From e3cb65416805cf5d4e2fdee65a1593a4bbb9140d Mon Sep 17 00:00:00 2001 From: Max Kramarov Date: Sun, 26 Oct 2025 20:01:51 +0200 Subject: [PATCH] converted mesh normals from local space to world space --- .../Scripts/Utility/HEU_InputInterfaceMesh.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Plugins/HoudiniEngineUnity/Scripts/Utility/HEU_InputInterfaceMesh.cs b/Plugins/HoudiniEngineUnity/Scripts/Utility/HEU_InputInterfaceMesh.cs index 6df46a73..a5aa737e 100644 --- a/Plugins/HoudiniEngineUnity/Scripts/Utility/HEU_InputInterfaceMesh.cs +++ b/Plugins/HoudiniEngineUnity/Scripts/Utility/HEU_InputInterfaceMesh.cs @@ -285,6 +285,7 @@ public bool UploadData(HEU_SessionBase session, HAPI_NodeId inputNodeID, HEU_Inp { Vector3[] meshVertices = inputDataMeshes._inputMeshes[i]._mesh.vertices; Matrix4x4 localToWorld = rootInvertTransformMatrix * inputDataMeshes._inputMeshes[i]._transform.localToWorldMatrix; + Matrix4x4 worldToLocalTransposed = localToWorld.inverse.transpose; List uniqueVertices = new List(); @@ -366,7 +367,11 @@ public bool UploadData(HEU_SessionBase session, HAPI_NodeId inputNodeID, HEU_Inp if (meshNormals != null && (originalIndex < meshNormals.Length)) { - normals.Add(meshNormals[originalIndex]); + Vector3 normalLocalSpace = meshNormals[originalIndex]; + Vector3 normalWorldSpace = worldToLocalTransposed * normalLocalSpace; + if (normalWorldSpace.sqrMagnitude > 0f) + normalWorldSpace.Normalize(); + normals.Add(normalWorldSpace); } for (int u = 0; u < NumUVSets; ++u)