# Why do we multiply perspective * modelview * point?

A common line in vertex shaders is:

gl_Position = projection_matrix * model_view_matrix * object_space_vertex;


I've seen this a lot, why isn't it written like

gl_Position = object_space_vertex * model_view_matrix * projection_matrix;


?

That would be more intuitive I suppose. Is it mathematically wrong?

Yes, it isn't what we want to do. Matrix multiplication is not communative, which is to say that switching the order produces different things.

Think of it this way, if you do these operations:

• Turn left 90 degrees
• Go forward 10 meters

You end up at a different position then if you did:

• Go forward 10 meters
• Turn left 90 degrees

This doesn't mean it's mathematically wrong, you could very well have a need for doing it in a different order, it's just that for this thing we want to do P*M*O and not some other order.

• That's an excellent analogy!
– user35344
Oct 4, 2016 at 14:09
• This also depends on your matrix conventions. DirectX and OpenGL famously disagree about which side of the matrix your vector-to-be-transformed should be placed, so what's M3 * M2 * M1 * v in GL would be v * M1 * M2 * M3 in DX... Oct 4, 2016 at 16:22
• Just to add, the terminology for this is left-to-right matrix multiplication versus right-to-left Oct 4, 2016 at 20:47