Light Bulb, Candle, Fire... in DirectX

Started by
4 comments, last by Petar Titelski 18 years, 3 months ago
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.
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.
how could you make shining ball with animated living magic light?
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".
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]
Thanks to all!

This topic is closed to new replies.

Advertisement