What is the difference between doing these two operations? Don't the first transform the vector from model space to view space? Then what does the second operation do?

gl_ModelViewMatrix * vec4(vector, 0.0)

gl_ModelViewMatrixTranspose * vec4(vector, 0.0)

  • 2
    \$\begingroup\$ Transposition makes column-major matrix row-major and vice versa. \$\endgroup\$
    – Ocelot
    Commented Sep 6, 2019 at 0:02

1 Answer 1


Transpose of a matrix is the same as inverting the matrix, as long as the matrix is orthogonal.

So if your gl_ModelView matrix transforms from model space to view space, then the transpose (inverse) of that matrix will transform from view space to model space.

  • \$\begingroup\$ Thanks, but why sometimes use that instead of gl_ModelViewMatrixInverse? \$\endgroup\$
    – Invariant
    Commented Sep 6, 2019 at 7:25
  • \$\begingroup\$ added further explanation to answer. \$\endgroup\$ Commented Sep 6, 2019 at 7:29
  • \$\begingroup\$ You're wrong, transpose = inverse only in case of rotation and reflection matrices. \$\endgroup\$
    – Ocelot
    Commented Sep 6, 2019 at 8:45
  • \$\begingroup\$ Invariant - using transpose is much cheaper than inverse, so in cases where it makes sense (such as when you have an orthogonal matrix) using transpose saves a bit of time \$\endgroup\$ Commented Sep 6, 2019 at 14:30
  • \$\begingroup\$ Ocelot - Yes, thank you for pointing that out . I qualified my statement in the edit. Matrix must be orthogonal. \$\endgroup\$ Commented Sep 6, 2019 at 17:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .