Shadow Volumes

Shadow Volumes 1   Shadow Volumes 2


This project displays four tori rotating around a point light source. Each casts shadows on the other tori and on the walls. The effect is acheived in three passes:

  1. Draw entire scene lit by ambient and a small amount of diffuse light.
    This pass also sets the depth values for the visible scene.
  2. Draw shadow volumes into stencil buffer.
    By default the shadow volumes use the "zFail" technique, with an infinite far clip plane, as described in the "Robust Stenciled Shadow Volumes" paper.
  3. Draw scene lit with full diffuse and specular, in unshadowed areas (where stencil == 0).

Several optimisations to the above method are also supported; see the technical information page for details.


For Two-sided-stencil shadows:


For vertex program volume extrusion:



Practical & Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering, by Cass Everitt and Mark J Kilgard.

Nehe tutorials lesson 28 - stencil shadow volumes.

Download: (150 KB)