# 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[16]; // 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[3] + mat[0]; l.b = mat[7] + mat[4]; l.c = mat[11] + mat[8]; l.d = mat[15] + mat[12]; // Right Plane // col4 - col1 r.a = mat[3] - mat[0]; r.b = mat[7] - mat[4]; r.c = mat[11] - mat[8]; r.d = mat[15] - mat[12]; // Bottom Plane // col4 + col2 b.a = mat[3] + mat[1]; b.b = mat[7] + mat[5]; b.c = mat[11] + mat[9]; b.d = mat[15] + mat[13]; // Top Plane // col4 - col2 t.a = mat[3] - mat[1]; t.b = mat[7] - mat[5]; t.c = mat[11] - mat[9]; t.d = mat[15] - mat[13]; // Near Plane // col4 + col3 n.a = mat[3] + mat[2]; n.b = mat[7] + mat[6]; n.c = mat[11] + mat[10]; n.d = mat[15] + mat[14]; // Far Plane // col4 - col3 f.a = mat[3] - mat[2]; f.b = mat[7] - mat[6]; f.c = mat[11] - mat[10]; f.d = mat[15] - mat[14];

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)