法线贴图一章节涉及到TNB-切线空间。切线空间在坐标变换过程中,可能偏离,TNB需要重新正交化。最重要的一步是T N正交化。 涉及到的代码片段如下: 重点理解:T = normalize(T - dot(T, N) * N);
vec3 T = normalize(vec3(model * vec4(tangent, 0.0)));
vec3 N = normalize(vec3(model * vec4(normal, 0.0)));
// re-orthogonalize T with respect to N
T = normalize(T - dot(T, N) * N);
// then retrieve perpendicular vector B with the cross product of T and N
vec3 B = cross(T, N);
mat3 TBN = mat3(T, B, N)
TN重新正交