Game Development Reference
In-Depth Information
to moving to the right in 2D in the normal map. (Often, the bump map
shares the same UV coordinates as other maps, but if they differ, it's the
coordinates used for bump mapping that count.) Similarly, the y basis
vector, known as the binormal 22 and denoted here as v , corresponds to the
direction of increasing v, although whether this motion is “up” or “down”
in the texture space depends on the conventions for the origin in (u,v)
space, which can differ, as we discussed earlier. Of course, the coordinates
for the tangent and binormal are given in model space, just like the surface
normal. As implied by the hats over the variables, basis vectors are usually
stored as unit vectors.
For example, assume that a certain texel in a normal map has the RGB
triple [37,128,218], which is decoded to the unit vector [−0.707,0,0.707].
We interpret this to mean that the local surface normal is pointing at about
a 45 o angle from a “flat” surface normal defined by the interpolated vertex
normal. It points “to the left,” where “left” is meaningful in the image
space of the normal map and really means “in the direction of decreasing
u.”
In summary, the tangent, binormal, and normal are the axes of a co-
ordinate space known as tangent space, and the coordinates of the per-
texel normal are interpreted by using this coordinate space. To obtain the
model-space normal from a tangent-space normal, we first decode the nor-
mal from the map and then transform it into model space just like any
other vector. Let s t = [s t x ,s y ,s z ] denote the tangent-space surface normal
and s m = [s x ,s y ,s z ] denote the model-space surface normal. We can
determine s m simply by taking the linear combination of the basis vectors
s m = s t x u + s y v + s z n .
By now, we know that this is the same thing as multiplying s t by a matrix
whose rows are the basis vectors:
2
4 u
3
5
s m = s t
v
n
.
(10.18)
Remember that the polygon mesh is just an approximation for a po-
tentially curved surface, so the surface normal we use for lighting varies
continuously over each face in order to approximate the true surface nor-
mal. In the same way, the tangent and binormal basis vectors also vary
continuously over the mesh, since they should be perpendicular to the sur-
face normal and tangent to the surface being approximated. But even on
a flat surface, the basis vectors can change over the surface if a texture is
22 The term “bitangent” is probably more correct; but it's less commonly used.
Search WWH ::




Custom Search