Reputation: 31860
I know that the normal transformation matrix is the inverse of the transpose of the model/view/projection matrix, but it looks like "inverse
" was only added in GLSL 1.4 and I can't find a "transpose
". Do I have to just copy and paste a bunch of math into my GLSL? (If so, is there a nice authoritative open-source place I can copy from?)
To be clear, what I'm asking is "How do I calculate gl_NormalMatrix
without using deprecated APIs"?
Upvotes: 1
Views: 1391
Reputation: 1
just to clarify there's also transpose and if you don't do any scale the normal matrix is the 3x3 submatrix, in glsl you can do
normal = mat3(model_matrix) * v_normal;
Upvotes: 0
Reputation: 473407
This is normally handled by computing the transpose of the inverse of the modelview matrix
N = (M^-1)^T
on the CPU, then uploading the matrix just like uploading any other matrix.
Upvotes: 3