
200 II Rendering Techniques
Normal maps. See Listing 14.2 for a normal layer fragment shader.
1. Set draw buffers to 100b, making the rendering affect only the third texture.
2. Set the color mask to affect either normal only or the displacement.
3. Draw the object with the depth test and disabled depth mask.
4. The vertex shader transforms the position into clip coordinates and generates
texture coordinates. It also has to compute the coordinate space in which the
normal map is given: tangent or object space. This space, or its mapping to
the world, is represented by a rotational transform in the form of a (quater-
nion,handedness) pair [Malyshau