i
i
i
i
i
i
i
i
352 9. Global Illumination
Too much bias causes a problem called “Peter Panning,” in which the
object appears to be slightly above the underlying surface. One method
that helps ameliorate this effect is to make sure the light frustum’s near
plane is as far away from the light as possible, and that the far plane is as
close as possible. Doing so increases the effective precision of the Z-buffer.
Another method of avoiding self-shadowing problems is to render only
the backfaces to the shadow map. Called second-depth shadow map-
ping [1321], this scheme works well for many situations; by default, most
surfaces have no chance of shadowing themselves. Or, more precisely, the
surfaces that now self-shadow are those that face away from the light, so
it does not matter. The problem cases are when objects are two sided or
in contact with one another. If an object is a two-sided cutout, e.g., a
palm frond or fence, self-shadowing can occur because the backface and
the frontface are in the same location. Similarly, if no biasing is performed,
problems can occur near silhouette edges or thin objects, since in these
areas backfaces are close to frontfaces. Also, solid objects must be “water-
tight” (manifold and closed), else the object may not fully cast a shadow.
The other problem with second-depth testing is that light leaks can
occur where objects are in contact or interpenetrate. In such cases, the
occluding backface’s stored distance is in some places greater than the
sampled receiver’s. This problem is in some ways the opposite of self-
shadowing. Problems can also occur in concavities in a solid model. Care-
ful rendering (e.g., pushing double-sided objects a bit farther away from
the light when building the shadow map), composition (avoiding objects
touching as much as possible), modeling (actually building extra occluder
polygons inside the shadow object to avoid light leaks), and traditional
biasing techniques can give good results. This algorithm is often used in
game development, where content and interactions are under full control
of the creators.
Woo [1374] proposes a general method of avoiding many biasing and
light leak problems by creating an intermediate surface on the fly. Instead
of keeping just the closest depth value, the two closest values are tracked in
separate buffers. For solid objects that do not intersect in space, frontfaces
and backfaces can be rendered to generate the separate buffers. Using two
passes of depth peeling is a general way to generate these buffers [76, 324].
These two buffers are averaged into one, which is then used as the shadow
map. For a solid object, this technique usually creates a shadowing surface
that passes through the middle of the object. For example, a sphere would
create a circle passing through its center and facing the light. However, this
technique can also have problems, such as light leaks and self-shadowing
for thin objects and near silhouette edges. See Figure 9.18. In practice,
the problems seen at j and k are relatively rare and not that noticeable,
especially when using multiple shadow map samples per fragment. By
i
i
i
i
i
i
i
i
9.1. Shadows 353
i
j
k
intermediate
surface
Figure 9.18. Woo’s shadow mapping method. A directional light comes from directly
above. The depths from each of the two surfaces closest to the light are combined to
give an intermediate surface that is stored in the shadow map. This surface is shown as
a blue dashed line. The two sets of surfaces on the right have problems due to sampling
limitations. A single surface covers area i, so this intermediate surface is somewhere
behind this part of the surface. At location j, the point may be erroneously found to be
in light if the shadow texel to the left of it is sampled, since this intermediate surface
is farther from the light. Similarly, point k may be incorrectly considered to be in light
because the intermediate surface to its left is more distant.
creating an intermediate surface, we can eliminate most self-shadowing
and light leak problems, at the cost of extra processing.
One other problem that can occur with shadow mapping is that as the
viewer moves, the view volume changes size. This causes the shadow map
generated to vary its view, which in turn causes the shadows to shift slightly
from frame to frame. Koonce [691] and Mittring [887] present the solution
of forcing each succeeding directional shadow map generated to maintain
the same relative texel beam locations in world space. That is, you can
think of the shadow map as imposing a grid frame of reference on the whole
world. As you move, the shadow map is generated for a different window
onto that world. In other words, the view is snapped to a grid to maintain
frame to frame coherence.
Resolution Enhancement
An example of stair-stepping artifacts is shown in Figure 9.19. The shadow
is blocky because each texel of the shadow map covers a large number of
pixels. In this case, the projection of each shadow map texel is stretched
over the surface because the eye is close to the surface but the light is far
away. This type of artifact is called perspective aliasing. Texels also are
stretched on surfaces that are nearly edge-on to the light, but that directly
face the viewer. This problem is called projective aliasing [1119, 1216].
i
i
i
i
i
i
i
i
354 9. Global Illumination
Figure 9.19. Perspective aliasing stairstepping artifacts due to the shadow map projec-
tion being magnified.(Image from NVIDIA ”Hardware Shadow Maps” demo program,
courtesy of NVIDIA Corporation.)
Blockiness can be decreased by incr e asing the shadow map resolution, but
at the cost of additional memory and processing. Another useful technique
is to limit the light’s view frustum to only those objects in view of the
camera [658] and further restrict this frustum to just the shadow-casting
objects, since shadow receivers outside this frustum are always in light.
At some point, increasing resolution farther or using other simple opti-
mizations is no longer an option. Similar to how textures are used, ideally
we want one shadow map texel to cover about one pixel. If we have a light
source located at the same p o sition as the eye, the shadow map perfectly
maps one for one with the screen-space pixels (and of course no visible shad-
ows, since the light illuminates exactly what the eye sees). Say the light
eye
light
eye
light
wall wall
Figure 9.20. The light and the eye focus on a wall. On the left, the light has fewer samples
at the top of the wall than at the bottom, compared to the eye’s even distribution. By
shifting the view plane of the light to match that of the eye, the texels again align one
for one.
i
i
i
i
i
i
i
i
9.1. Shadows 355
eye
light
floor
eye
light
floo
r
Figure 9.21. For an overhead light, on the left the sampling on the floor does not
match the eye’s rate. By changing the view direction and projection window, the light’s
sampling rate is biased toward having a higher density of texels nearer the eye.
source is a flashlight, held at the chest, pointing at a wall being viewed.
See Figure 9.20. The shadow-map-to-pixel correspondence is close, but the
top of the wall has shadow map texels that are stretched.
To make the shadow map’s samples match the eye’s, the light’s view
and perspective matrices are modified. Specifically, the light’s view vector
is made to match the eye’s, and the view window is shifted. Normally,
we think of a view as being symmetric, with the view vector in the center
of the frustum. However, the view direction merely defines a view plane.
The window defining the frustum can be shifted, skewed, or rotated on this
plane, creating a quadrilateral that gives a different mapping of world to
view. The quadrilateral is still sampled at regular intervals, as this is the
nature of a linear transform matrix and its use by the GPU. By varying
the view direction and the window’s bounds, the sample density can be
changed.
This scheme shows how shifting the view direction and window changes
the distribution of samples. The shift shown improves the sampling rate
along the wall, but does not address the problem of putting more shadow
samples closer to the viewer. Figure 9.21 shows a view shift that creates
more shadow map samples near the eye, where they are needed. For specific
planar targets such as walls and floors, Chong and Gortler [175] show that it
is possible to perfectly match view and light samples. Where the difficulty
comes in is when the entire view frustum’s volume is remapped to the
light’s space.
As King [658] points out, there are 22 degrees of freedom in mapping
the light’s view to the eye’s. Exploration of this solution space has led to
a number of different algorithms that attempt to better match the light’s
sampling rates to the eye’s over the depth range. Stamminger and Dret-
takis rst presented perspective shadow mapping (PSM) in 2002 [1216].
Their idea is for each light to attempt to fit its view to a post-perspective
transform of the scene’s visible objects. Koslov [692] discusses implemen-
tation issues and solutions. PSM is a difficult approach to understand and
i
i
i
i
i
i
i
i
356 9. Global Illumination
Figure 9.22. The image to the left is created using standard shadow mapping; the image
to the right using LiSPSM. The projections of each shadow map’s texels are shown. The
two shadow maps have the same resolution, the difference being that LiSPSM reforms
the light’s matrices to provide a higher sampling rate nearer the viewer. (Images courtesy
of Daniel Scherzer, Vienna University of Technology.)
implement in a robust fashion [122, 355]. Wimmer et al. [1359, 1361] in-
troduced light space perspective shadow maps (LiSPSM or LSPSM), which
also modify the light’s matrices. See Figure 9.22. Martin and Tan [823]
presented trapezoidal shadow maps (TSM), which place a trapezoid around
the eye’s frustum and warp it to fit the shadow map. Both LiSPSM and
TSM do not use post-perspective space, so they are able to avoid the prob-
lems its use engenders. LiSPSM sees more use, due to patent protection on
TSM. Hybrid approaches are also possible; Mikkelsen [865] describes how
any two schemes can be combined, using the strengths of each. This is
done by deriving a separating plane that determines which scheme is best
to use for a given location.
An advantage of these matrix warping algorithms is that no additional
work is needed beyond modifying the light’s matrices. Each method has its
own strengths and weaknesses [355], as each can help match sampling rates
for some geometry and lighting situations, while worsening these for others.
Biasing to avoid surface acne can become a more serious problem when the
matrices are warped. Another problem with these techniques is that they
can jump in quality from one frame to the next. As the lighting situation
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset