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

Depth test problems in large environments

Started by slikrik Jul 9, 2004 at 7:58 AM 1 replies 300+ views
Original Post
slikrik
slikrik
Hello, I'm developing an application that models flight dynamics around the Earth, and because of this, I have a rather large environment (I define my near clipping plane to be 0.1 and my far to be 35,000,000). I use gluLookAt to follow the plane(s) around, however there are often cases where the depth test seems to be malfunctioning; if I place a sphere in place of the Earth and place a texture map on the sphere, often times (usually depending on the location of the camera) I see the opposite side of the texture map. If I *don't* use a texture map, and instead use a LINE polygon mode when rendering the sphere, sometimes the lines appear on the *outside* of the plane, even though the plane is "above" the earth. None of these problems occur, however, when the objects are smaller-- and it may have nothing to do with the size of the environment at all, but rather the size of the sphere that I'm using. Does anyone have any clue why a sphere (of radius > 6,000,000) would have these depth-test issues? Or is it maybe not a depth test issue at all? Thanks in advance! Rick
okonomiyaki
okonomiyaki
Not exactly sure what you are describing, but since you are talking about depth testing in large environments, it could be a low precision depth buffer. Make sure the depth buffer is 24-bit. Also put your near plane as forward as possible, as it can increase the precision quite a bit.
_DarkWIng_
_DarkWIng_
Yeah, that's z-buffer fighting. Do you absolutly need that huge range? If not then push near plane forward as much as you can. You have to remember that z-buffer is not liner and it percision si defined something like far_distance/near_distance. So increasing near form 0.1 to 1.0 will increase resolution sbout 10 times. The other trick you could use is to draw your world in different passes. First set distance range something like [0.1, 200] and render everything in that range. Then set it to [100, 15000] and so on...
You should never let your fears become the boundaries of your dreams.

Topic Locked

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

Sign in to reply to this topic.