Building Vertex Normals from an Unstructured Polygon List

Abstract Many polygonal models are used as piecewise-flat approximations of curved models, and are thus “smooth-shaded” when displayed. To apply Gouraud or Phong shading to a model one needs to compute a surface normal at every vertex; often this simply involves averaging the surface normal of each polygon sharing that vertex. This Gem provides a general-purpose procedure that computes vertex normals from any list of polygons. I assume that the polygons describe a simple manifold in 3D space, so that every local neighborhood is a flat sheet. I also assume that the structure is a mesh; that is, there are no “T” vertices, isolated vertices, or dangling edges. Except for the addition of normals at the vertices, the input model is unchanged. I infer the topology of the model by building a data structure that allows quick access to all the polygons that have a vertex in the same region of space. To find the normal for a selected vertex, one needs only search the region surrounding the vertex and then average the normals for all polygons that share that vertex.