Skip to main content
gamedev.net
🔒 Locked

Z-Depth Buffer Problem

Started by OpenGL_Guru Feb 2, 2004 at 9:01 AM 10 replies 550+ views
Original Post
OpenGL_Guru
OpenGL_Guru
i am drawing a 3-D heightmap that is getting some Z-depth buffer problems when Z is too high a number. i didnt know there was a limit??? basically i am drawing my data according to lat/lon values , but in any case Z ends up being about 9 million in the positive Z axis. i have tested Z to be at even 500,000 or so, and i still get some Z-depth "errors". The error i am talking about is when rotating at these high values some of the data is not drawn, its like someone took scissors and just cut pieces out. i dunno if anyone has had these type of problems before but any know how on how to fix this would be helpful. my Z perspective is set to 200,000. i can divide all my numbers in half or by a certain number to shorten the value i just didnt know openGL would have a problem with the Z value being too high or low. any input would be appreciated! thanks!
heh
Trienco
Trienco
i wouldnt know of problems with numbers being too high. you WILL have trouble with extreme far planes (especially when using absurd near planes like 0.001). if its just far away parts being cutoff then your far plane is too close, if you get z fighting the ratio between near and far should be on you to-do list.

usually id consider a far plane of 200k as pretty perverse and suggest using a different scale. though if its causing problems will also depend on what youre doing with it.

if youre working with floats i hope you realize that theres a limit too?
f@dzhttp://festini.device-zero.de
OpenGL_Guru
OpenGL_Guru
actually my values for my data is double not float. i dunno if this makes a difference with z-fighting? i have tested like i said and when the numbers are low the "bug" is non-existent or not noticeable. at the beginning of the program i translate according the whatever the center of my heightmap will be which i figure out when i store the data. my center is something like
-163656 9.78123e+006, the x and z respectively, notice z is like 9 million. the weird thing is is that i dont seem to get a z-depth buffer problem unless i rotate the heightmap that is drawn.

how do i attach a screenshot to a post? i can take one and post it here so you can see what i mean if i have confused anyone or you need to see it. thanks!
heh
benjamin bunny
benjamin bunny
If you have a large disparity between your near and far clip planes, you will get problems. If you absolutely need to have your far clip plane set that far, you need to set the near clip plane accordingly. Try 100 or so. The FAQ gives a more detailed answer to this question BTW.
OpenGL_Guru
OpenGL_Guru
well i got the problem fixed..instead of translating my whole grid in 3-d real world coordinates i set them to stay at 0,0 and then after i drew the heightmap, update my information based upon the offset..this way my x y z cooridinates stay low. with a double precision number of 9 million+ im sure the GPU truncates to make room for a 32-bit floating point number so i was losing precision. this is all that i can think of.
heh
teamonkey
teamonkey
I had this problem a while ago and someone pointed me to this: http://www.gamasutra.com/features/20020712/oneil_01.htm
[teamonkey] [blog] [tinyminions]
OpenGL_Guru
OpenGL_Guru
wow what a perfect link teamonkey! thanks a lot! too bad that was isnt my latest issue of Game Developer MAgazine! thanks again.. btw, do you have a monkey that likes tea? or are you half man- half monkey? lol j/k
heh
OpenGL_Guru
OpenGL_Guru
wow what a perfect link teamonkey! thanks a lot! too bad that was isnt my latest issue of Game Developer MAgazine! thanks again.. btw, do you have a monkey that likes tea? or are you half man- half monkey? lol j/k
heh
Thunder_Hawk
Thunder_Hawk
I bet he''s supposed to be a team of monkeys.

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Forma
OpenGL_Guru
OpenGL_Guru
lots of monkeys who drink tea lol

they all need teapee for thier bungholes haha
heh
teamonkey
teamonkey
quote:
Original post by Thunder_Hawk
I bet he''s supposed to be a team of monkeys.


Actually no, it''s "tea"+"monkey"

OpenGL_Guru: I''m interested if you''ll be using some of the other techniques mentioned in that article, apart from keeping the viewpoint at 0,0, for your height map?
[teamonkey] [blog] [tinyminions]
OpenGL_Guru
OpenGL_Guru
well i didnt read the whole thing of part 3 and i have to go back and read the first 2 parts, i just got out of a meeting so you know how that goes yeah since i am calculating normals for my heightmap i would be interested in one technique that i saw regarding breaking apart each "square" into smaller triangles, smaller and smaller. although my heightmap is not high res this would prove to be useful for more in depth high res heightmaps, in bigger 3D worlds. first i have to figure out how to update my translations with regard to the angle of rotation of my heightmap. like when i rotate it 90 degrees lets say i want to update my translations, otherwise left will be up and right will be down and so on and so on... im sure this is a common problem
heh

Topic Locked

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

Sign in to reply to this topic.