> > Hi, > > In GLSL, a point is transformed from world-space to post-perspective > camera space like this: > > ftransform(); > OR > gl_ModelViewProjectionMatrix * gl_Vertex; > OR > gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex; > OR > gl_ProjectionMatrix * osg_ViewMatrix * gl_Vertex; > > It seems that the osg-provided uniform, osg_ViewMatrix, is equivalent with > gl_ModelViewMatrix.
No, osg_ViewMatrix is just the view (ie camera) transformation, without the model transformation. gl_ModelViewMatrix is the standard OpenGL combined view+model transformation. > > What I am looking for is to transform a point from post-perspective space > to world-space. > > A document that I've read says that this is done by the following > equations: > > (I am using the ' symbol for denoting an inverse (^-1) ) > > Eq 1: > M_Projector = (M_View * M_Perspective)' > > If I have understood things correctly, this is the inverse of > ModelViewProjectionMatrix. (?) > > Eq 2: > p_world = M_Projector * p_projector > > M are the camera matrices. p is a point in homogenous three-dimensional > space. > > If (M_View * M_Perspective)' is the the inverse of > ModelViewProjectionMatrix it would be equivalent to, > osg_ViewMatrixInverse * gl_ProjectionMatrix', as B'A'=(AB)' . (?) > > osg_ViewMatrixInverse is provided by osg, so the only thing I have to do > is to calculate the inverse of gl_ProjectionMatrix. GLSL provides many of the built-in "gl_" matrices also as inverse, transpose, and inverse-transpose. See p45 of the 1.10 spec or the GLSL Quick Reference at mew.cx cheers -- mew > > Are there a more convenient way make this calculation? > > > > -- > Joakim Simonsson > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

