Advertisement

Really inaccurate Depth Test ?!?

Started by February 01, 2004 05:26 PM
3 comments, last by Tree Penguin 21 years, 1 month ago
Hi, i am using a 32 bit z buffer and a far plane at distance 500.0 and i am getting really inaccurate depth testing (which, i think is not normal with these settings). Can someone tell me what to do about it? Here are some screenshots (far and closer), they are made with a 16 bit z buffer but the difference isn't that large. The size of the house is 4.0x4.0x5.0 A previous program of mine looked like this (same settings): In other words, perfect. EDIT: make images work [edited by - Tree Penguin on February 1, 2004 6:30:06 PM]
Never mind i got it, it was simply using the wrong depth testing function as i haven''t told it to use GL_LEQUAL, it works fine now .
Advertisement
I now found out that lines are depth tested not with their depth but with their depth plus their width (which isn''t affected by the perspective) so when you''re at a great distance (like 100.0) the line come through the objects. Is there any way i can prevent this?

Thanks.
You can use glPolygonOffset to nudge your data by 1 Z level.
Usually, this is so the lines WILL appear over the solids, but you could use negative numbers to reverse this.
Alterantively, you could draw your lines first (No Z Buffer write) and then carry on as normal.
Lastly, the Z buffer problems are more to do with the NEAR z value, rather than the FAR (actually, more like the ratio of these). Try setting Z near to 10, rather than 0.01, or whatever you''ve chosen - should be no problem unless you are looking for first-person style view.
Thanks, setting the near plane to a higher value solved it (i set it from 0.01 to 0.1).

This topic is closed to new replies.

Advertisement