Jump to content
  • Advertisement
Sign in to follow this  

dynamic zBuffers

This topic is 4234 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
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!