PDA

View Full Version : Model View matrix



Sly_Raccoon
12-07-2015, 01:35 AM
Hi All,

I am relatively new to Opengl so bear with me :) I have taken over a project from someone else and they are using the transpose of the inverse of the model view matrix to get a normal matrix, which is passed to the shaders for lighting / shading effects ??

The Issue I have is that in one location where this is done they had View * Model and in the other two they used Model * View for the model view matrix, which of these is the correct way? all the google searches I have done for model view matrix either don't say how they are created or talk about model view projection matrices.

Hopefully this is a simple answer :) and thanks in advance.

GClements
12-07-2015, 09:24 AM
With OpenGL or mathematical conventions, you'd use use View * Model.

For some reason, DirectX has its matrices transposed, so there you use Model * View.

More generally, (A.B)T=BT.AT and (A.B)-1=B-1.A-1. If a matrix is orthonormal (i.e. consists only of rotations), then M-1=MT. Also, using a row-major matrix where a column-major matrix is expected has the effect of transposing the matrix. So there are a variety of reasons why you might reverse the order of multiplies.