## mesa3d-users

 [Mesa3d-users] Matrices problems ... From: Damien TOURAINE - 2001-04-12 13:35:12 ```Hi all ! I'm trouble about the use of homogenous coordinates in OpenGL, and more specifically, with the glFrustum function : It seems that the last coordinate (homogenous one) is replaced in the case of this function by the Z-coordinate. Is it true or am I wrong ? Moreover, when are the standards coordinates divided by the homogenous one ? If they are divided after the Projection matrix, how does MesaGL deal with this function (does it means that the homogenous coordinate is definitively loose) ? How OpenGL deal with the case of vertices on the Z=0 plan with the frustum matrix (thoses vertices would be at the infinite, but the computer don't understand "infinite") ? Friendly Damien TOURAINE -- -------------------------------------------------------------------- Damien TOURAINE - +33 1 69 85 81 68 PhD student at LIMSI - CNRS (http://www.limsi.fr) Bat. 508, Universite Paris-Sud F-91403 Orsay cedex (France) -------------------------------------------------------------------- ```
 Re: [Mesa3d-users] Matrices problems ... From: Brian Paul - 2001-04-12 13:57:44 ```Damien TOURAINE wrote: > > Hi all ! > > I'm trouble about the use of homogenous coordinates in OpenGL, and more > specifically, with the glFrustum function : > It seems that the last coordinate (homogenous one) is replaced in the > case of this function by the Z-coordinate. Is it true or am I wrong ? If I understand you correctly, yes, that's basically true. > Moreover, when are the standards coordinates divided by the homogenous one ? After application of the projection matrix, but before viewport mapping. > If they are divided after the Projection matrix, how does MesaGL deal > with this function (does it means that the homogenous coordinate is > definitively loose) ? I don't understand. If (px,py,pz,pw) is the post-projection coordinate then the NDC, normalized device coordinates, (nx, ny, nz) are computed with: nx = px / pw ny = py / pw nz = pz / pw nx, ny and nz will be in [-1,1] and are subsequently scaled and bias according to glViewport() and glDepthRange(). > How OpenGL deal with the case of vertices on the Z=0 plan with the > frustum matrix (thoses vertices would be at the infinite, but the > computer don't understand "infinite") ? The near clipping plane prevents coordinates with Z=0. -Brian ```
 Re: [Mesa3d-users] Matrices problems ... From: Damien TOURAINE - 2001-04-12 14:18:16 ```Brian Paul wrote: > Damien TOURAINE wrote: > >> Hi all ! >> >> I'm trouble about the use of homogenous coordinates in OpenGL, and more >> specifically, with the glFrustum function : >> It seems that the last coordinate (homogenous one) is replaced in the >> case of this function by the Z-coordinate. Is it true or am I wrong ? > > If I understand you correctly, yes, that's basically true. >> Moreover, when are the standards coordinates divided by the homogenous one ? > > After application of the projection matrix, but before viewport mapping. > >> If they are divided after the Projection matrix, how does MesaGL deal >> with this function (does it means that the homogenous coordinate is >> definitively loose) ? > > I don't understand. If (px,py,pz,pw) is the post-projection coordinate > then the NDC, normalized device coordinates, (nx, ny, nz) are computed with: > > nx = px / pw > ny = py / pw > nz = pz / pw > > nx, ny and nz will be in [-1,1] and are subsequently scaled and bias > according to glViewport() and glDepthRange(). Yes of course, but the problem is : Imagine that I post a vertex that homogenous coordinates are (3.0, 3.0, 3.0, 3.0) => NDC = (1.0, 1.0, 1.0) ... With the Identity in the modelview as well as in the projection matrix, ie, a glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0) the finale NDC point provided to the viewport would be OK (1.0, 1.0, 1.0). However, in the case of Frustum matrix, as I loose the homogenous coordinates, I would have a defect in the drawing (homothetie) ... Is it true ? >> How OpenGL deal with the case of vertices on the Z=0 plan with the >> frustum matrix (thoses vertices would be at the infinite, but the >> computer don't understand "infinite") ? > > The near clipping plane prevents coordinates with Z=0. Yes, but all the vertices are computed by the two matrices and the clipping by the front plane are done after the NDC ... Thus, a problem may occur ! Friendly Damien TOURAINE -- -------------------------------------------------------------------- Damien TOURAINE - +33 1 69 85 81 68 Doctorant au LIMSI - CNRS (http://www.limsi.fr) Bat. 508, Universite Paris-Sud 91403 Orsay cedex -------------------------------------------------------------------- ```
 Re: [Mesa3d-users] Matrices problems ... From: Brian Paul - 2001-04-12 14:26:55 ```Damien TOURAINE wrote: > > Brian Paul wrote: > > > Damien TOURAINE wrote: > > > >> Hi all ! > >> > >> I'm trouble about the use of homogenous coordinates in OpenGL, and more > >> specifically, with the glFrustum function : > >> It seems that the last coordinate (homogenous one) is replaced in the > >> case of this function by the Z-coordinate. Is it true or am I wrong ? > > > > If I understand you correctly, yes, that's basically true. > > >> Moreover, when are the standards coordinates divided by the homogenous one ? > > > > After application of the projection matrix, but before viewport mapping. > > > >> If they are divided after the Projection matrix, how does MesaGL deal > >> with this function (does it means that the homogenous coordinate is > >> definitively loose) ? > > > > I don't understand. If (px,py,pz,pw) is the post-projection coordinate > > then the NDC, normalized device coordinates, (nx, ny, nz) are computed with: > > > > nx = px / pw > > ny = py / pw > > nz = pz / pw > > > > nx, ny and nz will be in [-1,1] and are subsequently scaled and bias > > according to glViewport() and glDepthRange(). > > Yes of course, but the problem is : > Imagine that I post a vertex that homogenous coordinates are (3.0, 3.0, > 3.0, 3.0) => NDC = (1.0, 1.0, 1.0) ... > With the Identity in the modelview as well as in the projection matrix, > ie, a glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0) the finale NDC point > provided to the viewport would be OK (1.0, 1.0, 1.0). > However, in the case of Frustum matrix, as I loose the homogenous > coordinates, I would have a defect in the drawing (homothetie) ... > Is it true ? I don't understand. Remember that clipping to the viewing frustum is performed after application of the project matrix, but before the divide-by-W. Frustum clipping ensures that -pw < px < pw, -pw < py < pw and -pw < pz < pw. > >> How OpenGL deal with the case of vertices on the Z=0 plan with the > >> frustum matrix (thoses vertices would be at the infinite, but the > >> computer don't understand "infinite") ? > > > > The near clipping plane prevents coordinates with Z=0. > > Yes, but all the vertices are computed by the two matrices and the > clipping by the front plane are done after the NDC ... > Thus, a problem may occur ! Clipping is performed on the project coordinates, before dividing by W and before NDC-to-Viewport mapping. -Brian ```