itun
itun

Reputation: 3521

OpenGL: gl_NormalMatrix & Skinning

How to obtain normal matrix for normal when I do skinning? In particular, when I do dual quaternion skinning.

Upvotes: 0

Views: 724

Answers (1)

datenwolf
datenwolf

Reputation: 162164

Quaternions directly translate into rotation matrices. In the case of OpenGL the rotation matrix is the upper left 3×3 submatrix. Normals are transformed by the inverse transpose of the modelview matrix. However for pure rotations, which are orthonormal transformations, the inverse is the transpose so obtaining the inverse transpose of a pure rotation matrix is a identity transform.

Thus you can just pass your quaternions as vec4 uniforms to the shader, build the 4×4 rotation matrix there, use it directly on the normals and multiply it on the gl_ModelViewMatrix to get the vertex position transformation.

Upvotes: 1

Related Questions