Original Post
Is there any function in glsl or opengl to get the inverse matrix?Now,I should use it,can anyone can help you?
Quote:I don't know about GLSL, but there is no OpenGL function to invert a matrix (the OpenGL API doesn't include math functions, per se).
Original post by jzpijiang
Is there any function in glsl or opengl to get the inverse matrix?Now,I should use it,can anyone can help you?
Quote:This has been discussed in a couple of threads in 'Math & Physics' recently. Not everyone agrees, but the general gist seems to be that for matrices of 4x4 and smaller, inversion by cofactors is generally preferred (or at least acceptable) because it's branchless (except possibly for checking for singularity) and because the types of matrices used in games and graphics are usually fairly well-behaved, numerically speaking.
Original post by jonnyfish
I have a warning. If you naively google "matrix inverse", you will probably find the expression giving the elements of the inverse in terms of the cofactors. This is NOT how you calculate inverses in general, because of the number of operations required. I think that even for n=4 calculating the inverse in this way is slower than other methods (i.e. reducing the augmented matrix A|I to reduced row echelon form), but correct me if I'm wrong. Additionally, you should also be aware of questions of numerical stability of whatever method you use.
( R R R P)O =( R R R P) ( R R R P) ( 0 0 0 1) ( R R R 0)R =( R R R 0) ( R R R 0) ( 0 0 0 1) ( 1 0 0 P)T =( 0 1 0 P) ( 0 0 1 P) ( 0 0 0 1) ( 1 0 0 -P)inv(T) =( 0 1 0 -P) ( 0 0 1 -P) ( 0 0 0 1)
Is there any function in glsl or opengl to get the inverse matrix?Now,I should use it,can anyone can help you?
This topic has been locked by a moderator. New replies are not allowed.
GameDev.net uses cookies to ensure you have the best experience on our platform. Learn more