I’m doing a per fragment lighting and when correcting normal vecter, i got this code: vec3 f_normal = mat3(MVI) * normal; Where MVI is: mat4 MVI = transpose(inverse(ModelViewMatrix));. So what is return after mat3(MVI) statement?
I’m doing a per fragment lighting and when correcting normal vecter, i got this
Share
Returns the upper 3×3 matrix from the 4×4 matrix and multiplies the normal by that. This matrix is called the ‘normal matrix’. You use this to bring your normals from world space to eye space. The upper 3×3 portion of the matrix is important for scale and rotation, while the rest is only for translation (and normals are never translated)
To take a normal from world space to eye space, you just need the 3×3 inverse transpose of the model view matrix. Unless your matrix in othro normal (no non-uniform scale) in that case the original matrix is the same as its inverse transpose.