i
i
i
i
i
i
i
i
348 9. Global Illumination
stencil buffer. Second, since it is not image based (unlike the shadow map
algorithm described next), it avoids sampling problems and thus produces
correct sharp shadows everywhere. This can sometimes be a disadvantage.
For example, a character’s clothing may have folds that give thin, sharp
shadows that alias badly.
The shadow volume algorithm can be extended to produce visually con-
vincing soft shadows. Assarsson and Akenine-M¨oller [49] present a method
called penumbra wedges, in which the projected shadow volume planes are
replaced by wedges. A reasonable penumbra value is generated by deter-
mining the amount a given location is inside a wedge. Forest et al. [350]
improve this algorithm for the case where two separate shadow edges cross,
by blending between overlapping wedges.
There are some serious limitations to the shadow volume technique.
Semitransparent objects cannot receive shadows properly, because the sten-
cil buffer stores only one object’s shadow state per pixel. It is also difficult
to use translucent occluders, e.g., stained glass or other objects that atten-
uate or change the color of the light. Polygons with cutout textures also
cannot easily cast shadows.
A major performance problem is that this algorithm burns fill rate, as
shadow volume polygons often cover many pixels many times, and so the
rasterizer becomes a bottleneck. Worse yet, this fill rate load is variable
and difficult to predict. Silhouette edge computation can cut down on
the fill rate, but doing so on the CPU is costly. Lloyd et al. [783] use
culling and clamping techniques to lower fill costs. Another problem is
that curved surfaces that are created by the hardware, such as N-patches,
cannot also generate shadow volumes. These problems, along with the
limitation to opaque, watertight models, and the fact that shadows are
usually hard-edged, have limited the adoption of shadow volumes. The
next method presented is more predictable in cost and can cast shadows
from any hardware-generated surface, and so has seen widespread use.
9.1.4 Shadow Map
In 1978, Williams [1353] proposed that a common Z-buffer-based renderer
could be used to generate shadows quickly on arbitrary objects. The idea
is to render the scene, using the Z-buffer algorithm, from the position of
the light source that is to cast shadows. Note that when the shadow map
is generated, only Z-buffering is required; that is, lighting, texturing, and
the writing of color values into the color buffer can be turned off.
When a single Z-buffer is generated, the light can “look” only in a
particular direction. Under these conditions, the light source itself is either
a distant directional light such as the sun, which has a single view direction,
or some type of spotlight, which has natural limits to its viewing angle.