Fixes #653: Skin normals/tangents before applying world space transform (#656)

This commit is contained in:
shartte
2018-12-24 08:50:29 +01:00
committed by Romain Guy
parent 5ea35ab87e
commit cd2786a2ef
+5 -5
View File
@@ -11,6 +11,11 @@ void main() {
// We encode the orthonormal basis as a quaternion to save space in the attributes
toTangentFrame(mesh_tangents, material.worldNormal, vertex_worldTangent);
#if defined(HAS_SKINNING)
skinNormal(material.worldNormal, mesh_bone_indices, mesh_bone_weights);
skinNormal(vertex_worldTangent, mesh_bone_indices, mesh_bone_weights);
#endif
// We don't need to normalize here, even if there's a scale in the matrix
// because we ensure the worldFromModelNormalMatrix pre-scales the normal such that
// all its components are < 1.0. This precents the bitangent to exceed the range of fp16
@@ -18,11 +23,6 @@ void main() {
vertex_worldTangent = objectUniforms.worldFromModelNormalMatrix * vertex_worldTangent;
material.worldNormal = objectUniforms.worldFromModelNormalMatrix * material.worldNormal;
#if defined(HAS_SKINNING)
skinNormal(material.worldNormal, mesh_bone_indices, mesh_bone_weights);
skinNormal(vertex_worldTangent, mesh_bone_indices, mesh_bone_weights);
#endif
// Reconstruct the bitangent from the normal and tangent. We don't bother with
// normalization here since we'll do it after interpolation in the fragment stage
vertex_worldBitangent =