[osg-submissions] From post-perspective space to world space (GLSL)
Joakim Simonsson
joakim at autosim.no
Tue Jul 24 04:02:32 PDT 2007
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.
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.
Are there a more convenient way make this calculation?
--
Joakim Simonsson
More information about the osg-submissions
mailing list