i
i
i
i
i
i
i
i
256 11. Texture Mapping
Then, vectorTurbulence is a direct analog of turbulence: sum a series of scaled
versions of vectorNoise.
Figure 11.12. Vector tur-
bulence on a sphere of ra-
dius 1.6. Lighting directly
from above. Top: k
1
=0.
Middle: k
1
= 0.08, k
2
=8.
Bottom: k
1
= 0.24, k
2
=8.
11.5 Displacement Mapping
One problem with Figure 11.12 is that the bumps neither cast shadows nor affect
the silhouette of the object. These limitations occur because we are not really
changing any geometry. If we want more realism, we can apply a displacement
map (Cook et al., 1987). A displacement map actually changes the geometry
using a texture. A common simplification is that the displacement will be in the
direction of the surface normal.
Figure 11.13. The points
p on the circle are each dis-
placed in the direction of n
by the function
f
(p).If
f
is
continuous, then the result-
ing points p
form a contin-
uous surface.
If we take all points p on a surface, with associated surface normal vectors n,
then we can make a new surface using a 3D texture d(p):
p
= p + f(p)n.
This concept is shown in Figure 11.13.
Displacement mapping is straightforward to implement in a z-buffer code by
storing the surface to be displaced as a fine mesh of many triangles. Each vertex
in the mesh can then be displaced along the normal vector direction. This results
in large models, but it is quite robust.
11.6 Environment Maps
Often we would like to have a texture-mapped background and for objects to
have specular reflections of that background. This can be accomplished using
environment maps (J. F. Blinn, 1976). An environment map can be implemented
as a background function that takes in a viewing direction b and returns a RGB
color from a texture map. There are many ways to store environment maps. For
example, we can use a spherical table indexed by spherical coordinates. In this
section, we will instead describe a cube-based table with six square texture maps,
often called a cube map.
The basic idea of a cube map is that we have an infinitely large cube with
a texture on each face. Because the cube is large, the origin of a ray does not
change what the ray “sees.” This is equivalent to an arbitrarily-sized cube that is
queried by a ray whose origin is at the Cartesian origin. As an example of how
a given direction b is converted to (u, v) coordinates, consider the right face of