We present a set of algorithms for rendering shadows using the stencil
buffer and shadow volume geometry. It can achieve greater performance
than previous methods by applying a series of techniques for culling,
clipping, and simplifying shadow volume geometry. The performance of
many 3D games is currently limited by pixel fill rate, and the
clipping and culling techniques effectively reduce the fill rate
consumption of shadow rendering by a constant factor. Scientific and
engineering 3D applications can instead be performance limited by the
hardware vertex processing rate and have unused fill rate. For a
shadow caster with O(s) possible silhouette edges and O(f) faces, the
simplification techniques reduce the triangle count needed for shadow
determination for two common cases from O(f) to O(s), reducing the
number of vertices processed. Finally, we use a vertex program and
indexed vertex array to reduce the memory bandwidth requirement from
36 to 6 bytes per triangle on programmable hardware. The effectiveness
of these techniques depends highly on the geometry of the 3D scene and
the graphics hardware available. For example, the simplification
method trades vertex rate for fill rate and will slow down
applications that are fill rate bound.
Our algorithm builds on previously published algorithms by Crow,
Everitt and Kilgard, and Lengyel. To facilitate implementation, we
review their methods and give a complete shadow algorithm rather than
just showing our improvements in isolation. Further implementation
details include an overview of the data structures used and a
pseudo-code implementation. An implementation in C++ using OpenGL is
available on our website.