Artifacts during zooming (glOrtho)

Hi All,

We are experiencing some artifacts during zooming (see picture). We perform zoom scaling the first 4 parameters of the glOrtho(left, right, bottom, top, near, far) method and noticed that changing the zNear and zFar values something changes. Currently we use the -1e6 for near and +1e6 for far: are the wrong? We also tested some other combination like -1e5 and +1e5 without success.

Any idea on how to correct this problem?



Yes… This is the problem with z-fighting. Please read

As a quick fix set znear = -1 and zfar = 1

znear /zfar values should define the smallest range in which fits what you want to see. Otherwise you loose zbuffer precision, which alter depth tests precision, and it results in this type of artifacts.

Now I see thanks.

Now I am wondering why this does not happen with gluPerspective…

yooyo, very nice link thanks.


That’s because glOrtho has a linear Z-conversion between eye-space and screen space Z-coordinate while the perspective camera has a non-linear conversion between eye-space and screen space Z-coordinate. For the non-linear conversion, the depth resolution is dependent on the distance of the object to the camera. If it’s near, you get good Z-resolution.