i
i
i
i
i
i
i
i
9.2. Ambient Occlusion 377
The result of the integral is divided by its own length to produce a normal-
ized result (the notation x indicates the length of the vector x). See the
right side of Figure 9.37.
The shading equation for applying ambient occlusion to an irradiance
environment map is similar to Equation 9.17, except that the environment
map irradiance E
env
(n
bent
) replaces the ambient irradiance πL
A
. We will
use the generic notation E
ind
to represent indirect irradiance from either
ambient light or an irradiance environment map.
Unlike the use of k
A
to attenuate a constant ambient light (which is
exact), accessing an irradiance environment map by the bent normal n
bent
and attenuating the result by the ambient occlusion factor k
A
is an ap-
proximation. However, it produces high-quality results; ILM used it for
several feature films. Pharr [1012] presents an alternative that uses the
GPU’s texture filtering hardware to produce a potentially more accurate
result. An area of the original (unfiltered) environment map is dynamically
filtered. The center of the filtered area is determined by the direction of the
bent normal, and its size depends on the value of k
A
. This technique uses
a texture instruction that takes user-supplied derivatives. Unfortunately,
on most hardware, this instruction is significantly slower than an ordinary
texture access.
ILM [728] sometimes shades direct lights with the bent normal instead
of the surface normal, and attenuates the result by the ambient occlusion
factor instead of using regular shadowing techniques. Lights treated in this
way have some of the visual properties of a large area light.
A similar technique, proposed by Iones et al. [587] is intended to model
the indirect contribution of point or directional lights. This is particularly
useful in environments with dynamic lighting. Imagine a room that is dark
until a character walks in carrying a torch. The direct lighting from the
torch is modeled by a point light using a shadowing technique such as
shadow maps. However, even areas in shadow or facing away from the
torch receive some indirect bounce light from the torch. In the technique
proposed by Iones et al., the indirect contributions of light sources are
modeled by adding them to the indirect irradiance:
L
o
(v)=k
A
c
amb
π
E
ind
+k
ind
n
k=1
E
L
k
+
n
k=1
v(l
k
)f(l
k
, v) E
L
k
cos θ
i
k
,
(9.19)
where the factor k
ind
is a value between 0 and 1, used to control the relative
intensity of the direct and indirect contributions of the lights. Since this
model is empirical, the value of k
ind
should be manually set to achieve
visually pleasing results. Note that unlike the direct contributions, the
indirect contributions of the light sources are unaffected by cosine factors.
i
i
i
i
i
i
i
i
378 9. Global Illumination
If bent normals are available, it is possible to combine the two previous
techniques by applying the bent normals to the indirect light contributions:
L
o
(v)=k
A
c
amb
π
E
ind
+ k
ind
n
k=1
E
L
k
cos θ
i
k
+
n
k=1
v(l
k
)f(l
k
, v)E
L
k
cos θ
i
k
,
(9.20)
where θ
i
k
is the angle between l
k
and the bent normal n
bent
.
Mittring [887] describes a similar approach used in Crytek’s Crysis.
Instead of a bent normal, Crytek uses a blend of the light direction and the
surface normal, and instead of the k
ind
factor, it uses separate intensity,
color, and distance falloffs for the direct and indirect contributions of the
light source. Otherwise their approach is the same as Equation 9.20.
Although using ambient occlusion to attenuate glossy or specular envi-
ronment maps is incorrect, Kozlowski and Kautz [695] show that in some
cases this can work reasonably well. See Section 9.10.2 for more general
approaches to shadowing glossy and specular environment maps.
9.2.3 Visibility and Obscurance
The visibility function v(l) used to compute the ambient occlusion factor
k
A
(see Equation 9.14) needs to be carefully defined. For discrete objects,
such as characters or vehicles, it is straightforward to define v(l) based on
whether a ray cast from a surface location in direction l intersects any other
part of the same object. However, this does not account for occlusion by
other, nearby objects. Often, the object can be assumed to be placed on
a flat plane for lighting purposes. By including this plane in the visibility
calculation, more realistic occlusion can be achieved. Another benefit is
that the occlusion of the ground plane by the object can be used as a
contact shadow [728].
Unfortunately, the visibility function approach fails for enclosed ge-
ometry. Imagine a scene consisting of a closed room containing various
objects—all surfaces will have a k
A
value of zero! Empirical approaches,
which attempt to reproduce the look of ambient occlusion without nec-
essarily simulating physical visibility, tend to work better for closed or
semi-closed geometry. Some of these approaches were inspired by Miller’s
concept of accessibility shading [867], which models how nooks and crannies
in a surface capture dirt or corrosion.
Zhukov et al. [1409] introduced the idea of obscurance, which modifies
the ambient occlusion computation by replacing the visibility function v(l)
with a distance mapping function ρ(l):
k
A
=
1
π
Ω
ρ(l)cosθ
i
i
. (9.21)
i
i
i
i
i
i
i
i
9.2. Ambient Occlusion 379
Unlike v(l), which has only two valid values (1 for no intersection and 0
for an intersection), ρ(l) is a continuous function of intersection distance.
The value of ρ(l) is 0 at an intersection distance of 0 and 1 at intersection
distances greater than a specified distance d
max
(or no intersection at all).
Intersections beyond d
max
do not need to be tested, which can considerably
speed up the computation of k
A
.
Although obscurance is nonphysical (despite attempts to justify it on
physical grounds), it is quite effective and practical. One drawback is
that the value of d
max
needs to be set by hand to achieve pleasing results.
6
endez-Feliu et al. [856, 857] extend obscurance to account for color bleed-
ing as well.
Iones et al. [587] propose a variant of ρ(l) that asymptotically ap-
proaches 1 as the intersection distance goes to infinity. This has a speed
disadvantage but does not require manually setting a d
max
parameter.
9.2.4 Accounting for Interreflections
Although the results produced by ambient occlusion are darker than those
produced by a full global illumination simulation (compare the middle and
right images in Figure 9.36 on page 374), they are visually convincing.
Computing the value of k
A
is significantly cheaper than performing a full
global illumination calculation. This is particularly important for dynamic
scenes with deforming objects, where it is preferable to compute k
A
in real
time.
The differences between ambient occlusion and global illumination are
due to interreflections. Equation 9.14 assumes that the radiance in the
blocked directions is zero, while in reality interreflections will introduce a
nonzero radiance from those directions. The effect of this can be seen as
darkening in the creases and pits of the model in the middle of Figure 9.36
(on page 374), compared to the model on the right. This difference can
be addressed by increasing the value of k
A
. Using the obscurance distance
mapping function instead of the visibility function (see Section 9.2.3) can
also mitigate this problem, since the obscurance function often has values
greater than 0 for blocked directions.
Accounting for interreflections in a more accurate manner is expensive,
since it requires solving a recursive problem (to shade one point, other
points must first be shaded, and so on). Stewart and Langer [1219] pro-
pose an inexpensive, but surprisingly accurate, solution. It is based on
6
This is often the case in computer graphics, where a technique has no direct physical
basis but is “perceptually convincing.” The goal is usually a plausible image, so such
techniques are fine to use. Some advantages of methods based on theory are that they
can work automatically and can be improved further by reasoning about how the real
world works.
i
i
i
i
i
i
i
i
380 9. Global Illumination
the observation that for Lambertian scenes under diffuse illumination, the
surface locations visible from a given location tend to have similar radi-
ance. By assuming that the radiance L
i
from blocked directions is equal to
the outgoing radiance L
o
from the currently shaded point, the recursion is
broken and an analytical expression can be found:
E =
πk
A
1 c
amb
(1 k
A
)
L
A
. (9.22)
This is equivalent to replacing the ambient occlusion factor k
A
with a new
factor k
A
:
k
A
=
k
A
1 c
amb
(1 k
A
)
. (9.23)
This equation will tend to brighten the ambient occlusion factor, making it
visually closer to the result of a full global illumination solution, including
interreflections. The effect is highly dependent on the value of c
amb
.The
underlying approximation assumes that the ambient color is the same over
the surface. In cases where the ambient color varies, it should be blurred
before use in these equations, so that the results are still somewhat valid.
This blurring can also produce an effect somewhat similar to color bleeding.
Hoffman and Mitchell [555] use this method to illuminate terrain with sky
light.
9.2.5 Dynamic Computation of Ambient Occlusion
For static scenes, the ambient occlusion factor k
A
and bent normal n
bent
can be precomputed (this will be discussed in more detail in Section 9.10.1).
However, for dynamic scenes or deforming objects, better results can be
achieved by computing these factors dynamically. Methods for doing so
can be grouped into those that operate in object space, and those that
operate in screen space.
Object-S pace Methods
Offline methods for computing ambient occlusion usually involve casting
a large number of rays (dozens to hundreds) from each surface point into
the scene and checking for intersection. This is a very expensive operation,
and real-time methods focus on ways to approximate or avoid much of this
computation.
Bunnell [146] computes the ambient occlusion factor k
A
and bent nor-
mal n
bent
by modeling the surface as a collection of disk-shaped elements
placed at the mesh vertices. Disks were chosen since the occlusion of one
disk by another can be computed analytically, avoiding the need to cast
rays. Simply summing the occlusion factors of a disk by all the other
i
i
i
i
i
i
i
i
9.2. Ambient Occlusion 381
disks leads to overly dark results due to double-shadowing (if one disk
is behind another, both will be counted as occluding the surface, even
though only the closer of the two should be counted). Bunnell uses a
clever two-pass method to avoid double-shadowing. The first pass com-
putes ambient occlusion including double-shadowing. In the second pass,
the contribution of each disk is reduced by its occlusion from the first pass.
This is an approximation, but in practice, yields results that are quite
good.
Computing occlusion between each pair of elements is an order O(n
2
)
operation, which is too expensive for all but the simplest scenes. The cost
is reduced by using simplified representations for distant surfaces. A hi-
erarchical tree of elements is constructed, where each node is a disk that
represents the aggregation of the disks below it in the tree. When perform-
ing inter-disk occlusion computations, higher-level nodes are used for more
distant surfaces. This reduces the computation to order O(n log n), which
is much more reasonable.
Each disk’s location, normal, and radius are stored in textures, and
the occlusion computations are performed in fragment shaders. This is
because at the time the technique was developed (2005), GPUs’ fragment
shading units possessed significantly higher computation throughput than
their vertex shading units. On modern GPUs with unified shader units,
vertex shaders may be a better choice for this algorithm, since the lowest-
level elements are placed at the vertices.
Bunnell’s technique is quite efficient and produces high-quality results—
it was even used by ILM when performing renders for the Pirates of the
Caribbean films [1071].
Hoberock [553] proposes several modifications to Bunnell’s algorithm
that improve quality at higher computational expense. A distance attenu-
ation factor is also proposed, which yields results similar to the obscurance
factor proposed by Zhukov et al. [1409].
Ren et al. [1062] approximate the occluding geometry as a collection
of spheres. The visibility function of a surface point occluded by a single
sphere is represented using spherical harmonics. Such visibility functions
are simple to project onto the spherical harmonic basis. The aggregate
visibility function for occlusion by a group of spheres is the result of multi-
plying the individual sphere visibility functions. Unfortunately, multiplying
spherical harmonic functions is an expensive operation. The key idea is to
sum the logarithms of the individual spherical harmonic visibility func-
tions, and exponentiate the result. This produces the same end result as
multiplying the visibility functions, but summation of spherical harmonic
functions is significantly cheaper than multiplication. The paper shows
that with the right approximations, logarithms and exponentiations can be
performed quickly, yielding an overall speedup.
..................Content has been hidden....................

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