model and projection matrices are separate in OpenGL. Abstract camera already grabs the Projection matrix. I haven't really studied what you are proposing, but is this matrix not enough? (Maybe we have the method misnamed.)
The model matrix, to send data (vertices for example) from the object space to the world space;
The view matrix, to send data from the world space to the view space;
The projection matrix, to send vertices from the view space to the screen space.
In OpenGL, the model matrix and the view matrix are automatically merged.
So, in a GLSL shader program, you can only use 2 matrices :
The model/view matrix, to send data from the object space to the view space;
The projection Matrix, to send data from the view space to the screen space.
If you only use the fixed graphic pipeline, don't need to use separatly the model and the view matrix,.
But sometimes, when you use shaders you need them separately.
In jme we could add functions to get the model matrix and the view matrix separatly, by adding getViewMatrixInverse() to the camera and another function getModelMatrixInverse() to the com.jme.scene.Spatial class.
I have not much knowledge on all this but I always thought that the two matrices that are combined in OpenGL are the view and the projection matrix. The model matrix is still alone in both 3D APIs. I'm unsure anyway.
Anyway, I don't understand the solution you propose and you seem to know what you're talking about better than me. I hope that someone can help you with this.
I always thought that the two matrices that are combined in OpenGL are the view and the projection matrix
It is strange, but you are not the first person that tell that the projection and and the view matrix are combine in OpenGL.
In fact, you can combine them as you say : the result would be the same because (Mat_projection * Mat_view) * Mat_model == Mat_projection * (Mat_view * Mat_model).
But I think your way is not the right way because OpenGL provides matrix stacks which are named GL_PROJECTION and GL_MODELVIEW. (see the glMatrixMode specification http://pyopengl.sourceforge.net/documentation/manual/glMatrixMode.3G.html).
I think it is bad to store projection/view matrix inside the GL_PROJECTION stack and the model matrix inside the GL_MODELVIEW stack...
I don't understand the solution you propose
I want to create some GLSL standard Fx like a per pixel lighting or a real time paralax dot3 bump mapping (like in TestFragmentProgramState demo http://www.jmonkeyengine.com/webstart/jmedemo.php?renderer.state.TestFragmentProgramState) in an entire scene. To do that, I need to process separatly the model matrix and the view matrix, and that is why I'm going to develop some usefull functions to get these matrices.
i think targ is right…the viewmatrix is much needed in shaders, and is not supplied by opengl automatically(why i have no clue). fortunately it's very easy to extract…just multiply the inverse of the modelmatrix with the modelviewmatrix and you are there…
just multiply the inverse of the modelmatrix with the modelviewmatrix and you are there...
I'm agree with you, but you cannot get the model/view matrix from jme ! The only place to get it is the vertex/pixel shader. Then , if you want to compute the view matrix by this way, you must recompute it in the shader and then recompute it for each vertex/pixel. I think that it is hightly unoptimized :-o !!!
My prefered way is to precompute the view matrix in the java program by using the function that I wrote in my first post, and then to send it to the shader program like an uniform variable.