In computer graphics, back-face culling determines whether a polygon of a graphical object is potentially visible. It is a step in the graphical pipeline usually performed in screen space that tests whether the points in the polygon appear in clockwise or counter-clockwise order when projected onto the screen. If the user has specified that front-facing polygons have a clockwise winding, but the polygon projected on the screen has a counter-clockwise winding then it has been rotated to face away from the camera and will not be drawn. (It may also be performed in world space if the polygon's normal is available.)
The process makes rendering objects quicker and more efficient by reducing the number of polygons for the program to draw. It may be applied early in a rendering pipeline. For example, in a city street scene, there is generally no need to draw the polygons on the sides of the buildings facing away from the camera; they are completely occluded by the sides facing the camera.
In general back-face culling can be assumed to produce no visible artifact in a rendered scene if it contains only closed and opaque geometry. In scenes containing transparent polygons, rear facing polygons may become visible through the process of alpha composition. In wire-frame rendering, back-face culling can be used to partially address problem of hidden line removal, but only for closed convex geometry.
A related technique is clipping, which determines whether polygons are within the camera's field of view at all.
Another similar technique is Z-culling, also known as occlusion culling, which attempts to skip the drawing of polygons which are covered from the viewpoint by other visible polygons.
where P is the view point, V0 is the first vertex of a triangle and N is its normal, defined as a cross product of two vectors representing sides of the triangle adjacent to V0
Since cross product is non-commutative, defining the normal in terms of cross product allows to specify normal direction relative to triangle surface using vertex order(winding):
If points are already in view space, P can be assumed to be (0, 0, 0), the origin.
It is also possible to use this method in projection space by representing above inequality as determinant of a matrix and applying projection matrix to it.
Another method exists based on reflection parity, which is more appropriate for two dimensions where surface normal cannot be computed (also known as CCW check).
Let a unit triangle in two dimensions (homogeneous coordinates) be defined as
Then for some other triangle, also in two dimensions,
define a matrix that transforms the unit triangle into it
Discard the triangle if matrix M contained odd number of reflections (facing the opposite way of unit triangle)
Unit triangle is used as a reference and transformation M is used as a trace to tell if vertex order is different between two triangles. The only way vertex order can change in two dimensions is by reflection. Reflection is an example of involutory function (with respect to vertex order), even number of reflections will leave triangle facing the same side, as if no reflections were applied at all. An odd number of reflections will leave triangle facing the other side, as if exactly after one reflection. Transformations containing an odd number of reflections always have negative scaling factor, likewise scaling factor is positive if there are no reflections or even number of them. Scaling factor of a transformation is computed by determinant of its matrix.
- David H. Eberly (2006). 3D Game Engine Design: A Practical Approach to Real-Time Computer Graphics, p. 69. Morgan Kaufmann Publishers, United States. ISBN 0122290631.
- Geometry Culling in 3D Engines, by Pietari Laurila