# 頂點法線的逆轉置

You are correct, when they are talking about taking the inverse-transpose they are talking about the 3x3 part of the affine transformation leaving the translation since it doesn't affect the normal vector.

About how or why is it the inverse transpose, a simple explanation, that is also given in the book "Essential Mathematics for Games" is

Suppose we have a Point $P$ and a normal vector $n$ both represented by column matrix. Then we know that $$n^T P = 0$$ This is the same as the dot product. Now if we apply a transformation matrix $M$ to point $P$, we'll have to apply some sort of transformation matrix $Q$ to $n$ also. $$\begin{eqnarray} (Q n)^T M P & = & 0 \\ n^T Q^T M P & = & 0 \end{eqnarray}$$

One solution is $$\begin{eqnarray} Q^T M & = & I \\ Q & = & {M^{-1}}^T \end{eqnarray}$$ Hence the inverse transpose. This stands for any sort of transformation matrix $M$ be it scaling, rotation etc. Also for pure rotation matrix, since they are orthogonal, the matrix transforming the normals is the same as that of the vertices. as ${M^T}^T = M$

You're right, translation is not relevant in this context: it wouldn't affect the normals.

Consider a non-uniformly scaled object: We want to get the normal matrix to transform the normals in the vertex buffer into vectors representing world space normals from the world matrix M, which encodes the translation, rotation and scaling (and shearing) of the model object.

If you were to interpret the 3x3 of the M in the vertex shader, you would read rotation data with scaling applied. If the world matrix contains non-uniform scaling, your normal vectors will be scaled incorrectly, and you'll get the wrong results.

The reason we take the transpose of the transform is because the rotation matrix, used to create M = TranslationMatrix x RotationMatrix x ScaleMatrix, is an Orthagonal Matrix, which means that the row vectors are orthogonal, unit vectors, i.e. they are linearly-independent and their length is one.

This type of matrices hold a property like the following:

Q^T * Q = Q * Q^T = I


If you remember the inverse rule:

Q^-1 * Q = Q * Q^-1 = I


This also means the following for the orthogonal matrices:

Q^T = Q^-1


This allows us to apply the inverse of the rotations by transposing the matrix.

In summary, taking inverse-transpose of the world matrix does 2 important things:

1. Undo transformation (Inverse)
• undo the scaling (and shearing)
• invert rotations
• translate the object to the world center (irrelevant) 1. Un-undo rotations (Transpose)
• Now, if we take the transpose of our matrix, we will get our rotations back to their original state because of the orthogonal property of the rotation matrix. We now have our normal matrix ready to transform model-space normals defined in the vertex buffer into world-space normals in the vertex shader.