Game Development Reference
In-Depth Information
7.8.2 Tangent Space
Since the vector 0, 0,1 in a bump map represents an unperturbed normal, we
need it to correspond to the interpolated normal vector that we would ordinarily
use in the lighting formula. This can be achieved by constructing a coordinate
system at each vertex in which the vertex normal always points along the positive
z axis. In addition to the normal vector, we need two vectors that are tangent to
the surface at each vertex in order to form an orthonormal basis. The resulting
coordinate system is called tangent space or vertex space and is shown in
Figure 7.16.
Once a tangent-space coordinate system has been established at each vertex
of a triangle mesh, the direction to light vector L is calculated at each vertex and
transformed into the tangent space. The tangent-space vector L is then interpolat-
ed across the face of a triangle. Since the vector 0, 0,1 in tangent space corre-
sponds to the normal vector, the dot product between the tangent-space direction
to light L and a sample from a bump map produces a valid Lambertian reflection
The tangent vectors at each vertex must be chosen so that they are aligned to
the texture space of the bump map. For surfaces generated by parametric func-
tions, tangents can usually be calculated by simply taking derivatives with re-
spect to each of the parameters. Arbitrary triangle meshes, however, can have
bump maps applied to them in any orientation, which necessitates a more general
method for determining the tangent directions at each vertex.
7.8.3 Calculating Tangent Vectors
Our goal is to find a 3
matrix at each vertex that transforms vectors from ob-
ject space into tangent space. To accomplish this, we consider the more intuitive
problem of transforming vectors in the reverse direction from tangent space into
object space. Since the normal vector at a vertex corresponds to 0, 0,1 in tangent
space, we know that the z axis of our tangent space always gets mapped to a ver-
tex's normal vector.
We want our tangent space to be aligned such that the x axis corresponds to
the s direction in the bump map and the y axis corresponds to the t direction in
the bump map. That is, if Q represents a point inside the triangle, we would like
to be able to write
B ,
Search Nedrilad ::

Custom Search