Frustum Culling

Started by
28 comments, last by Ruudje 20 years, 7 months ago
Yes, it''s a lot easier with bounding spheres But I think the same trouble can occur at the beginnig of the frustum when it is thin.
Have you noticed it occurs at specific locations ? Being near the camera for example ?
And are you sur of your bounding spheres ? Try to draw them, and check if it is radius instead of -radius
Advertisement
ZMaster: I have exactly the same problem. The weird thing is that it's view dependent. If the camera an the object is positioned along the z-axis then there's no problem. If both the camera an the object is positioned along the x-axis then there's to cases.

1: If the camera looks along the x-axis then the objects disappear on the left side of the frustum.

2: If the camera looks along the negative x-axis then the objects disappear on the right side of the frustum. I use spheres as bounding volumes.

[edited by - __fold on September 5, 2003 7:02:07 PM]
Has anyone ever used Rectangle shapes and bounding boxes to check the frustum ?
I have modified the CubeinFrustum to do this, but it''s not working very well..
This is kindof in the other direction than the last posts, but: what would be faster, Frustum Culling, suing an octree, or putting the entire worldmesh into a display list. Or what if I manually divide the mesh up in say 4 parts (or 16 or whatever) using a 3D editor, and place em in display lists, and come up with a formula to check whether or not they are in the camera''s view?

By the way... how on earth am I supposed to do that (the checking if the camera sees it)? (I''m still a opengl newbie, and need all my time figuring out how to do the online part for now...)
Bruno: A simple rectangle/frustum check is this.

For all planes in the frustum.
{
  For all vertices i (Xi,Yi,Zi) in the rectangle
  {
    Calculate the distance by inserting the vertex in the plane
    (distance = A*Xi + B*Yi + C*Zi + D).
  }   
if all distances are positive
return outside
}
return inside.



[edited by - __fold on September 6, 2003 4:05:00 AM]
quote:Original post by MV
quote:Original post by ZMaster
BTW: Is anyone familiar with the problem, that objects that lie within the view are culled though they shouldn be? If I fake the position of the object (for example give a y - 10 value to my CheckCubeInFrustum() function) it''s not culled anymore.


Using bouding boxes, sometimes the corners of your box are outside the frustum (each side of the frustum for example)so it''s culled but it shouldn''t.

 \    /+-\--/---+|  \/    ||        ||        ||        |+--------+

The tutorial mentions this problem but dont solve it. I solved it, but I use my own function for culling.


If all the points are behind one plane of the frustum, then it can be culled. It''s conservative though, so sometimes things aren''t culled when they can be, but it works adequately.

You have to remember that you''re unique, just like everybody else.
If at first you don't succeed, redefine success.
__fold, i believe that''s what i''m doing.
I test all points, accordingly to the size of the volume i''me feeding to the bounding box.., what''s wrong here ?


bool Camera::VolumeInFrustum( float x, float y, float z, float sizex, float sizey, float sizez )
{
for(int p = 0; p < 6; p++ )
{
if( frustum[p][0] * (x - sizex) + frustum[p][1] * (y - sizey) + frustum[p][2] * (z - sizez) + frustum[p][3] > 0 )
continue;
if( frustum[p][0] * (x + sizex) + frustum[p][1] * (y - sizey) + frustum[p][2] * (z - sizez) + frustum[p][3] > 0 )
continue;
if( frustum[p][0] * (x - sizex) + frustum[p][1] * (y + sizey) + frustum[p][2] * (z - sizez) + frustum[p][3] > 0 )
continue;
if( frustum[p][0] * (x + sizex) + frustum[p][1] * (y + sizey) + frustum[p][2] * (z - sizez) + frustum[p][3] > 0 )
continue;
if( frustum[p][0] * (x - sizex) + frustum[p][1] * (y - sizey) + frustum[p][2] * (z + sizez) + frustum[p][3] > 0 )
continue;
if( frustum[p][0] * (x + sizex) + frustum[p][1] * (y - sizey) + frustum[p][2] * (z + sizez) + frustum[p][3] > 0 )
continue;
if( frustum[p][0] * (x - sizex) + frustum[p][1] * (y + sizey) + frustum[p][2] * (z + sizez) + frustum[p][3] > 0 )
continue;
if( frustum[p][0] * (x + sizex) + frustum[p][1] * (y + sizey) + frustum[p][2] * (z + sizez) + frustum[p][3] > 0 )
continue;
return false;
}
return true;
}
There is an excellent article about quadtrees here at gamedev:
Quadtrees

it''s really worth looking at.
For object culling, you could use occlusion query. It's a method where you draw a bounding box to your object and ask the graphics card if the object is visible. In OpenGL you could use NV_occlusion_query or ARB_occlusion_query for example.

[edited by - ALiENiD on September 8, 2003 5:53:11 AM]
quote:Original post by ALiENiD
For object culling, you could use occlusion query. It''s a method where you draw a bounding box to your object and ask the graphics card if the object is visible. In OpenGL you could use NV_occlusion_query or ARB_occlusion_query for example.

[edited by - ALiENiD on September 8, 2003 5:53:11 AM]


More details please !

This topic is closed to new replies.

Advertisement