Shadow Volume Extrusion using a Vertex Shader

Chris Brennan · 2004

The shadow volume technique of rendering real time shadows involves drawing geometry that represents the volume of space that bounds what is in the shadow cast by an object. To calculate if a pixel being drawn is in or out of a shadow, shoot a ray from the eye through the shadow volume towards the point on the rendered object and count the number of times the shadow volume is entered and exited. If the ray has entered more times than exited, the pixel being drawn is in shadow. The stencil buffer can be used to emulate this by rendering the back sides of the shadow volume triangles while incrementing the stencil buffer, followed by the front sides of the triangles, which decrement it. If the final result adds up to where it started, then you have entered and exited the shadow an equal number of times, and are therefore outside the shadow, otherwise you are inside the shadow. The next step is rendering a light pass that is masked out by a stencil test.

Read the paper · More papers on PaperTik