# Creating Camera Bounding Frustum From View and Projection Matrix

This topic is 1559 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How do I create Bounding Frustum from the view and projection matrix?

##### Share on other sites

You just need to multiply the ViewMatrix*Projection Matrix. Then you need to extra the 6 planes that makes up the frustum.

//This is Column Major matrix.

//If you have row based then you would flip the multiplication order.

Matrix4x4 ViewProjection = ProjectionMatrix*ViewMatrix;

Plane& right = GetPlaneRight();
right.normal.x=ViewProjection.m14-ViewProjection.m11;
right.normal.y=ViewProjection.m24-ViewProjection.m21;
right.normal.z=ViewProjection.m34-ViewProjection.m31;
right.distance=ViewProjection.m44-ViewProjection.m41;
right.Normalized();

Plane& left = GetPlaneLeft();
left.normal.x=ViewProjection.m14+ViewProjection.m11;
left.normal.y=ViewProjection.m24+ViewProjection.m21;
left.normal.z=ViewProjection.m34+ViewProjection.m31;
left.distance=ViewProjection.m44+ViewProjection.m41;
left.Normalized();

Plane& top = GetPlaneTop();
top.normal.x=ViewProjection.m14-ViewProjection.m12;
top.normal.y=ViewProjection.m24-ViewProjection.m22;
top.normal.z=ViewProjection.m34-ViewProjection.m32;
top.distance=ViewProjection.m44-ViewProjection.m42;
top.Normalized();

Plane& bottom = GetPlaneBottom();
bottom.normal.x=ViewProjection.m14+ViewProjection.m12;
bottom.normal.y=ViewProjection.m24+ViewProjection.m22;
bottom.normal.z=ViewProjection.m34+ViewProjection.m32;
bottom.distance=ViewProjection.m44+ViewProjection.m42;
bottom.Normalized();

Plane& front = GetPlaneFront();
front.normal.x=ViewProjection.m14-ViewProjection.m13;
front.normal.y=ViewProjection.m24-ViewProjection.m23;
front.normal.z=ViewProjection.m34-ViewProjection.m33;
front.distance=ViewProjection.m44-ViewProjection.m43;
front.Normalized();

Plane& back = GetPlaneBack();
back.normal.x=ViewProjection.m14+ViewProjection.m13;
back.normal.y=ViewProjection.m24+ViewProjection.m23;
back.normal.z=ViewProjection.m34+ViewProjection.m33;
back.distance=ViewProjection.m44+ViewProjection.m43;
back.Normalized();

Edited by BornToCode

##### Share on other sites

@BornToCode: Thanks!

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
17
5. 5

• 9
• 12
• 9
• 33
• 13
• ### Forum Statistics

• Total Topics
632591
• Total Posts
3007250

×