To perform view frustum culling, you need the frustum planes in the same coordinate space as your objects' bounding volumes (usually world space). So the goal is to have the frustum planes defined in world space.
There are two common approaches:
✅ Option 1: Extract Frustum Planes Directly in World Space
This is often the most straightforward and efficient method, especially if you already have the view-projection matrix (VP) or can compute it.
Steps:
Get the View-Projection matrix (VP):
cpp
glm::mat4 VP = projectionMatrix * viewMatrix;
Extract the 6 frustum planes from this matrix using standard plane extraction techniques.
Each plane is defined by the equation: Ax + By + Cz + D = 0, where (A,B,C) is the normal and D is the distance from origin.
Plane extraction from a clip-space matrix (like VP) gives you the planes in clip space, so you’ll need to transform them into world space.
⚠️ The extracted planes from the VP matrix are in clip space, not world space. You must transform them to world space.
Transform each plane into world space:
Since clip space planes are derived from the VP matrix, to convert them to world space, you can do:
cpp
// For each plane (A, B, C, D) in clip space:
// WorldSpacePlane = inverse(VP) * Plane; but need to adjust for plane representation
But more accurately, because a plane in clip space is N_clip·X + d_clip = 0, and you want N_world·X + d_world = 0, and X_clip = MVP · X_world, the correct transformation is:
cpp
N_world = transpose(inverse(VP)) · N_clip
d_world = transpose(inverse(VP)) · (d_clip * N_clip) ? No — better formula below.
✅ A reliable way:
Take the plane normal and distance from the clip-space plane.
The inverse transpose of the projection-view matrix transforms normals.
However, the correct and fast way is:
cpp
// Plane in clip space: clipPlane = (A, B, C, D)
// Transform normal to world space:
glm::vec4 worldNormal = glm::inverseTranspose(glm::mat3(VP)) * glm::vec3(clipPlane);
float worldD = clipPlane.w - glm::dot(worldNormal.xyz, VP[3].xyz); // tricky part
But even that isn't always correct.
✅ Better yet, the standard and numerically stable method is:
Extract the plane in clip space from the VP matrix.
Then, the world-space plane can be computed as:
cpp
// For a clip-space plane (A, B, C, D), the world-space plane is:
glm::vec4 worldPlane = glm::inverse(VP) * glm::vec4(A, B, C, D);
worldPlane = glm::normalize(worldPlane); // important!
⚠️ But this is not mathematically accurate either.
✅ Correct and widely used approach (from "3D Math Primer for Graphics", Lengyel):
Clip-space plane extraction gives you the plane in camera homogeneous clip space.
To get world-space planes, you must use camera world position and orientation.
✅ Best practice: Extract planes from view (camera) basis and projection, and construct planes in view space, then transform to world space.
✅ Option 2: Extract Planes in View Space, Then Transform to World Space
This is usually much easier and more intuitive.
Steps:
Use the view matrix (camera transform) and projection matrix to extract the 6 frustum planes in view space.
There are many code examples online for extracting left/right/top/bottom/near/far planes from the projection matrix (or combined VP).
Here's one example for extracting the left plane from a projection matrix: