I tried to calculate the inverse Modelview, but what is gl_ModelViewMatrix ? It is definitively not the same like glGetFloatv(GL_MODELVIEW_MATRIX,m). (of course I don’t do anymore transformations after I call glGetFloat)
OpenGL seems to make an additional transformation before sending it to the Shader. What is this transformation ?
[This message has been edited by Keldon (edited 12-19-2003).]
Don’t forget to update your modelview matrix uniform everytime inside a glPushMatrix() / glPopMatrix().
For example, you can’t use glutSolidTeapot or other predefined Objects which use push/pop inside. I wrote a little program using inverse modelview/modelviewprojection and it works fine now. I will upload it to my site tonight.
I really wish gl_ModelViewMatrixInverse would be part of the standard…
It isn’t.
It is the upper 3x3 of the inverse of the modelview matrix.
Actually, I’m not sure, it might be the upper 3x3 of the inverse transpose of the modelview matrix.
You can of course just use the upper 3x3 of the modelview if there is no non uniform scale operation on it.
The normal matrix is the inverse transpose of the rotational part of the modelview matrix.
What Mazy said is true iff the conditions holds that the rotational part is and orthogonal (or even orthonormal) matrix. In this case it is true that M^-1 = M^T. Therefore (M^T)^-1 = (M^-1)^-1 = M.
In general this is NOT true! Still, since most of the time we’re dealing with an orthonormal matrix (some form of the 3D rotation matrices) mat3(gl_ModelViewMatrix) == gl_NormalMatrix.
Edit: @Amandeep: You might want to check out rule #6 in the forum posting guidelines. Just realized how incredibly dated this thread is…