i
i
i
i
i
i
i
i
362 9. Global Illumination
area light
occluder
receiver
point light
occluder
PP
Q RQ R
Figure 9.27. On the left, the brown lines from the area light source show where penum-
brae are formed. For a single point P on the receiver, the amount of illumination received
could be computed by testing a set of points on the area light’s surface and finding which
are not blocked by any occluders. On the right, a point light does not cast a penum-
bra. PCF approximates the effect of an area light by reversing the process: At a given
location, it samples over a comparable area on the shadow map to derive a percentage
of how many samples are illuminated. The red ellipse shows the area sampled on the
shadow map. Ideally, the width of this disk is proportional to the distance between the
receiver and occluder.
This idea of retrieving multiple samples from a shadow map and blend-
ing the results is called percentage-closer filtering (PCF) [1053]. Soft shad-
ows are produced by area lights. The amount of light reaching a location
on a surface is a function of what proportion of the light’s area is visible
from the location. PCF attempts to approximate a soft shadow for a point
(or directional) light by reversing the process. Instead of finding the light’s
visible area from a surface location, it finds the visibility of the point light
from a set of surface locations near the original location. See Figure 9.27.
The name “percentage-closer filtering” refers to the ultimate goal, to find
the percentage of the samples taken that are visible to the light. This
percentage is how much light then is used to shade the surface.
In PCF, locations are generated nearby to a surface location, at about
the same depth, but at different texel locations on the shadow map. The
key idea is that each location must be individually compared with the
shadow map to see if it is visible. It is these resulting boolean values, lit or
unlit, that are then blended to get a soft shadow. Typical area summation
techniques for textures, such as mipmapping or summed area tables, cannot
be used directly on shadow maps. Such techniques applied to the shadow
map would give an average depth for the occluders over some area, which
i
i
i
i
i
i
i
i
9.1. Shadows 363
Figure 9.28. The depth map on the left has edge detection and dilation applied, to create
an edge map, on the right. This map identifies potential penumbra areas. Time is saved
by applying PCF to only these areas and using single samples for the rest. (Images
courtesy of John Isidoro, ATI Research, Inc.)
has little direct correlation to the amount that a receiving point is occluded
from the light. We cannot simply average the depths and compare this
depth to our location. What this means in practice is that each sample
must be evaluated separately (with some potential exceptions, discussed
further on).
Sampling a large number of locations on the shadow map per pixel is
an expensive proposition. Only points that are in the penumbra benefit
from PCF. The problem is knowing which pixels are fully lit or are fully
in shadow. Uralsky [1284] takes a few samples, and if they differ, samples
more. Isidoro [594, 595] uses image processing techniques on the shadow
map to create a bitonal edge map to determine where PCF sampling is
likely to be useful. The costs of processing the map are usually outweighed
by the savings from performing expensive PCF sampling on just a few
locations. See Figure 9.28.
There are numerous variations of how to sample and filter nearby shadow
map locations. Variables include how wide an area to sample, how many
samples to use, the sampling pattern, and how to weight the results. The
width of the area sampled affects how soft the shadow will appear. If the
sampling area’s width remains constant, shadows will appear uniformly
soft, all with the same penumbra width. This may be acceptable under
some circumstances, but appears incorrect where there is ground contact
between the occluder and receiver. As shown in Figure 9.29, the shadow
should be sharp at the point of contact and softer as the distance between
occluder and receiver increases.
i
i
i
i
i
i
i
i
364 9. Global Illumination
Figure 9.29. Percentage-Closer Filtering. On the left, hard shadows with a little PCF
filtering. In the middle, constant width soft shadows. On the right, variable-width soft
shadows with proper hardness where objects are in contact with the ground. (Images
courtesy of NVIDIA Corporation.)
If we could know in advance the distance of the occluder from the
receiver, we could set the area to sample accordingly and approximate the
effect of an area light. One simple, but incorrect, idea is to examine the
shadow map for the occluder location and find the distance between this
location and the receiver. The problem with this naive scheme is that if a
location is not in shadow for the point light, no further processing will be
done. In Figure 9.27, points Q and R are in a penumbra. The distance to
the occluder from point Q is a simple lookup. Point R, however, is fully
lit by the basic shadow map—a simple lookup will fail to find the proper
sample width for this point.
What is needed is a way to find whether a surface location could be
partially affected by any occluder. The distance to the relevant occluder
from the location is key in determining the width of the area to sample.
Fernando [340, 916] attempts a solution by searching the nearby area on
the shadow map and processing the results. The idea is to determine all
possible occluders within this sampled area. The average distance of these
occluders from the location is used to determine the sample area width:
w
sample
= w
light
d
r
d
o
d
r
, (9.9)
where d
r
is the distance of the receiver from the light and d
o
the average
occluder distance. If there are no occluders found, the location is fully
lit and no further processing is necessary. Similarly, if the location is fully
occluded, processing can end. Otherwise the area of interest is sampled and
the light’s approximate contribution is computed. To save on processing
costs, the width of the sample area is used to vary the number of samples
taken. The drawback of this method is that it needs to always sample
an area of the shadow map to find the occluders, if any. Valient and de
Boer [1287] present a method of processing the shadow map to create a
map in which the distance to the nearest occluder is stored in each texel.
i
i
i
i
i
i
i
i
9.1. Shadows 365
Figure 9.30. The upper left shows PCF sampling in a 4 × 4 grid pattern. The upper
right shows a 12-tap Poisson sampling pattern on a disk. Using this pattern to sample
the shadow map gives the improved result on the lower left, though artifacts are still
visible. On the lower right, the sampling pattern is rotated randomly around its center
from pixel to pixel. The structured shadow artifacts turn into (much less objectionable)
noise. (Images courtesy of John Isidoro, ATI Research, Inc.)
i
i
i
i
i
i
i
i
366 9. Global Illumination
Once the width of the area to be sampled is determined, it is impor-
tant to sample in a way to avoid aliasing artifacts. The typical method
is to sample the area using a precomputed Poisson distribution pattern.
A Poisson distribution spreads samples out so that they are neither near
each other nor in a regular pattern. See Figure 9.30. It is well known
that using the same sampling locations for each pixel can result in pat-
terns [195]. One solution is to randomly rotate the sample pattern around
its center to turn the aliasing into noise. A separate repeating texture can
be used to hold precomputed random rotations that are accessed using the
screen pixel location [594]. One problem with this technique is that as
the viewer moves the screen sampling patterns cause artifacts by staying
in place. Mittring [887] discusses projecting a mipmapped version of the
noise pattern into world space to minimize artifacts.
One problem that is exacerbated by using PCF is self-shadowing, i.e.,
“surface acne.” In addition to the standard problems described earlier,
caused by discrete sampling of the light map, other problems can arise.
By sampling in a wider area from a single location on a surface, some of
the test samples may get blocked by the true surface. Biasing based on
slope does not fix this problem. One solution is to add an additional bias
factor: Move sample locations closer relative to the distance between the
sample and the original location [1287]. See Figure 9.31. Sculer [1140]
gives a more involved method based on using the depths retrieved from
PCF sampling to determine a better slope gradient.
receiver
point light
P
receiver
point ligh
t
P
Figure 9.31. On the left, the surface sampled with PCF partially shadows itself. On the
right, the PCF is sampled in a cone shape to help avoid this problem.
..................Content has been hidden....................

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