View Full Version : Artifacts during zooming (glOrtho)

05-16-2008, 05:40 AM
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?




05-16-2008, 06:18 AM
Yes.. This is the problem with z-fighting. Please read http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

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

05-16-2008, 06:18 AM
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.

05-16-2008, 06:33 AM
Now I see thanks.

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

yooyo, very nice link thanks.


05-16-2008, 07:32 AM
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.