Game Development Reference
In-Depth Information
An extreme version of this situation occurs when two faces are placed
back-to-back. Such infinitely thin double-sided geometry can arise with
foliage, cloth, billboards, and the like. In this case, since the normals are
exactly opposite, averaging them produces the zero vector, which cannot
be normalized. The simplest solution is to detach the faces so that the
vertex normals will not average together. Or if the front and back sides
are mirror images, the two “single-sided” polygons can be replaced by one
“double-sided” one. This requires special treatment during rendering to
disable backface culling (Section 10.10.5) and intelligently dealing with the
normal in the lighting equation.
A more subtle problem is that the averaging is biased towards large
numbers of triangles with the same normal. For example, consider the
vertex at index 1 in Figure 10.11. This vertex is adjacent to two trian-
gles on the top of the cube, but only one triangle on the right side and
one triangle on the back side. The vertex normal computed by averaging
the triangle normals is biased because the top face normal essentially gets
twice as many “votes” as each of the side face normals. But this topol-
ogy is the result of an arbitrary decision as to where to draw the edges
to triangulate the faces of the cube. For example, if we were to trian-
gulate the top face by drawing an edge between vertices 0 and 2 (this is
known as “turning” the edge), all of the normals on the top face would
change.
Techniques exist to deal with this problem, such as weighing the con-
tribution from each adjacent face based on the interior angle adjacent to
the vertex, but it's often ignored in practice. Most of the really terrible
examples are contrived ones like this, where the faces should be detached
anyway. Furthermore, the normals are an approximation to begin with,
and having a slightly perturbed normal is often di cult to tell visually.
Although some modeling packages can deliver vertex normals for you,
fewer provide the basis vectors needed for bump mapping. As we see in
Section 10.9, techniques used to synthesize vertex basis vectors are similar
to those described here.
Before we go on, there is one very important fact about surface normals
that we must mention. In certain circumstances, they cannot be trans-
formed by the same matrix that is used to transform positions. (This is
an entirely separate issue from the fact that normals should not be trans-
lated like positions.) The reason for this is that normals are covariant
vectors. “Regular” vectors, such as position and velocity, are said to be
contravariant: if we scale the coordinate space used to describe the vector,
the coordinates will respond in the opposite direction. If we use a coordi-
nate space with a larger scale (for example, using meters instead of feet) the
coordinates of a contravariant vector respond to the contrary, by becoming
smaller. Notice that this is all about scale; translation and rotation are not
Search WWH ::




Custom Search