HOME

TheInfoList



OR:

In
computer graphics Computer graphics deals with generating images with the aid of computers. Today, computer graphics is a core technology in digital photography, film, video games, cell phone and computer displays, and many specialized applications. A great de ...
, back-face culling determines whether a
polygon In geometry, a polygon () is a plane figure that is described by a finite number of straight line segments connected to form a closed '' polygonal chain'' (or ''polygonal circuit''). The bounded plane region, the bounding circuit, or the two ...
of a graphical object is drawn. It is a step in the graphical pipeline 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 A camera is an optical instrument that can capture an image. Most cameras can capture 2D images, with some more advanced models being able to capture 3D images. At a basic level, most cameras consist of sealed boxes (the camera body), with ...
and will not be drawn. The process makes rendering objects quicker and more efficient by reducing the number of polygons for the program to draw. 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 Closed may refer to: Mathematics * Closure (mathematics), a set, along with operations, for which applying those operations on members always results in a member of the set * Closed set, a set which contains all its limit points * Closed interval, ...
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 the problem of
hidden line removal In 3D computer graphics, solid objects are usually modeled by polyhedra. A face of a polyhedron is a planar polygon bounded by straight line segments, called edges. Curved surfaces are usually approximated by a polygon mesh. Computer programs ...
, but only for closed
convex Convex or convexity may refer to: Science and technology * Convex lens, in optics Mathematics * Convex set, containing the whole line segment that joins points ** Convex polygon, a polygon which encloses a convex set of points ** Convex polytop ...
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 that are covered from the viewpoint by other visible polygons. In non-realistic renders certain faces can be culled by whether or not they are visible, rather than facing away from the camera. "inverted hull" or "front face culling" can be used to simulate
outlines Outline or outlining may refer to: * Outline (list), a document summary, in hierarchical list format * Code folding, a method of hiding or collapsing code or text to see content in outline form * Outline drawing, a sketch depicting the outer edg ...
or
toon shaders Cel shading or toon shading is a type of non-photorealistic rendering designed to make 3-D computer graphics appear to be flat by using less shading color instead of a shade gradient or tints and shades. A cel shader is often used to mimic ...
without post-processing effects.


Implementation

One method of implementing back-face culling is by discarding all triangles where the
dot product In mathematics, the dot product or scalar productThe term ''scalar product'' means literally "product with a scalar as a result". It is also used sometimes for other symmetric bilinear forms, for example in a pseudo-Euclidean space. is an alg ...
of their
surface normal In geometry, a normal is an object such as a line, ray, or vector that is perpendicular to a given object. For example, the normal line to a plane curve at a given point is the (infinite) line perpendicular to the tangent line to the curve ...
and the camera-to-triangle vector is greater than or equal to zero : \left( V_ - P\right) \cdot N \ge 0 where is the view point, is the first vertex of a triangle and is its normal, defined as a cross product of two vectors representing sides of the triangle adjacent to : N = \left( V_ - V_\right) \times \left( V_ - V_\right) 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): :\left( V_ - V_\right) \times \left( V_ - V_\right) = - \left( V_ - V_\right) \times \left( V_ - V_\right) If points are already in view space, can be assumed to be , the origin. : -V_ \cdot N \ge 0 It is also possible to use this method in projection space by representing the above inequality as a
determinant In mathematics, the determinant is a scalar value that is a function of the entries of a square matrix. It characterizes some properties of the matrix and the linear map represented by the matrix. In particular, the determinant is nonzero if a ...
of a matrix and applying the projection matrix to it.David H. Eberly (2006). ''3D Game Engine Design: A Practical Approach to Real-Time Computer Graphics'', p. 69. Morgan Kaufmann Publishers, United States. . Another method exists based on reflection parity, which is more appropriate for two dimensions where the surface normal cannot be computed (also known as CCW check). Let a unit triangle in two dimensions (
homogeneous coordinates In mathematics, homogeneous coordinates or projective coordinates, introduced by August Ferdinand Möbius in his 1827 work , are a system of coordinates used in projective geometry, just as Cartesian coordinates are used in Euclidean geometr ...
) be defined as :U_ = \begin 0 \\ 0 \\ 1 \end, U_ = \begin 1 \\ 0 \\ 1 \end, U_ = \begin 0 \\ 1 \\ 1 \end Then for some other triangle, also in two dimensions, :V_ = \begin x_ \\ y_ \\ 1 \end, V_ = \begin x_ \\ y_ \\ 1 \end, V_ = \begin x_ \\ y_ \\ 1 \end define a matrix that transforms the unit triangle: :M = \begin x_-x_ & x_-x_ & x_ \\ y_-y_ & y_-y_ & y_ \\ 0 & 0 & 1 \end so that: :MU_=V_ :MU_=V_ :MU_=V_ Discard the triangle if matrix contained an odd number of reflections (facing the opposite way of the unit triangle) :\left, M \ < 0 The unit triangle is used as a reference and transformation 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), therefore an even number of reflections will leave the triangle facing the same side, as if no reflections were applied at all. An odd number of reflections will leave the triangle facing the other side, as if exactly after one reflection. Transformations containing an odd number of reflections always have a negative scaling factor, likewise, the scaling factor is positive if there are no reflections or even a number of them. The scaling factor of a transformation is computed by
determinant In mathematics, the determinant is a scalar value that is a function of the entries of a square matrix. It characterizes some properties of the matrix and the linear map represented by the matrix. In particular, the determinant is nonzero if a ...
of its matrix.


References

{{Computer graphics 3D rendering Computer graphics algorithms