AABB frustum culling
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?
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).
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).
Can you explain it a little bit better? It sounds like you are turning the bounding box into a bounding sphere and testing that ( I already am doing that )
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.
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.
http://www.ce.chalmers.se/~uffe/vfc_bbox.pdf
consider this the bible for frustum/AABB intersection tests..
consider this the bible for frustum/AABB intersection tests..
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement