Shadow volumes are a technique used in 3D computer graphics to add shadows to a rendered scene. At the current time (late 2003) it is generally considered the most practical general purpose real-time shadowing system given the capabilities of modern 3D graphics hardware.

A shadow volume divides the virtual world into two; areas that are in shadow and areas that are not.

In order to construct a shadow volume, project a line from the light through each vertex in the shadow casting object to some point (generally at infinity). These projections will together form a volume; any point inside that volume is in shadow, everything outside is lit by the light.

Current research and implementations focus on the use of a hardware stencil buffer to optimize the algorithm making use of hardware acceleration.

In order to test whether a given pixel in the rendered image is shadowed or not, the shadow volume itself is rendered, though to the stencil buffer only and not to the final image. For every front-facing face in the shadow volume the value in the stencil buffer is increased; for every back-facing face it is decreased.

Once all faces in the shadow volume have been rendered to the stencil buffer, any pixel with a value not equal to zero will be in shadow.

In order to understand why, think in terms of a ray of light heading back from the pixel on the screen - if it passes into the shadow volume, it will be through a front-facing face and so the stencil buffer value will be increased. If it then passes out through the back of the volume (through a back-facing face) it will be decreased.

If, however, the pixel is in shadow then the value will only be decreased when it leaves the shadow volume at the back, and so the value will be non-zero.

See also

  • Shadow Maps

External Articles