i
i
i
i
i
i
i
i
9.1. Shadows 337
Figure 9.7. On the left, a rendering using Heckbert and Herf’s method, using 256 passes.
On the right, Haines’ method in one pass. The umbrae are too large with Haines’
method, which is particularly noticeable around the doorway and window.
ground plane that shows a soft shadow.
2
We then describe less accurate,
faster methods.
Soft shadows appear whenever a light source has an area. One way to
approximate the effect of an area light is to sample it by using a number
of point lights placed on its surface. For each of these point light sources,
an image is rendered and added to the accumulation buffer. The average
of these images is then an image with soft shadows. Note that, in theory,
any algorithm that generates hard shadows can be used along with this
accumulation technique to produce penumbrae. In practice, doing so may
be untenable because of execution time or memory constraints.
Heckbert and Herf use a frustum-based method to produce their shad-
ows. The idea is to treat the light as the viewer, and the ground plane
forms the far clipping plane of the frustum. The frustum is made wide
enough to encompass the ground plane polygon.
A shadow texture for the receiver is generated in the following way. For
each sample on the light source, the receiver is first rendered by using this
sample as a point light source. Then the projection matrix is used to render
all objects inside the pyramid. Since these objects should generate shadows,
they are drawn in black (and so Z-buffering, texturing, and lighting can be
turned off). All of these images are averaged into the accumulation buffer
to produce a shadow texture. See the left side of Figure 9.7.
A problem with the sampled area light method is that it tends to look
like what it is: a number of overlapping shadows from point light sources.
Instead of varying the location of samples on the light’s surface, Gooch et
al. [424] move the receiving plane’s location up and down and the projec-
tions cast upon it are averaged. This method has the advantage that the
2
Basic hard shadows can also be generated using this technique.
i
i
i
i
i
i
i
i
338 9. Global Illumination
shadows created are nested, which generally looks better and so requires
fewer samples. In addition, a single shadow projection could be generated
and reused to create the nested effect. A drawback of Gooch’s method
is that if the object touches the receiver, the shadow will not be modeled
correctly. Darkness will appear to leak out from under the object. Another
problem with both of these methods is that the shadows are quantized be-
tween a limited number of grayscale shades. For n shadow passes, only
n + 1 distinct shades can be generated. One answer is to fool the eye by
applying a color texture to the receiver, as the texture will have a masking
effect and hide this quantization [341].
Another approach is to use convolution, i.e., filtering. Soler and Sil-
lion [1205] create soft shadows by rendering the hard shadow to a texture
and then softening (convolving) it by using a filter in the shape of the area
light source. They vary the amount of blurring of the shadow dependent
on the occluder silhouette’s distance from the receiver, blending between
blurred shadow images. This technique gives smooth, soft shadows for ob-
jects at a constant distance from the shadow receiver. Similar to Gooch’s
method, objects touching the ground can cause problems, as the shadow is
supposed to be sharp where it touches and become softer as the distance
increases. In a similar vein, Pranckeviˇcius [1029] provides a method of
smoothly varying the projected shadow’s penumbra on the texture. The
distance between receiver and occluder at each texel determines the amount
of post-process blur to perform.
Haines [487] presents a method that creates soft shadows in a single pass
for circular area lights. The idea is to start with a normal projected hard
shadow and then paint the silhouette edges with gradients that go from dark
in the center to white on the edges to create penumbrae. These gradient
areas have a width proportional to the height of the silhouette edge casting
Figure 9.8. On the left, a visualization of Haines’ method of soft shadowing on a plane.
The object casts a hard shadow, and then gradient areas are drawn to simulate the
penumbra. On the right is the result.
i
i
i
i
i
i
i
i
9.1. Shadows 339
the shadow. Each silhouette edge casts a quadrilateral gradient area, and
each edge endpoint casts a circular gradient area. By using the Z-buffer
and painting these penumbrae objects using three-dimensional primitives
such as wedges and cones, the rendered gradient areas are made to properly
overlap (see Figure 9.8).
The methods of Gooch et al. and Haines share another problem. They
both create umbra regions that are too large, since the projected shadow
will always be larger than the object. In reality, if an area light is larger
than the width of an occluder, the occluder will cast a smaller or nonexis-
tent umbra region. See Figure 9.7 on page 337 for a comparison between
Heckbert and Herf’s method and Haines’.
9.1.2 Shadows on Curved Surfaces
One way to extend the idea of planar shadows to curved surfaces is to use a
generated shadow image as a projective texture [849, 917, 939, 1146]. Think
of shadows from the light’s point of view (literally). Whatever the light
sees is illuminated; what it does not see is in shadow. Say the occluder is
rendered in black from the light’s viewpoint into an otherwise white texture.
This texture can then be projected onto the surfaces that are to receive
the shadow. Effectively, each vertex on the receivers has a (u, v)texture
coordinate computed for it and has the texture applied to it. These texture
coordinates can be computed explicitly by the application or implicitly
using the projective texturing functionality of the graphics hardware. We
call this the shadow texture technique. It is also occasionally known as the
shadow map method in the game development community, as it is analogous
to light mapping, but for shadows. Because a different technique, covered
in Section 9.1.4, is more commonly called “shadow mapping,” we use the
term “shadow texture” for the method here.
When forming a shadow texture, only the area of overlap between cast-
ers and receivers needs to be rendered. For example, the texture can often
be considerably smaller than the area of the potential receivers, since the
texture is needed only where the shadows are cast.
When rendered, the shadow texture modifies the receiver surfaces. One
example is shown in Figure 9.9. This technique works particularly well
for circumstances where the silhouette of the shadowing object does not
change shape, so that the texture generated can be reused. Bloom [114]
gives a wide range of optimizations that can be performed to minimize the
cost of this technique.
There are some serious drawbacks of this method. First, the designer
must identify which objects are occluders and which are their receivers.
The receiver must be maintained by the program to be further from the
light than the occluder, otherwise the shadow is “cast backwards.” Also,
i
i
i
i
i
i
i
i
340 9. Global Illumination
Figure 9.9. Shadow projection. On the left is the scene from the light’s view. In the
middle is the occluding object rendered as a shadow texture. On the right, the shadow
texture has been applied. (Images courtesy of Hubert Nguyen.)
occluding objects cannot shadow themselves. The next two sections present
algorithms that generate correct shadows without the need for such inter-
vention or limitations.
Note that a variety of lighting patterns can be performed by using pre-
built projective textures. A spotlight is simply a square projected texture
with a circle inside of it defining the light. A Venetian blinds effect can
be created by a projected texture consisting of horizontal lines. Shadows
can be made soft by blurring the texture. This type of texture is called
a light attenuation mask, cookie texture,orgobo map. A prebuilt pattern
can be combined with a projected texture created on the fly by simply
multiplying the two textures together. Such lights are discussed further in
Section 7.4.3.
9.1.3 Shadow Volumes
Presented by Heidmann in 1991 [531], a method based on Crow’s shadow
volumes [208] can cast shadows onto arbitrary objects by clever use of the
stencil buffer. This technique is also sometimes called volumetric shadows.
To begin, imagine a point and a triangle. Extending the lines from a
point through the vertices of a triangle to infinity yields an infinite pyramid.
The part under the triangle, i.e., the part that does not include the point,
is a truncated infinite pyramid, and the upper part is simply a pyramid.
This is illustrated in Figure 9.10. Now imagine that the point is actually
a point light source. Then, any part of an object that is inside the volume
of the truncated pyramid (under the triangle) is in shadow. This volume
is called a shadow volume.
Say we view some scene and follow a ray from the eye through a pixel
until the ray hits the object to be displayed on screen. While the ray is on
its way to this object, we increment a counter each time it crosses a face
i
i
i
i
i
i
i
i
9.1. Shadows 341
point
triangle
infinite pyramid
shadow
volume
pyramid
Figure 9.10. Left: The lines from a point light are extended through the vertices of a
triangle to form an infinite pyramid. Right: The upper part is a pyramid, and the lower
part is an infinite truncated pyramid, also called the shadow volume. All geometry that
is inside the shadow volume is in shadow.
of the shadow volume that is frontfacing (i.e., facing toward the viewer).
Thus, the counter is incremented each time the ray goes into shadow. In
the same manner, we decrement the same counter each time the ray crosses
a backfacing face of the truncated pyramid. The ray is then going out of
a shadow. We proceed, incrementing and decrementing the counter until
the ray hits the object that is to be displayed at that pixel. If the counter
is greater than zero, then that pixel is in shadow; otherwise it is not.
This principle also works when there is more than one triangle that casts
shadows. See Figure 9.11.
Doing this geometrically is tedious and time consuming. But there is
a much smarter solution [531]: The stencil buffer can do the counting for
us. First, the stencil buffer is cleared. Second, the whole scene is drawn
into the frame buffer with only ambient and emission components used, in
order to get these lighting components in the color buffer and the depth
information into the Z-buffer. Third, Z-buffer updates and writing to
the color buffer are turned off (though Z-buffer testing is still done), and
then the frontfacing polygons of the shadow volumes are drawn. During
this process, the stencil operation is set to increment the values in the
stencil buffer wherever a polygon is drawn. Fourth, another pass is done
with the stencil buffer, this time drawing only the backfacing polygons
of the shadow volumes. For this pass, the values in the stencil buffer are
decremented when the polygons are drawn. Incrementing and decrementing
are done only when the pixels of the rendered shadow-volume face are
visible (i.e., not hidden by any real geometry). At this point the stencil
..................Content has been hidden....................

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