When we project 3-D objects on a 2-D screen, we need to detect the faces that are hidden on 2D.
Back-Face detection, also known as Plane Equation method, is an object space method in which objects and parts of objects are compared to find out the visible surfaces. Let us consider a triangular surface that whose visibility needs to decided. The idea is to check if the triangle will be facing away from the viewer or not. If it does so, discard it for the current frame and move onto the next one. Each surface has a normal vector. If this normal vector is pointing in the direction of the center of projection, then it is a front face and can be seen by the viewer. If this normal vector is pointing away from the center of projection, then it is a back face and can not be seen by the viewer.
Algorithm for left-handed system :
1) Compute N for every face of object. 2) If (C.(Z component) > 0) then a back face and don't draw else front face and draw
The Back-face detection method is very simple. For the left-handed system, if the Z component of the normal vector is positive, then it is a back face. If the Z component of the vector is negative, then it is a front face.
Algorithm for right-handed system :
1) Compute N for every face of object. 2) If (C.(Z component) < 0) then a back face and don't draw else front face and draw
Thus, for the right-handed system, if the Z component of the normal vector is negative, then it is a back face. If the Z component of the vector is positive, then it is a front face.
Back-face detection can identify all the hidden surfaces in a scene that contain non-overlapping convex polyhedra.
Recalling the polygon surface equation :
Ax + By + Cz + D < 0
While determining whether a surface is back-face or front face, also consider the viewing direction. The normal of the surface is given by :
N = (A, B, C)
A polygon is a back face if Vview.N > 0. But it should be kept in mind that after application of the viewing transformation, viewer is looking down the negative Z-axis. Therefore, a polygon is back face if :
(0, 0, -1).N > 0 or if C < 0
Viewer will also be unable to see surface with C = 0, therefore, identifying a polygon surface as a back face if : C <= 0.
V.N = |V||N|Cos(angle) if 0 <= angle 0 and V.N > 0 Hence, Back-face.
V.N = |V||N|Cos(angle) if 90 < angle <= 180, then cos(angle) < 0 and V.N < 0 Hence, Front-face.
1) This method works fine for convex polyhedra, but not necessarily for concave polyhedra.
2) This method can only be used on solid objects modeled as a polygon mesh.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Collision Detection in CSMA/CD
- Error detection and Recovery in Compiler
- Method within method in java
- Java Math asin() method with Example
- Object toString() Method in Java
- Print all subsequences of a string | Iterative Method
- Maximum distance between two points in coordinate plane using Rotating Caliper's Method
- Z-Buffer or Depth-Buffer method
- A-Buffer Method
- Difference between Method and Function in Python
- Java Math hypot() method with Example
- Java Math exp() method with Example
- Java Math sin() method with Examples
- Java Math sinh() method with Examples
- Java Math cosh() method with Examples
- Java Math tanh() method with Examples
- Java Math cos() method with Examples
- Java Math tan() method with Examples
- ArrayList iterator() method in Java with Examples
- IntStream codePoints() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.