Z-buffer problems

Started by
2 comments, last by David Jones 20 years, 12 months ago
My depth testing was definately not working in my Open GL program, so I decided to look through these forums. Quite a while ago someone had something similar. I now understand where I went wrong and wish to share it. When setting the perspective matrix - gluPerspective (angle, (w/h), near, far); - is where my problem occured. The Z-buffer uses a ratio to determine how much to focus in certain areas...there''s some fact like 98% of the depth buffer is used on the first 2% of the scene. I had the near set as 0.0f, which obviously caused a divide by zero and therefore the buffer wouldn''t work. The other guy was using 0.5f...very similar, it makes the ratio huge! Hope this helps someone! It''''s always a silly little error!
It''s always a silly little error!
Advertisement
it is also advised to make znear at least 1.0f
don''t piss on an electrical fence
http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html
quote:Original post by _Corrupt_
it is also advised to make znear at least 1.0f


Not nessecarily... It is advised that you keep the ratio between your znear, and zfar small... Some people use 0.1f, 1000.0f, and that is a very large ratio, which will cause problems on some cards. So what you can do is just change the near to 1.0f...

This topic is closed to new replies.

Advertisement