Let's cover an example showcasing normal mapping in action:
- Open the ch10_03_normal-map.html file in a browser:
- Rotate the cube to see the effect that the normal map has on the lit cube. Keep in mind that the profile of the cube has not changed. Let's examine how this effect is achieved.
- First, we need to add a new attribute to our vertex buffers. There are three vectors needed to calculate the tangent space coordinates for lighting: the normal, the tangent, and the bitangent:
- We have already covered normals, so let's investigate the other two vectors. The tangent represents the up (positive y) vector for the texture relative to the polygon surface. The bitangent represents the left (positive x) vector for the texture relative to the polygon surface.
- We only need to provide two of the three vectors as vertex attributes...