• Advertisement
Sign in to follow this  

Light Bulb, Candle, Fire... in DirectX

This topic is 4424 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do you make visible light sources in 3D space of directX, like Light Bulbs, Lamps, Candles, Fire and such.... I know how to add a Spot light, or Point light, but it's is not visible, it only reflects on the surface of other objects. Can someone just give me guidelines where to look? Thanks. Petar.

Share this post


Link to post
Share on other sites
Advertisement
A light in DX using the fixed function pipeline (if you're not using vertex or pixel shaders you will be using it) basically alters the colours of verticies acording to a lighting equation, hence why it's not visible, there's nothing there to show.

If you want it to be visible you'll need to draw some geometry where the light is. This geometry could be a full 3d model or a simple bilboard displaying a sprite (e.g. a white circle or something like that). Geometry (e.g. a light-bulb) along with some sort of sprite to make the light actually look like a light can work pretty well.

Rendering fire so it looks good and lights up the scene as you would expect is going to be harder. You'll need some form of particle system to render the fire and then you'll need a method to render the light it casts, an animated projected texture may be a good option here.

Share this post


Link to post
Share on other sites
Conceptually (I don't know DX):

Create a mesh with point lights being attached to the vertices. Don't draw anything to do with this; just animate the mesh to move the lights around.

Then draw a semi-transparent sphere around the outside, so that the light shines through it. You'll want a diffuse material for a "soft glow".

Share this post


Link to post
Share on other sites
Regarding volumetric lights, you could render the light source to the final image by raytracing ('marching') through the volume in which the light travels.

This can be done by making a screen-sized textured quad, and applying a pixel shader to it so that each pixel position on the screen translates directly to the corresponding pixel position within the texture. Instant GPU-accelerated raytracer.

You perform the same calculations as you would regarding the light accumulation, but simply make the volumetric media translucent (ie: smokey air).

Shader constants set from within Direct3D could allow runtime configuration of colour(s), translucency level, even how noisy the particle pattern is in the air.

It's a lot to learn, but the result would be stunning to see.

As for fire, yeah, I don't know how easy it would be to do a self-lit object and have the light travelling accurately without some kind of Global Illumination technique. There is code and papers for doing GI and caustic reflection / refraction on the GPU at gpgpu.org

Even then, for absolutely realistic fire, you would want to do a free-surface representation using the Navier-Stokes equations. I know I sound like an evangelist when it comes to this technique, but it really is 100% as accurate as possible, considering the precision level of modern GPUs and FPUs. This technique has been documented by Jos Stam, and others.

A volumetric light area around an animated fire would be absolutely kick-butt!

[Edited by - taby on December 30, 2005 1:45:45 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement