Depth buffering problem

Started by
2 comments, last by Marmin 19 years, 2 months ago
Hi, In my direct3d scene I've enabled depth buffering. So I'd like the objects farther away not rendered. The problem is, that the objects that are far away from the camera, are still rendered. In the surrounding landscape I also see the triangles that are far away 'shining through'. (I does not seem logical to me. I have enabled Fog, and Lighting) Question: Is enabling the z buffer the only thing I need to do, or do I need to make hardware card-specific settings? Thanks for the time.
Advertisement
there are other things you have to take into consideration:

-do you use a 16bit or 24, 32 bit z-buffer?
-are you using w-buffering?
-do you have backface culling enabled?
-how is your near-far clipping plane ratio?

z-fighting is a problem of dloating point inaccuracy.

use the highest bit count for the z-buffer if possible.
try using w-buffering.
enable backface culling.
adjust your near/far clip planes according to your environmental resolution.

In my engine i defined 1.0f to be 1 meter.
So my near clipping plane is at 0.01f (1 centimeter) and my far-clipping plane is at 1000.0f (1 kilometer)
- z fighting is what happens when two pixels with different z values map to the same z buffer value - a 24-bit z buffer only has 2^24 unique z buffer values - and they're not linear. The lower your near clip plane is, then the more of those values are assigned to z values near the camera and the more you risk z fighting in the distance.

- make the near clip plane as high as you can based on your world. The higher this is, the more linearly your z buffer will behave. Never set near to 0. The near clip plane is the most important of the two planes to set right.

- make the far clip plane a sensible number with regard to your world units and near clip plane value. So for example if 1 unit in your world is equal to 1 metre, a far clip plane of 1,000,000 will be spreading the range of values in your z buffer out too much.

- if you've got ZBIAS or DEPTHBIAS states set, then double check the values you're using for them - set them incorrectly and you'll get lots of z fighting.

- beware of bad artwork/modelling - two polygons modelled too closely to each other sat one on top of the other will z fight, particularly at distance.

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

---> make the near clip plane as high as you can based on your world. The higher this is, the more linearly your z buffer will behave. Never set near to 0. The near clip plane is the most important of the two planes to set right.


Oh my god.
I want to thank you for your quick reply-
You helped me out. Because I have set the near clip plane at... right, 0.0. This was done in the very early stages of development and other things were more important to me , and I forget that setting. An important lesson for me.

Thanks guys for helping me out, you're in great debt to me!
Everything is suddenly working and looks neat!

Thanks again,-

Marcel.

This topic is closed to new replies.

Advertisement