Skip to main content
GameDev.net gamedev.net
🔒 Locked

Depth Test Problem

Started by Doolwind Mar 21, 2003 at 11:06 PM 1 replies 300+ views
Original Post
Doolwind
Doolwind
Hi, I am having trouble with my Direct3D (DX8) game I am putting together. The problem is when I have two polygons quite far away from the viewer that are close together the order they are being drawn is sometimes incorrect. Basically I making an RTS and when I zoom up quite high my tanks are appearing as though they are under (or partially under) the ground, even though they should be completely above it (as when I zoom in close it is obvious they are completely above the ground). So the depth test of each pixel must be getting confused when the two depth values are very far from the camera but the difference is very small. I thought I had heard that there are some problems with depth ordering when the depths are very high but close together and I was wondering if there is something generic I can do to fix my problem. I have tried setting my ZFunc to D3DCMP_LESS as well as the default LESSOREQUAL but it still doesn''t work. I have also tried rendering my objects in the opposite order but that didn''t work either. Any ideas on this problem would be greatly appreciated. Doolwind
cheez_keeper
cheez_keeper
set your perspective matrix to a farther Z depth. the docs actually comment on this, and if i remember the stats correctly it is something like 60% of the z-buffer distance computations are done in the first 10% of the range. it''s not a linear function anyway, you need to make sure most of the points you care about being calculated right are within the first 30-50% of your depth and you should be good (i keep all non-background points within 40%).

Brett Lynnes
cheez_keeper@hotmail.com
Brett Lynnescheez_keeper@hotmail.com
Doolwind
Doolwind
cheez_keeper-

Thanks, that was my problem. I knew I had heard something about needing to space out my z depths more. I just didn''t go to the extreme I had to to get my z''s into the first 40% (my back clipping plane is now at 50,000,000).

Thanks for your help.

Doolwind

Topic Locked

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

Sign in to reply to this topic.