i
i
i
i
i
i
i
i
372 9. Global Illumination
erated that looks convincing. However, as with Haines’ method [487],
the umbra regions are overstated, and rendering artifacts occur wher-
ever two separate shadow edges cross. Arvo et al. [39] and de Boer [234]
each take a different approach, finding silhouette edges via edge detection
and then using image processing techniques to create plausible penum-
brae. By using the depth map to find the distance between occluder
and receiver, they grow variable-width silhouette edges via repeated fil-
tering operations. Arvo performs this operation in screen space, de Boer
in shadow map space. By using disk sampling to decide whether an edge
should cast a penumbra, de Boer is able to avoid artifacts due to crossing
edges.
Methods like PCF work by sampling the nearby receiver locations. Ide-
ally we want to determine how much of the area light source is visible from
a single receiver location. In 2006 a number of researchers explored back-
projection using the GPU. The idea is to treat the receiver as a viewer and
the area light source as a screen, and project the occluders back onto it.
A basic element of these algorithms is the micropatch. Each shadow map
texel has a given distance and size; this data can literally be treated as
a tiny polygon for purposes of backprojection. Both Schwarz and Stam-
minger [1142] and Guennebaud et al. [465] summarize previous work and
offer their own improvements. Bavoil et al. [76] take a different approach,
using depth peeling to create a multilayer shadow map.
The challenge is creating a backprojection algorithm that both works
efficiently to determine the amount of light covered by micropatches and
maintains reasonable quality. One concept that has proven useful is a
hierarchical min/max shadow map. While shadow map depths normally
cannot be averaged, the minimum and maximum values at each mipmap
level can be useful. That is, two mipmaps are formed, one saving the largest
z-depth found, and one the smallest. Given a texel location, depth, and
area to be sampled, the mipmaps can be used to rapidly determine fully
lit and fully shadowed conditions. For example, if the texel’s z-depth is
greater than the maximum z-depth stored for an area of the mipmap, then
the texel must be in shadow—no further samples are needed. This type
of shadow map makes the task of determining light visibility much more
efficient. In addition, it can be used in place of PCF sampling to create
smooth, noiseless penumbra shadows [262].
9.1.5 Shadow Optimizations
It has already been noted that shadows add to the level of realism of a
rendered image, and that shadows can be used as visual cues to determine
spatial relationships. However, shadows may also incur a great cost, both
i
i
i
i
i
i
i
i
9.2. Ambient Occlusion 373
in terms of performance and in memory usage. Some general optimization
strategies for faster shadow generation are presented here.
Since it is fairly difficult to perceive whether a shadow is correct, some
shortcuts can be taken. These simplifications can cause inaccuracies in the
shadows, but given a high enough frame rate, these are often difficult to
notice [114]. One technique is to use a low level of detail model to actually
cast the shadow. Whether this method helps performance is dependent on
the algorithm and the location of the bottleneck (see Chapter 15). Using
a simpler occluder lessens the load on the bus and geometry stage of the
pipeline, as fewer vertices are processed.
You yourself are currently in the shadows of billions of light sources
around the world. Light reaches you from only a few of these. In real-
time rendering, large scenes with multiple lights can become swamped with
computation if all lights are active at all times. Various culling strate-
gies can also work for lights. For example, the portal culling technique
in Section 14.4 can find which lights affect which cells. Another strategy
is to use lights that drop o with distance and that are made inactive
when beyond some given distance. Alternately, as the distance from a set
of lights increases beyond some value, the lights can be coalesced into a
single light source. One of the great strengths of a deferred shading sys-
tem (see Section 7.9.2) is that it can efficiently handle a large number of
lights.
If a light source is inside the view frustum, no object outside this frus-
tum can cast a shadow that is in the view. Thus, objects outside the
view frustum need not be processed. Note that this is not true in general.
Lights outside the view frustum can have shadows cast by objects outside
the frustum and so affect the image. A bounding volume can be formed by
using the light’s area of effect, and this can then be used to avoid unnec-
essary shadow generation and rendering by frustum and occlusion culling
(see Section 14.2) [114].
Govindaraju et al. [437] present a number of optimization techniques for
complex models. They use level of detail methods and combine potentially
visible sets with frustum and occlusion culling (see Chapter 14) to save
time overall and improve image quality.
9.2 Ambient Occlusion
When a light source covers a large solid angle, it casts a soft shadow. Am-
bient light, which illuminates evenly from all directions (see Section 8.3)
casts the softest shadows. Since ambient light lacks any directional vari-
ation, shadows are especially important—in their absence, objects appear
flat (see left side of Figure 9.36).
i
i
i
i
i
i
i
i
374 9. Global Illumination
Figure 9.36. A diffuse object lit evenly from all directions. On the left, the object is
rendered without any shadowing or interreflections. No details are visible, other than
the outline. In the center, the object has been rendered with ambient occlusion. The
image on the right was generated with a full global illumination simulation. (Images
generated using the Microsoft SDK [261] sample “PRTDemo.”)
Shadowing of ambient light is referred to as ambient occlusion. Unlike
other types of shadowing, ambient occlusion does not depend on light di-
rection, so it can be precomputed for static objects. This option will be
discussedinmoredetailinSection9.10.1. Here we will focus on techniques
for computing ambient occlusion dynamically, which is useful for animating
scenes or deforming objects.
9.2.1 Ambient Occlusion Theory
For simplicity, we will first focus on Lambertian surfaces. The outgoing
radiance L
o
from such surfaces is proportional to the surface irradiance E.
Irradiance is the cosine-weighted integral of incoming radiance, and in the
general case depends on the surface position p and the surface normal n.
Ambient light is defined as constant incoming radiance L
i
(l)=L
A
for all
incoming directions l. This results in the following equation for computing
irradiance:
E(p, n)=
Ω
L
A
cos θ
i
i
= πL
A
, (9.12)
where the integral is performed over the hemisphere Ω of possible incom-
ing directions. It can be seen that Equation 9.12 yields irradiance values
unaffected by surface position and orientation, leading to a flat appearance.
Equation 9.12 does not take visibility into account. Some directions
will be blocked by other objects in the scene, or by other parts of the
same object (see Figure 9.37, for example, point p
2
). These directions
will have some other incoming radiance, not L
A
. Assuming (for simplicity)
i
i
i
i
i
i
i
i
9.2. Ambient Occlusion 375
p
0
p
1
p
2
p
0
p
1
p
2
Figure 9.37. An object under ambient illumination. Three points (p
0
, p
1
,andp
2
)are
shown. On the left, blocked directions are shown as black rays ending in intersection
points (black circles). Unblocked directions are shown as arrows, colored according to
the cosine factor, so arrows closer to the surface normal are lighter. On the right, each
blue arrow shows the average unoccluded direction or bent normal.
that blocked directions have zero incoming radiance results in the following
equation (first proposed by Cook and Torrance [192, 193]):
E(p, n)=L
A
Ω
v(p, l)cosθ
i
i
, (9.13)
where v(p, l) is a visibility function that equals 0 if a ray cast from p in the
direction of l is blocked, and 1 if it is not. The ambient occlusion value
5
k
A
is defined thus:
k
A
(p)=
1
π
Ω
v(p, l)cosθ
i
i
. (9.14)
Possible values for k
A
range from 0 (representing a fully occluded surface
point, only possible in degenerate cases) to 1 (representing a fully open
surface point with no occlusion). Once k
A
is defined, the equation for
ambient irradiance in the presence of occlusion is simply
E(p, n)=k
A
(p)πL
A
. (9.15)
Note that now the irradiance does change with surface location, since k
A
does. This leads to much more realistic results, as seen in the middle of
Figure 9.36. Surface locations in sharp creases will be dark since their value
of k
A
is low—compare surface locations p
0
and p
1
in Figure 9.37. The
surface orientation also has an effect, since the visibility function v(p, l)
is weighted by a cosine factor when integrated. Compare p
1
to p
2
in
Figure 9.37. Both have an unoccluded solid angle of about the same size,
but most of the unoccluded region of p
1
is around its surface normal, so
5
Since the value increases with visibility, perhaps it would be more proper to call it
ambient visibility, but ambient occlusion is the commonly used term.
i
i
i
i
i
i
i
i
376 9. Global Illumination
the cosine factor is relatively high (as can be seen by the brightness of the
arrows). On the other hand, most of the unoccluded region of p
2
is off to
one side of the surface normal, with correspondingly lower values for the
cosine factor. For this reason, the value of k
A
is lower at p
2
.
From this point, we will cease to explicitly show dependence on the
surface location p,forbrevity.
9.2.2 Shading with Ambient Occlusion
Shading with ambient occlusion is best understood in the context of the
full shading equation, which includes the effects of both direct and indirect
(ambient) light. Similarly to ambient occlusion, shadows for direct light
sources use the visibility function v(l), but applied directly, rather than in
an integral. To help focus on the relevant terms in the (somewhat large)
shading equations, the terms under discussion will be shown in red.The
shading equation for Lambertian surfaces is
L
o
(v)=
c
diff
π
k
A
πL
A
+
n
k=1
v(l
k
)E
L
k
cos θ
i
k
, (9.16)
where l
k
is the light direction for the kth direct light source, E
L
k
is the
irradiance contribution of that light source (measured in a plane perpen-
dicular to l
k
), and θ
i
k
is the angle between l
k
and the surface normal n.
The symbol (piecewise vector multiply) is used, since both c
diff
and the
lighting values are spectral (RGB). The
cos function represents a cosine
clamped to non-negative values.
As we have seen in Section 8.3, non-Lambertian surfaces are shaded
with ambient light by defining an ambient color c
amb
that is a blend of the
diffuse and specular colors. The equivalent to Equation 9.16 for arbitrary
BRDFs is
L
o
(v)=k
A
c
amb
π
πL
A
+
n
k=1
v(l
k
)f(l
k
, v) E
L
k
cos θ
i
k
, (9.17)
where f(l, v) is the BRDF (see Section 7.5).
Ambient occlusion can be used with other types of indirect light besides
constant ambient. ILM uses ambient occlusion with irradiance environment
maps [728]. In addition to k
A
, ILM also compute an average unoccluded
direction or bent normal that is used to access the irradiance environment
map, instead of the surface normal. The bent normal is computed as a
cosine-weighted average of unoccluded light directions:
n
bent
=
Ω
v(l)l cos θ
i
i
Ω
v(l)l cos θ
i
i
. (9.18)
..................Content has been hidden....................

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