i
i
i
i
i
i
i
i
6.7. Bump Mapping 189
maximal reuse of the normal maps. It is also easier to compress tangent
space normal maps, since the sign of the z component (the one aligned with
the unperturbed surface normal) can usually be assumed to be positive.
The downside of tangent-space normal maps is that more transformations
are required for shading, since the reference frame changes over the surface.
To use illumination within a typical shading model, both the surface
and lighting must be in the same space: tangent, object, or world. One
method is to transform each light’s direction (as viewed from the vertex)
into tangent space and interpolate these transformed vectors across the
triangle. Other light-related values needed by the shading equation, such
as the half vector (see Section 5.5), could also be transformed, or could be
computed on the fly. These values are then used with the normal from the
normal map to perform shading. It is only the relative direction of the light
from the point being shaded that matters, not their absolute positions in
space. The idea here is that the light’s direction slowly changes, so it can be
interpolated across a triangle. For a single light, this is less expensive than
transforming the surface’s perturbed normal to world space every pixel.
This is an example of frequency of computation: The light’s transform is
computed per vertex, instead of needing a per-pixel normal transform for
the surface.
However, if the application uses more than just a few lights, it is more
efficient to transform the resulting normal to world space. This is done by
using the inverse of Equation 6.5, i.e., its transpose. Instead of interpolating
a large number of light directions across a triangle, only a single transform
is needed for the normal to go into world space. In addition, as we will see
in Chapter 8, some shading models use the normal to generate a reflection
direction. In this case, the normal is needed in world space regardless,
so there is no advantage in transforming the lights into tangent space.
Transforming to world space can also avoid problems due to any tangent
space distortion [887]. Normal mapping can be used to good effect to
increase realism—see Figure 6.30.
Filtering normal maps is a difficult problem, compared to filtering color
textures. In general, the relationship between the normal and the shaded
color is not linear, so standard filtering methods may result in objectionable
aliasing. Imagine looking at stairs made of blocks of shiny white marble.
At some angles, the tops or sides of the stairs catch the light and reflect
a bright specular highlight. However, the average normal for the stairs is
at, say, a 45-degree angle; it will capture highlights from entirely different
directions than the original stairs. When bump maps with sharp specular
highlights are rendered without correct filtering, a distracting sparkle effect
can occur as highlights wink in and out by the luck of where samples fall.
Lambertian surfaces are a special case where the normal map has an
almost linear effect on shading. Lambertian shading is almost entirely a