views:

371

answers:

1

hello, since in GLSL the modelmatrix is not available, i was wondering if it is possible to get it programatically from the gl_ModelViewMatrix and the "viewmatrix" which i would pass as a uniform?

if yes, how?

thank you!

+3  A: 

You can obtain the model matrix by multiplying the modelview matrix with the inverse of your view matrix.

gl_ModelViewMatrix * myViewMatrixInverse

Can
thanks, but that means that i have to calculate the inverse of the viewmatrix on the clientside and pass it as a uniform, right?
clamp
@matt: afaik there is no built-in function to do a matrix inverse in glsl or opengl. so you have to code your own in either the clientside or the shader, the decision is up to you.
Can
thank you! and the viewmatrix is the one i get with glGetFloatv(GL_MODELVIEW_MATRIX , ...);immediately after the gluLookAt(), right?
clamp
yes, that's right
Can