"There's a saying that states: 'The road to hell is paved with good intentions'. There's hardly anything that better describes communism than that. All good hopes and dreams of justice and equality have ended in oppression and dictatorship."
- Peter Eriksson, Green Party of Sweden

Framework 4 (Last updated: October 25, 2019)
Framework 3 (Last updated: February 6, 2017)
Framework 2 (Last updated: October 8, 2006)
Framework (Last updated: October 8, 2006)
Libraries (Last updated: September 16, 2004)
Really old framework (Last updated: September 16, 2004)
Volumetric lighting
Sunday, January 12, 2003 | Permalink

Executable
Source code
VolumetricLighting.zip (565 KB)

Required:
Vertex shader 2.0
Pixel shader 1.0
This demo does a volumetric lighting effect for an arbitrary number of light volumes by using a vertex shader. The demo calculates the sum of the distances through the light volumes of the ray from the camera to the vertex. This is a fairly complex calculation, even though I suspect there exist a simplier solution that what I implemented. So in the 128 instruction of vertex shader 1.1 I would at most be able to fit 2 volumes. But with vertex shader 2.0 I can use a loop to support an arbitrary amount of light volumes without going through the instruction barrier and don't need to use different shaders depending on what number of light volumes I use.

The good thing about this technique is of course that it's cheap from a fillrate point of view as it runs in a vertex shader. Fillrate usually is the limiting factor, not so in this demo though. It would be better to do this kind of calculation on fragment level though, but that would make even the 9700 pro beg for mercy.
The backside of this technique is that it requires a decent amount of tesselation to give good results. The original UT level (DM-Fractal) I used had too few polygons so I tesselate it into smaller polygons at load time for better quality.

Should run on Radeon 9500/9700 and Parhelia.