# Extracting frustum planes from modelview-projection matrix In this post I’m going to explain how to extract the parameters of each frustum plane in the local space of the object with a certain modelview-projection matrix. Knowing the frustum planes may be useful in some cases. The first one that comes to my mind is to perform frustum culling, which I will explain soon in a separated post.

Suppose we have a modelview-projection matrix MP: Here I write down the formulas to extract the six frustum planes defined by a modelview-projection OpenGL matrix. Those planes are expressed in their implicit form Ax + By + Cz + D = 0.   And here is the corresponding code, assuming that the matrix is stored in column-major order.

 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 const float mat; // Modelview-projection matrix Plane l,r,b,t,n,f; // Frustum-planes // Code to fill the modelview-projection matrix // ... // Left Plane // col4 + col1 l.a = mat + mat; l.b = mat + mat; l.c = mat + mat; l.d = mat + mat; // Right Plane // col4 - col1 r.a = mat - mat; r.b = mat - mat; r.c = mat - mat; r.d = mat - mat; // Bottom Plane // col4 + col2 b.a = mat + mat; b.b = mat + mat; b.c = mat + mat; b.d = mat + mat; // Top Plane // col4 - col2 t.a = mat - mat; t.b = mat - mat; t.c = mat - mat; t.d = mat - mat; // Near Plane // col4 + col3 n.a = mat + mat; n.b = mat + mat; n.c = mat + mat; n.d = mat + mat; // Far Plane // col4 - col3 f.a = mat - mat; f.b = mat - mat; f.c = mat - mat; f.d = mat - mat;

Each plane could be normalized after being extracted from mat, although this is not always necessary but just convenient in some cases (e.g. measuring distances).

A more in depth explanation of this can be found in Clip Space Approach – Extracting the Planes (Lighthouse3D)