Calculating and displaying normals
Unlike rays, which have a starting position and direction and are infinite in length, normals are special vectors assigned to mesh surfaces and vertices. A normal is a vector that usually sits at 90 degrees to a surface. I say usually because they can be manipulated for special surface texturing effects. Normals are used to calculate how light falls on a surface, as well as define the side of a polygon to which a texture is applied. There are two places normals are used; on surfaces and vertices, as shown in Figure 10.6, though usually, they are defined with vertices in mesh files:
Figure 10.6: Normals
As shown in Figure 10.6, mathematically, a plane has two normals, which can be found using the cross product of two vectors on the surface. Recall from Chapter 9, Practicing Vector Essentials, that multiplying two vectors together results in a third vector that sits at right angles to the initial vectors. In Figure 10.6, one...