PDA

View Full Version : Shadow Volumes.



MrShoe
07-21-2002, 04:35 PM
Ok, im studying shadow volumes atm. I can project the shadow volume polygons ok, thats easy... But id like to clear something up. How do i work out using the stencil buffer where i should actually draw the shadow polygons.

Mezz
07-21-2002, 10:36 PM
You don't use the stencil buffer to work out where to draw the shadow polygons, you use the stencil to work out where to NOT put the light contribution from a particular source.

This is generally done by the following steps:
1) Clear stencil buffer to zero, disable colour (and depth buffer?) writes
2) Set stencil buffer to increment on depth pass, do nothing on depth fail
3) Render front faces of shadow volumes
4) Set stencil to decrement on depth pass, do nothing on depth fail
5) Render back faces of shadow volumes

Thus, when all the shadow volumes faces are rendered, you will have a value of zero in the stencil buffer where there is no shadow, and another value if it is in shadow.

There is a great paper by a couple of the guys at nVidia on the whole thing, that explains this really well. Check out developer.nvidia.com under OpenGL, it's by Mark Kilgard & Cass Everitt I believe.

-Mezz

MrShoe
07-22-2002, 01:09 AM
Thanks, coz i get the whole idea of a shadow volume, but i dont fully understand what comes after determining the shadow volume.