How do we get the inverse of a matrix within shaders?
Inverse of modelview matrix: gl_ModelViewMatrixInverse
Inverse of projection matrix: gl_ProjectionMatrixInverse
Otherwise, you can compute it mathematically by hardcoding the formula for inverting a 2x2, 3x3, or 4x4 matrix found here.
I could do that but it will be inefficient to do that per vertex, especially when having thousands of multi-verts polys.
But those built-in uniforms are not supported yet???
That sounds like a bug… those two uniforms should definitely be available (there’s also gl_ModelViewProjectionMatrixInverse).
Or, you could always compute it on the CPU and supply it as a uniform, if that works for what you’re doing.
glFreak > I don’t think that the inverse computation of all these matrices is done per vertex…it would be completly stupid. I think that it is done for each glBegin()/glEnd() sequence.
gl_ProjectionMatrixInverse, gl_ModeViewMatrixInverse,… are built-in uniform. It means that they are given by primitive and not by vertex as it would be if they were attribute variables.
So I think that you will gain in performances if you use these built-in uniform whereas computing these inverses on CPU.
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.