Skip to main content
gamedev.net
🔒 Locked

Depth buffer problem

Started by Vincent_22 Mar 20, 2005 at 4:57 AM 2 replies 850+ views
Original Post
Vincent_22
Vincent_22
Hello guys, I have a problem with my depth buffer in D3D9. We have a little engine where we can load quake 3 maps. In OpenGL it looks fine, but in D3D9 there are depth buffer errors. I try to describe: While moving around you can see that geometry behind a wall comes in front and goes back again, its like fluckering. All over the walls you have an effect looks like shadow polys and they are moving. So I set the near clipping plane from 0.1f to 2.0f and its much more better now. But if you are far away from an object you still the effect of swapping in front and behind, if you come closer this effect is going away. I hope you can help me. regards Vince
Trip99
Trip99
Sounds like z fighting - when you have two polys that cause very similar z values and due to inaccuracies in floating calculations the results vary minutely making one in front of the other and then behind etc. The problem is of course not enough z buffer resolution hence the improvement when you changed the clipping planes. You can use a depth bias value to help solve this or even use two projection matrices.
------------------------See my games programming site at: www.toymaker.info
Vincent_22
Vincent_22
Hi,

ok I changed the clipping planes and its better now but not away. What do you mean with use two projection matrices and how to work with zBias?

Thanks
Vince
Aldenar
Aldenar
For example, say you are rendering the normal geometry first and the shadows afterward. Then what you can do is set the projection matrix as before for the normal geometry, then when change the near and|or far plane distance for the shadows. If you use near = 2.0f and far = 256.0f, then for the shadows you could try something like near = 2.0f and far = 255.995f. That way, it changes the zbuffer range and will bring the triangles a bit closer. Be aware that this technique can cause some problems such as a mesh that should be behind other meshes ending up in front of them.

As of ZBias, take a look at the D3DRS_DEPTHBIAS render state. Note that it is not supported on all hardware, but most of the recent graphic cards supports it.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.