View Full Version : Volumetric lighting using Shadow volumes

05-07-2012, 06:31 AM
I have heard of ways to do this with shadow maps. I remember also reading something not to long ago where a shadow map was used on a tessellated quad to make a mesh that contained only light area. Though I can not find anything about volumetric lighting and shadow volumes. Also Google is not being useful. Likely because of the words being used.

Any help is much appreciated.

carsten neumann
05-08-2012, 08:47 AM
At the risk of stating the obvious, but your question suffers from similar problems as your search: it is too vague ;)
Describe what you want to do (I'm not familiar with the term "volumetric lighting" for example) or perhaps you can post a link that describes the technique you are after for shadow maps.

05-08-2012, 07:57 PM
Here is a link what volumetric lighting is. http://en.wikipedia.org/wiki/Volumetric_lighting
Essentially it is known as light beams,god rays and some other stuff.

I get how to do it with a mesh generated that perfectly fits area of light. Though shadow volumes can be inside each other.
Here is a video of volumetric lighting. http://www.youtube.com/watch?v=2dUL3vjSgPk. It uses a depth map to make a mesh of the volume of light and presumably uses that same mesh for shadow volumes.

The problem with this method is you still have to worry about depth map resolution.

I'm starting to think there is no solution.

Maybe the best I can do is make my shadow volumes to make detailed shadows and then render the depth map and create the shadow volume. it will be harder to notice a low detailed volumetric lighting than shadows.

Ilian Dinev
05-10-2012, 04:24 PM

Uses a texture, with no depth info necessary. Does something like radial blur. Source and demo available.

Ilian Dinev
05-10-2012, 04:54 PM
About shadowvolume reconstruction, detect horizontal and vertical scanline spans in the shadowmap. The span [A;B] contains depth values that are <= than the depth at endpoints A and B. So, depth(x) <= depth(A) and depth(x) <= depth(B), where A < x < B. After finding such endpoints A and B (each scanline can have many of those, and maybe also spans that are inside other spans (but naturally no spans that partially overlap; only embedding of spans allowed), generate a front-facing extruded quad from A, and a back-facing one from B. Extrusion starts from depth of the endpoint, towards infinity, and converges to the pointlight's position. Each quad should have a varying float, which contains the distance from the complementary endpoint. You could have to generate 4 million quads out of a 1000x1000 shadowmap. Overdraw is dependent on how many spans per scanline you find.
After you construct the shadowvolume, simply ... visualize it. With subtractive blending. Enable backface culling, and the gl_FragColor should be the inverse interpolated distance to the complementary edge. Shorter spans will generate darker shading.

Another idea, skipping shadowvolumes completely, would be to use the shadowmap directly, in a fullscreen quad: raycast stuff, and along the distance sample uniformly 10-20 times the shadowmap, to see whether the specific pixel is shadowed at depths 0.1, 0.2, 0.3 ,... etc. Accumulate results, write to gl_FragColor with blending.

(note: I havent tested any of this, simply got a few ideas on implementing the effect after seeing the second video that you linked to)

05-11-2012, 01:06 AM
Uses a texture, with no depth info necessary. Does something like radial blur. Source and demo available.
I have seen that technique. It only works when the source light is visible.