From 9c2e485cfc2f60b28e01c5b3ddd9f15ef351feba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=C3=81vila=20Membrives?= Date: Sun, 3 Dec 2017 15:32:53 +0100 Subject: [PATCH 1/2] Apply the correct transform on normals (remove transform & scaling components) --- src/Fbx2Raw.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Fbx2Raw.cpp b/src/Fbx2Raw.cpp index 08b1440..35242ba 100644 --- a/src/Fbx2Raw.cpp +++ b/src/Fbx2Raw.cpp @@ -739,7 +739,10 @@ static void ReadMesh(RawModel &raw, FbxScene *pScene, FbxNode *pNode, const std: const FbxVector4 meshScaling = pNode->GetGeometricScaling(FbxNode::eSourcePivot); const FbxAMatrix meshTransform(meshTranslation, meshRotation, meshScaling); const FbxMatrix transform = meshTransform; - const FbxMatrix inverseTransposeTransform = transform.Inverse().Transpose(); + + // Remove translation & scaling from transforms that will bi applied to normals, tangents & binormals + const FbxMatrix normalTransform(FbxVector4(), meshRotation, FbxVector4(1.0f, 1.0f, 1.0f, 1.0f)); + const FbxMatrix inverseTransposeTransform = normalTransform.Inverse().Transpose(); raw.AddVertexAttribute(RAW_VERTEX_ATTRIBUTE_POSITION); if (normalLayer.LayerPresent()) { raw.AddVertexAttribute(RAW_VERTEX_ATTRIBUTE_NORMAL); } From 1a46ccf7ff5f42b68d9a11abf0477b2ce775764d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=C3=81vila=20Membrives?= Date: Sun, 3 Dec 2017 20:47:41 +0100 Subject: [PATCH 2/2] Include meshScaling in normal transform --- src/Fbx2Raw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fbx2Raw.cpp b/src/Fbx2Raw.cpp index 35242ba..61b241f 100644 --- a/src/Fbx2Raw.cpp +++ b/src/Fbx2Raw.cpp @@ -741,7 +741,7 @@ static void ReadMesh(RawModel &raw, FbxScene *pScene, FbxNode *pNode, const std: const FbxMatrix transform = meshTransform; // Remove translation & scaling from transforms that will bi applied to normals, tangents & binormals - const FbxMatrix normalTransform(FbxVector4(), meshRotation, FbxVector4(1.0f, 1.0f, 1.0f, 1.0f)); + const FbxMatrix normalTransform(FbxVector4(), meshRotation, meshScaling); const FbxMatrix inverseTransposeTransform = normalTransform.Inverse().Transpose(); raw.AddVertexAttribute(RAW_VERTEX_ATTRIBUTE_POSITION);