Normals

Normals are vectors that are perpendicular to the surface we want to illuminate. Normals represent the orientation of the surface and are therefore critical to modeling the interaction between a light source and the object. Given that each vertex has an associated normal vector, we can use the cross product to calculate normals.

Cross-Product

By definition, the cross-product of vectors A and B will be a vector perpendicular to both vectors A and B.

Let's break this down. If we have the triangle conformed by vertices p0p1, and p2, we can define the v1 vector as p1 - p0 and the v2 vector as p2 - p0. The normal is then obtained by calculating the v1 x v2 cross-product. Graphically, this procedure looks something like the following:

We then repeat the same calculation for each vertex on each triangle. But, what about the vertices that are shared by more than one triangle? Each shared vertex normal will receive a contribution from each of the triangles in which the vertex appears.

For example, say that the p1 vertex is shared by the #1 and #2 triangles, and that we have already calculated the normals for the vertices of the #1 triangle. Then, we need to update the p1 normal by adding up the calculated normal for p1 on the #2 triangle. This is a vector sum. Graphically, this looks similar to the following:

Similar to lights, normals are generally normalized to facilitate mathematical operations.