PDA

View Full Version : Can anyone explain me the attched picture from Angel's book

Lee_Jennifer_82
10-19-2015, 10:03 PM
Hello,
Can any one explain me the attached picture on Angel's book? How znear = -1 works here, I don't understand? Shouldn't be it equal to znear = +1 and zfar = -1?
2159

Dark Photon
10-20-2015, 09:18 AM
This shows how EYE-SPACE (left) is transformed to NDC-SPACE (right).

The znear = -1, zfar = +1 is part of the definition of the NDC-SPACE. Check it out in your favorite OpenGL book.

Lee_Jennifer_82
10-20-2015, 10:11 AM
This shows how EYE-SPACE (left) is transformed to NDC-SPACE (right).

The znear = -1, zfar = +1 is part of the definition of the NDC-SPACE. Check it out in your favorite OpenGL book.

I understand that, but shouldn't be znear = +1 and zfar = -1 ?

Dark Photon
10-21-2015, 06:09 AM
I understand what you're asking. I just don't understand why you're asking it.

That could have been chosen as the convention. It just wasn't.

Are you asking because EYE-SPACE znear > EYE-SPACE zfar, so you're expecting NDC znear > NDC zfar? If so, consider WINDOW-SPACE znear < WINDOW-SPACE zfar (by default), so the convention had to flip at some point. Might as well be for NDC.

GClements
10-21-2015, 06:44 AM
All of the legacy OpenGL functions which are typically used for constructing a projection matrix (i.e. glOrtho, glFrustum, gluOrtho2D and gluPerspective) construct a matrix which "flips" the Z direction, i.e. increasing eye-space Z maps to decreasing NDC Z, and the initial values of glDepthRange(), glDepthFunc() and glClearDepth() are appropriate for this convention.

If you wish, you can use a projection matrix which preserves the Z direction. But then you would need to either use e.g. glDepthRange(1, 0) or use glDepthFunc(GL_GREATER) and glClearDepth(0) so that closer objects obscure farther ones.

Lee_Jennifer_82
10-21-2015, 10:56 AM
Thank you both Dark Photon and GClements for trying to help me out. I understand but still a bit confused. I understand znear is smaller near the eye and perspective division produces the result at the right (top view). Am I right? But which coordinate system does the picture at the right follow? Here it seems that zmin and zman are the depths from the eye respectively which may not comply with the sign of near and far clipping plane.