OpenGL VRML W3D            
  Home Tutorials Books Applications Tools Docs Models Textures  

 

              Bugs

View Frustum Culling Tutorial   

  View Frustum Culling Tutorial

Index
Introduction
View Frustum's Shape

Geometric Approach
Extracting the Planes
Implementation
Testing Points and Spheres
Testing Boxes
Testing Boxes II
Source Code

Clip Space Approach
Extracting the Planes
Implementation

Radar Approach
Testing Points I
Testing Points II
Implementation
Testing Spheres
Implementation II
Source Code

Notes and Refs
Notes and Optimization
Further Optimization
References


Google

OpenGLTutorials @ Lighthouse3d.com

Led Shader
View Frustum Culling
GLSL Tutorial
Maths Tutorial
Billboarding Tutorial
Picking Tutorial
Terrain Tutorial
Display Lists Tutorial
GLUT Tutorial

   
[Previous: Source Code] [Next: Implementation]

View Frustum Culling Tutorial


Clip Space Approach - Extracting the Planes


In here another approach to extract the view frustum planes is presented based on the properties of clip space.

Consider a point p =(x,y,z,1) on the 3D world. Consider also a modelview matrix M and a projection matrix P. The point p is transformed by matrices M and P as point pc =(xc,yc,zc,wc) in clip space using:

The point pc is in homogeneous coordinates, and when normalised becomes pcn:

In normalised clip space the view frustum is an axis aligned box centered in the origin, and bounded by the following planes:

  • Left Plane: x' = -1
  • Right Plane: x' = 1
  • Top Plane: y' = 1
  • Bottom Plane: y' = -1
  • Near Plane: z' = -1
  • Far Plane: z' = 1
  • This implies that the point pcn =(x',y',z') is inside the view frustum if:

    Then the point pc, in non-normalized coordinates, must obbey the following conditions in order to be inside the view frustum:

    Based on this information it is possible to extract the six planes, in world coordinates, that bound the view frustum. The point pc is on the "right" side of the left plane if

    Consider p and A=MP as described below

    Then xc and wc can be defined as a function of p = (x,y,z,w), and A.

    Therefore the following inequation must be true if p is on the right side of the left plane.

    A little algebraic manipulation gives

    So the left plane (Ax+By+Cz+D=0) is defined as:

    where col1 and col4 are the first and forth columns of matrix A, respectively.

    If the only objective is to find out if a point is inside or outside of the frustum then the plane as defined is ok. However when testing spheres, which require computing the distance from the center of the sphere to the plane, it is advisable to normalize the plane.

    The right plane can be obtained in a similar manner:

    The following coefficients are obtained for the right plane:

    The remaining planes are obtained as follows:

  • Bottom Plane
  • Top Plane
  • Near Plane
  • Far Plane
  •  

    [Previous: Source Code] [Next: Implementation]

           


    Site designed and maintained by António Ramires Fernandes
    Your comments, suggestions and references to further material are welcome!

    Lighthouse 3D privacy statement