I have a problem with setting up the gl_ModelViewMatrix in GLSL code with Ogre3D and the recent versions of OpenGL. Before OpenGL 3.0 I could use the gl_ModelViewProjectionMatrix directly in the GLSL code to obtain the vertex positions in the vertex shader. However, in OpenGL 4.0 it seams that all the gl_... stuff (apart from gl_Position and probably a few more) are being deprecated.
As far as I understand, the solution is to send the view, model and projection matrices through uniform variables to the vertex shader and then apply the following code in the main() function:
Code: Select all
gl_Position = projMat*viewMat*modelMat*_layoutVertPos;
I don't know wich matrix should I use because these matrices are set by material (each shader corresponds to a material) and different objects, with different model matrices may use the same material... So, if I use the _getFullTransform() function of the node to set its material model matrix, it will only work for that specific object.
Is there some function in Ogre3D to set this matrix correctly on a per object basis? Or what sequence of procedures should I do to generate this matrix correctly in my shader?
Although I can still use the gl_ModelViewMatrix in shader code, probably it will disapear in the future, and then it must be created manually.
I hope this makes some sense!
Thank you!