Game Development Reference
In-Depth Information
0
1
1
1
0
+
1
+
1
+
1
C
Figure 10.7. Numbers at the ends of rays emanating from the camera position C repre-
sent the values left in the stencil buffer for a variety of cases. The stencil value is incre-
mented when front faces of the shadow volume pass the depth test, and the stencil value
is decremented when back faces of the shadow volume pass the depth test. The stencil
value is not changed when the depth test fails.
The original stencil algorithm renders the shadow volume in two stages. In
the first stage, the front faces of the shadow volume (with respect to the camera)
are rendered using a stencil operation that increments the value in the stencil
buffer whenever the depth test passes. In the second stage, the back faces of the
shadow volume are rendered using a stencil operation that decrements the value
in the stencil buffer whenever the depth test passes. As illustrated in Figure 10.7,
this technique leaves nonzero values in the stencil buffer wherever the shadow
volume intersects any surface in the scene, including the surface of the object
casting the shadow.
There are two major problems with the method just described. The first is
that no matter what finite distance we extrude an object's silhouette away from a
light source, it is still possible that it is not far enough to cast a shadow on every
object in the scene that should intersect the shadow volume. The example shown
in Figure 10.8 demonstrates how this problem arises when a light source is very
Search Nedrilad ::




Custom Search