i
i
i
i
i
i
i
i
8.6. Irradiance Environment Mapping 315
Figure 8.22. Irradiance maps formed from the Grace Cathedral sphere map. The left
figure is formed by summing the weighted colors in the hemisphere above each pixel.
The right figure is generated by deriving a nine-term function approximating this ra-
diance map, then evaluating this function for eac h pixel. (Images courtesy of Ravi
Ramamoorthi, Computer Graphics Laboratory, Stanfor d University.)
Figure 8.23. Character lighting performed using an irradiance map. (Image courtesy of
the game “Dead or Alive
R
3,” Tecmo, Ltd. 2001.)
i
i
i
i
i
i
i
i
316 8. Area and Environmental Lighting
on page 302 has a corresponding irradiance map shown in Figure 8.22.
Figure 8.23 shows an example of an irradiance map in use.
Irradiance environment maps are stored and accessed separately from
the specular environment or reflection map, usually in a view-independent
EM representation such as a cube map. See Figure 8.24. Instead of using
the reflected view vector, the surface normal is used to access the cube map
to retrieve the irradiance. Values retrieved from the irradiance environment
map are multiplied by the diffuse reflectance, and values retrieved from the
specular environment map are multiplied by the specular reflectance. The
Fresnel effect can also be modeled, increasing specular reflectance (and
possibly decreasing diffuse reflectance) at glancing angles [535].
Since the irradiance environment maps use extremely wide filters, it
is difficult to create them efficiently on the fly. King [660] discusses how
to perform convolution on the GPU to create irradiance maps. He was
able to generate irradiance maps at rates of more than 300 fps on 2004-era
hardware.
If a dynamic environment map is rendered only for the purpose of gen-
erating an irradiance environment map, it can have very low resolution.
However, any area light sources may “fall between the texels,” causing
them to flicker or drop out completely. To avoid this problem, Wiley [1351]
proposes representing such light sources by large “cards” when rendering
the dynamic environment map.
As in the case of glossy reflections, dynamic light sources can also be
added into prefiltered irradiance environment maps. This allows the envi-
ronment map to react dynamically to moving light sources without filtering
Figure 8.24. A cube map and its corresponding filtered irradiance map. (Reprinted with
permission from Microsoft Corporation.)
i
i
i
i
i
i
i
i
8.6. Irradiance Environment Mapping 317
the entire environment map. An inexpensive method to do this is given by
Brennan [140]. Imagine an irradiance map for a single light source. In the
direction of the light, the radiance is at a maximum, as the light hits the
surface straight-on. Radiance for a given surface normal direction (i.e., a
given texel) falls off with the cosine of the angle to the light, then is zero
as the surface faces away from the light. The GPU can be used to rapidly
add in this contribution directly to an existing irradiance map. Instead of
rendering a point light to a cube map and filtering the map, the filtered
appearance of the light is represented by an object. This object can be vi-
sualized as a hemisphere centered around the observer, with the pole of the
hemisphere along the light’s direction. The hemisphere itself is brightest in
this direction, falling off to zero at its edge. Rendering this object directly
into the cube map gives an irradiance contribution for that light. In this
way, each moving point light in a scene can add its effect to the irradiance
map by rendering its corresponding hemisphere.
As with specular environment maps, it is possible to modify how irradi-
ance environment maps are accessed, so that they represent local reflections
rather than infinitely far ones. One way to do this is to use a blend of the
normal and the direction from the reference location (the “center” of the
environment map) to the surface location. This gives some variation with
location, while still being affected by the surface normal [947].
8.6.1 Spherical Harmonics Irradiance
Although we have only discussed representing irradiance environment maps
with textures such as cube maps, other representations are possible. Spher-
ical harmonics (SH) have become popular in recent years as an irradiance
environment map representation. Spherical harmonics are a set of mathe-
matical functions that can be used to represent functions on the unit sphere
such as irradiance.
Spherical harmonics
5
are basis functions: a set of functions that can be
weighted and summed to approximate some general space of functions. In
the case of spherical harmonics, the space is scalar functions on the unit
sphere.” A simple example of this concept is shown in Figure 8.25. Each
of the functions is scaled by a weight or coefficient such that the sum of
the weighted basis functions forms an approximation to the original target
function.
Almost any set of functions can form a basis, but some are more con-
venient to use than others. An orthogonal set of basis functions is a set
such that the inner product of any two different functions from the set is
5
The basis functions we discuss here are more properly called “the real spherical
harmonics,” since they represent the real part of the complex-valued spherical harmonic
functions.
i
i
i
i
i
i
i
i
318 8. Area and Environmental Lighting
0
0
1
0
1
1234512345 12345
Figure 8.25. A simple example of basis functions. In this case, the space is “functions
that have values between 0 and 1 for inputs between 0 and 5.” The left side shows
an example of such a function. The middle shows a set of basis functions (each color
is a different function). The right side shows an approximation to the target function,
formed by multiplying each of the basis functions by a weight (the basis functions are
shown scaled by their respective weights) and summing them (the black line shows the
result of this sum, which is an approximation to the original function, shown in gray for
comparison).
zero. The inner product is a more general, but similar, concept to the dot
product. The inner product of two vectors is their dot product, and the
inner product of two functions is defined as the integral of the two functions
multiplied together:
f
i
(x),f
j
(x)≡
f
i
(x)f
j
(x)dx, (8.36)
where the integration is performed over the relevant domain. For the func-
tions shown in Figure 8.25, the relevant domain is between 0 and 5 on the
x-axis (note that this particular set of functions is not orthogonal). For
spherical functions the form is slightly different, but the basic concept is
the same:
f
i
(n),f
j
(n)≡
Θ
f
i
(n)f
j
(n), (8.37)
where Θ indicates that the integral is performed over the unit sphere.
An orthonormal set is an orthogonal set with the additional condition
that the inner product of any function in the set with itself is equal to 1.
More formally, the condition for a set of functions {f
j
()} to be orthonormal
is
f
i
(),f
j
() =
0, where i = j,
1, where i = j.
(8.38)
Figure 8.26 shows a similar example to Figure 8.25, where the basis func-
tions are orthonormal.
The advantage of an orthonormal basis is that the process to find the
closest approximation to the target function is straightforward. This pro-
cess is called basis projection. The coefficient for each basis function is
i
i
i
i
i
i
i
i
8.6. Irradiance Environment Mapping 319
0
0
1
0
1
1234512345 12345
Figure 8.26. Orthonormal basis functions. This example uses the same space and target
function as Figure 8.25, but the basis functions have been modified to be orthonormal.
The left side shows the target function, the middle shows the orthonormal set of basis
functions, and the right side shows the scaled basis functions. The resulting approxima-
tion to the target function is shown as a dotted black line, and the original function is
shown in gray for comparison.
simply the inner product of the target function f
target
() with the appropri-
ate basis function:
k
j
= f
target
(),f
j
(),
f
target
()
n
j=1
k
j
f
j
().
(8.39)
This is very similar in concept to the standard basis” introduced in
Section 4.2.4. Instead of a function, the target of the standard basis is a
point’s location. Instead of a set of functions, the standard basis is com-
posed of three vectors. The standard basis is orthonormal by the same
definition used in Equation 8.38. The dot product (which is the inner
product for vectors) of every vector in the set with another vector is zero
(since they are perpendicular to each other), and the dot product of every
vector with itself is one (since they are all unit length). The method of pro-
jecting a point onto the standard basis is also the same: The coefficients
are the result of dot products between the position vector and the basis
vectors. One important difference is that the standard basis exactly repro-
duces every point, and a finite set of basis functions only approximates its
target functions. This is because the standard basis uses three basis vectors
to represent a three-dimensional space. A function space has an infinite
number of dimensions, so a finite number of basis functions can only ap-
proximate it. A roughly analogous situation would be to try to represent
three-dimensional points with just the x and y vectors. Projecting a three-
dimensional point onto such a basis (essentially setting its z-coordinate to
0) is an approximation roughly similar to the projection of a function onto
a finite basis.
..................Content has been hidden....................

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