Game Development Reference
Figure 10.4. In the left image, a depth offset is used to prevent self-shadowing artifacts. Without
this offset, striped shadowing artifacts can be seen on the concrete and rock in the right image.
( Image from the C4 Engine, courtesy of Terathon Software LLC. )
between representable values varies with depth.) When a surface is rendered at
an oblique angle relative to the direction of the light, the depths of many pixels in
a small neighborhood may be quantized to the same value in the shadow map. As
shown in Figure 10.5, this can result in some of the pixels being shadowed while
others are not.
The most straightforward solution to the self-shadowing problem is to apply
an offset to the values in the shadow map to make them appear slightly deeper
than they would normally be. This eliminates the shadow artifacts by moving the
shadow-casting surface underneath the actual surface that we render by a small
distance. However, as the surface of an object becomes more oblique with re-
spect to the light direction, a greater offset must be used in order to fix the
Fortunately, OpenGL provides a function called glPolygonOffset() that
applies a depth offset that depends on the camera-space slope of the surface at
each pixel. The following code solves the self-shadowing problem in most cases:
It's possible to use larger values to handle more problematic scenes, but values
that are too large result in shadows appearing to be disconnected from the objects
that are casting them.
Search Nedrilad ::