Jump to content
  • Advertisement
Sign in to follow this  

Frustum culling

This topic is 4759 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

Hi! I want to optimize the render method of my 3d engine. Now I don't know how to realize frustum culling. The only thing I want to do is to check if a box and a frustum intersect. I have the coordinates of the 8 vertices of the box and the 6 plane equations of the frustum. I also have a method which checks if a point is within the frustum. My first idea was to check if at least one of the 8 vertices is in the frustum. But this does not work very well, because the box can also intersect with the frustum even if all vertices are outside the frustum (this is especially the case if not the box is in the frustum, but the frustum is in the box). I found a few tutorials in the internet, but they always assume that the box is a cube. But my algorithm shall also work with cuboids, because I can not be sure that the width, the height and the depth of the box are equal. Does anybody have an idea? Thanks in advance. rgds [Edited by - ChristophR on October 10, 2005 2:53:12 AM]

Share this post

Link to post
Share on other sites
As you note, the per-corner test doesn't work very well, and for that reason it's usually not used in practice.

As for the tutorials you read, are you sure they were restricted to cubes? That seems unlikely, as that's an uncommon constraint to put on bounding volumes.

You didn't mention if your box is oriented or axis-aligned, but the same method can be employed for either; only the details differ. The idea is to perform a limited separating axis test. By limited I mean that only a few of the possible separating axes between the box and frustum are tested, specifically, the normals to the frustum planes. This results in some false positives, which is generally acceptable for frustum culling.

A perhaps more intuitive way to put it is that if the box is entirely on the 'back' side of any frustum plane, it cannot possibly intersect the frustum and you can cull it. You'll note that with your example of the box containing the frustum, the per-corner test fails but the separating axis test returns the correct result. Checking a box against a plane reduces to seeing if the distance from the box center to the plane is greater than the projected radius of the box onto the plane normal. Another common equivalent formulation is to find the corners of the box that project minimally and maximally onto the plane normal and test those.

You might take another look at those tutorials. I could be wrong, but I'm guessing they might discuss the above methods in some form or another, without restriction to perfect cubes.

Share this post

Link to post
Share on other sites
Thank you.

The tutorials describe methods which have the arguments: centerX, centerY, centerZ and size. Therefore they only work with cubes, because otherwise they would need 3 different size arguments.

PS: I only work with axis-aligned boxes.


Share this post

Link to post
Share on other sites
The tutorials describe methods which have the arguments: centerX, centerY, centerZ and size.
Really? That seems odd. Anyway, no guarantees of correctness (too late at night for that), but I'll try to give the basics. A convenient representation for the AABB is as center and extents. If you have it in min/max form, the conversion is:
center = (max+min)/2;
extents = (max-min)/2;
If you've already got a point-frustum test, then presumably you've got a point-plane distance function. The first step is then to find the (signed) distance from the box center to the plane. Then you need the projected box radius, which is:
radius = dot(box.extents, plane.normal.GetAbsolute());
Where GetAbsolute() returns a vector whose components are the absolute values of the original vector. So you end up with something like this:
float distance = DistancePointPlane(box.center, plane);
float radius = dot(box.extents, plane.normal.GetAbsolute());

if (distance < -radius)
return BACK;
if (distance > radius)
return FRONT;
return ON;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!