0
\$\begingroup\$

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)

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

1 Answer 1

0
\$\begingroup\$

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.

\$\endgroup\$
7
  • \$\begingroup\$ Thanks, but why sometimes use that instead of gl_ModelViewMatrixInverse? \$\endgroup\$
    – Invariant
    Sep 6, 2019 at 7:25
  • \$\begingroup\$ added further explanation to answer. \$\endgroup\$ Sep 6, 2019 at 7:29
  • \$\begingroup\$ You're wrong, transpose = inverse only in case of rotation and reflection matrices. \$\endgroup\$
    – Ocelot
    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\$ 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\$ 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 .