Normals are an important piece of geometry for rendering smooth surfaces. Generation of proper normals is very straightforward for continuous surfaces. To calculate a smooth normal for a vertex, average the facet normals of all the polygons that the vertex is in. However, this does not work when there are edges that are to be preserved in the model. This method will smooth out all edges. Therefore, it is desirable to selectively average normals according to a threshold for edge preservation.
A good example is a model of a cube. It is desirable for the cube to have flat faces. However, if all the facet normals around a vertex are averaged, and the resulting average normal is used, the cube takes on a spherical look (see figure 1), which is probably not the desired effect.
Another gotcha when creating smooth normals is duplicate vertices. These can be eliminated by 'welding' vertices that are closer than a tolerance to each other. Then the normals are recalculated. See figure 2 for an example of this.
Different models require different edge tolerance angles. Sometimes the angle across some edges is the same as the angle between some geometry that should be smooth. This is a problem with my current algorithm. It could be dealt with by localizing the averaging according to user defined areas. See figure 3 for an example of problems of this kind (the base of the pawn is faceted, when it shouldn't be, but the tolerance must be 76° for the edge in the middle to appear).
|