Sign in to follow this  

AABB frustum culling

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a better way of doing a AABB frustum culling rather than looping though each frustum plane, and then looping per bounding vertex? It seems there should be a better way than running through a loop 48 times per box per frame ( not to mention using D3DXPlaneDotCoord() - that can't be that fast of a function ) Is there a better way?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yes, there is a better way.

To know if a box is intersecting or completely behind a plane, you only need to look at one vertex. That vertex is the one with the minimum signed distance to the plane (or maximum depending on which direction your planes are facing). For a given plane, the vertex to look at is the same for all AABBs (for example, it might be the vertex in the positive x and y and negative z directions, relative to the box's center, or whatever).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
No, it's not turning it into a sphere.

For purposes of this discussion let's say the frustum planes are oriented so the positive side is outside the frustum. For a single point, you can calculate the signed distance to a plane. If the distance between a point and a frustum plane is positive, it is outside the frustum. If for all planes the distance is negative, the point is inside the frustum.

For any shape, to know that the shape is entirely outside the frustum plane we only need to check the point on the shape that has the minimum signed distance from the plane. Since all the other points of the shape are an equal or greater distance from the plane, if the signed distance of the minimum distance point is positive, all the other points are also positive, and the shape is outside the frustum.

The only point that needs to be tested is the extreme point in the opposite direction as the plane's normal. For axis aligned bounding boxes, this will be a particular corner determined by the signs of the components of the plane's normal. If the AABB has center (Cx,Cy,Cz) and extents of (Ex, Ey, Ez), and the plane's normal is (.58, -.58, .58), the vertex with the minimal signed distance to the plane is (Cx - Ex, Cy + Ey, Cx - Ez). This is the only vertex that needs to be checked to know if the box is entirely outside the frustum.

You can try googling terms like "bounding box" and "frustum" to find articles about this stuff.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this