Sign in to follow this  

dynamic zBuffers

This topic is 4051 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 it normal to dynamically alter znear and far to the scene closest and furthest vertex (basically world-fixed frustrum)? The scene is small in all dimensions and I have coplanar poly tearing. The user is allowed to set objects on top of each other. When the camera is very near these coplanar polys there is no zfighting but significant tearing when camera is further away from the scene. My zBuffer is 64 bit (52 bit mantissa) and z values are 1 at near and 0 at infinity regardless of my camera.znear and zfar. Am I barking up the wrong tree? When I render the scene as zbuffer (white to black) the scene always renders as white in front of the camera and black at infinity, is this normal? Won't moving znear further away from camera and bringing zfar closer to the back of the scene compress z and prevent zfight? Any advice on what has worked for you and details would be very much appreciated.

Share this post


Link to post
Share on other sites
First, the Z-buffer is always 0 -> 1 from your far to near clip planes, so adjusting the clip planes
never changes the Z values, but it does change the meaning of those values.
Second, the Z-buffer is not linear. There is more acuracy at the near plane and less so at the far.

So, one thing you can try doing is a multiple render (like what space games do).
This means that you render everything in batches of "closeness" to the camera. Say by deviding the space
into near, med, and far distances. Each time you render a new batch you clear the depth buffer and
adjust the near and far clip planes to cover only the distance segment you are rendering.
This allows you to have better acuracy at places far from the camera.

So yes, moving the znear and zfar closer to each other should prevent the z fighting of any objects rendered in
that space. And yes it is common to have some method of rendering with different clip planes,
but im not sure of the advantage of picking the nearest and fartest scene elements each frame.
something makes me think this could cause hard to find problems later on.

Share this post


Link to post
Share on other sites

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