Conservative Backface Culling using Logical Operations
Hansong Zhang and Kenneth E. Hoff III
In the rendering of complex scenes that contain solid, enclosed, manifold objects, it has been a common practice to reduce the set of visible polygons by removing all those that face away from the viewer. This technique, called backface-culling, requires a comparison between the polygon's normal and the viewing direction towards the polygon. If the angle between the normal and the viewing direction is less than 90 degrees, the polygon is facing the same way as the viewer and is thus considered "back-facing", and if the angle is greater than 90 degrees it is facing in the opposite direction of the viewer and is considered "front-facing". It is important to note that the viewing direction must be towards some point on the polygon in question, so either the viewing direction must be calculated and compared for each polygon being tested or all of the polygons must be transformed into a parallel viewing volume (for perspective only, parallel projections do not require such a transformation). Traditional implementations of this technique, including hardware, often require the polygons to be perspectively transformed into an orthographic or parallel viewing-volume, or require a relatively expensive dot-product test between the polygon normal and the viewing direction towards some point on the polygon. In this paper, we propose a slightly conservative solution to this problem that overestimates the set of "frontfacing" polygons, for the perspective case, that works entirely in object space, requires no perspective transformations, requires only logical operations, and has very modest storage and preprocessing requirements.
The method works by first subdividing the set of all normals in three-dimensions into frusta formed from the uniformly subdivided grid cells formed on the sides of a cube and a center-of-projection at the center of the cube. Each frusta or cube frustum cell is represented by a single bit in a bit sequence whose length is the number of frustum cells that all of the normal directions have been subdivided into. As a preprocessing step, each polygon is then classified by its normal into one of these frustum cells; so each polygon will store a shortened form of the entire bit sequence with the appropriate bit set corresponding to the frustum cell its normal belongs to. After all of the polygons have been classified, we can perform a greatly simplified form of backface culling. For the current viewing direction, we will classify each frustum cell as either backfacing or frontfacing by appropriately setting the bits in a single bit sequence called the VMASK; set bits in the VMASK correspond to a cell that is backfacing. Now for each polygon, we can test if a polygon is backfacing by simply performing a logical AND with the polygon's normal bit sequence and the VMASK. If the result is greater than zero, the polygon's normal must have had a normal that is in a frustum cell that is backfacing. The general idea is very straightforward, but several problems remain. How do we store a "shortened form" of the polygon normal's bit sequence that must have a bit corresponding to every cube frustum cell? How do we find the set of backfacing cells that accounts for a perspective projection with respect to the current viewing direction? How do we avoid being too conservative in our selection of backfacing frustum cells that does not classify polygons incorrectly? We will tackle each one of these problems in turn.