Trouble with frustum culling (Video included)

Hello :slight_smile:

I’m working on an OpenGL application and I’m having trouble with my objects being clipped undesirably by frustum culling

The scene consists of a number of objects on an invisible plane. You can pan around by left clicking and dragging on the invisible plane (This does not translate the plane, it translates the camera). You can rotate the invisible plane by right clicking and dragging (This rotates the plane).

The problem comes when you rotate the plane and then pan so that the objects pass through the far plane of the frustum.

I would like my objects to never get clipped, no matter how far back you push them.

I’m currently using a constant frustum defined by

frustum.left = -1.0;
frustum.right = 1.0; = 1.0;
frustum.bottom = -1.0;
frustum.near = 5.0;
frustum.far = 500.0;

but I was thinking perhaps I could update the projection matrix and frustum every frame, ensuring that the near plane touches the front of the bounding box of my objects and the far plane touches the back of the bounding box of my objects.

Does anyone have any advice which could help me get rid of this unwanted clipping?

Please see accompanying video which visually describes the problem here (View using Flash):


You could do that.

Or, if you’re only real problem is far clipping, you could push your far clip back enough that you’ll in practice never hit that distance. Just make sure you push your near clip out as far as you can. In fact, there’s a form of the projection matrix for an “infinite distance far clip” that in practice eliminates far Z clipping, though you sacrifice some depth precision for that.

If you end up needing to render a Z range that is just too large for standard depth buffers, you can use higher precision depth buffers and/or render the Z range in depth slices (depth partitioning).

Thanks Dark Photon.

I have tried fitting the frustum’s near and far planes (adjusting left, right, top and bottom too) and this seems to be giving me what I want.

The result is:

I have had some bad Z-Fighting in my real application (The video only shows a test app) and minimising the distance between the near and far planes seems to help a lot with that.