IT lexicon › Programming › Shadow volume

Shadow volume

Programming På svenska → Updated: 2026-10-24

Shadows as geometry: extrude the silhouette edges away from the light into closed volumes and use the stencil buffer to count which pixels land inside.

Frank Crow described the method in 1977. You find an object's silhouette edges as seen from the light, extrude them to infinity so a volume forms, and render it against the stencil buffer: every time the ray to a pixel enters a volume you count up, every time it exits you count down. If the tally is nonzero the pixel is in shadow. The result is razor-sharp, pixel-exact shadows with no resolution dependence.

The naive version broke when the camera sat inside a volume. John Carmack's "depth-fail" trick (also derived independently by others) counted against the far plane instead and fixed it; the technique carried Doom 3 (2004). But the fill-rate cost is brutal and the geometry must be closed, so shadow mapping eventually won on sheer cheapness.

← Back to the lexicon