Frustum CullingWritten by Paul BourkeNovember 2000
Before geometry is sent to a rendering engine it is often desirable
to determine whether or not it is visible and therefore need not
be rendered. While rendering engines such as OpenGL clip the geometry
themselves, it still requires the overhead of the geometry being sent to
the engine.
In order to determine whether part of a primitive is inside the frustum it is necessary to check that every vertex in the primitive is outside the volume. To determine this, compute the vertices of each plane making up the frustum. Each plane can be written in the form, Ax + By + Cz + D = 0. The constants A,B,C,D can be calculated from any three points on the planes (since all four points are coplanar) say (x_{1},y_{1},z_{1}), (x_{2},y_{2},z_{2}), and (x_{3},y_{3},z_{3}) as follows: A = y_{1} (z_{2}  z_{3}) + y_{2} (z_{3}  z_{1}) + y_{3} (z_{1}>  z_{2})B = z_{1} (x_{2}  x_{3}) + z_{2} (x_{3}  x_{1}) + z_{3} (x_{1}  x_{2}) C = x_{1} (y_{2}  y_{3}) + x_{2} (y_{3}  y_{1}) + x_{3} (y_{1}  y_{2})  D = x_{1} (y_{2} z_{3}  y_{3} z_{2}) + x2 (y_{3} z_{1}  y_{1} z_{3}) + x3 (y_{1} z_{2}  y_{2} z_{1})
In order to test whether a point (x,y,z) is on the left or right of the plane compute Ax + By + Cz + D. If the result is greater than zero then the point is on the same side as the normal (A,B,C), if less than zero then it's on the opposite side, if zero then it lies on the plane. Notes
