depth buffer and gluPerspective ratio

I have a model that is insanely large and my far clipping plane is very large. It seems that if my near clipping plane is too close to the camera then the depth function messes up and bottom layers start showing through top layers. My question is, the ratio of FarClippingPlane/NearClippingPlane needs to be lower than what value to ensure that the depth function works correctly ?

Hi !

The OpenGL spec has details on how it works, but if you increase the near clipping plane just a bit it might be working, the near clipping plane is very important to get correct because it has huge impact on the depth buffer.

Mikael

currently i am increasing the near clipping plane to get this working. But this is a model viewer and the user wants to zoom in very close for all the detail, but right now, with my near clipping plane high, the model disappears before you can get too close to it. When the user zooms in, i want the near clipping plane to be set to one, and then start brining the far clipping plane way in so that i still get good precision for the dpeth function, but i dont’ know how far i need to bring the farz in to get a good ratio.

Hi !

That depends on the resolution of your depthbuffer, with some contexts you will only have 16 bits, with some 24 bits, I if you are lucky you might get 32 bits.

Check out so that you are not running with some crappy 16 bit depth buffer.

Mikael