PDA

View Full Version : Artifacts during zooming (glOrtho)



devdept
05-16-2008, 06: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?

Thanks,

Alberto

http://www.devdept.com/glortho.jpg

yooyo
05-16-2008, 07: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

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

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

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

yooyo, very nice link thanks.

Alberto

-NiCo-
05-16-2008, 08: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.