From d8aba3e850c80f61b41bf2874430dc905830ae01 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Mon, 26 Sep 2022 11:50:29 +0200 Subject: [PATCH] Renormalize normals & tangents from dmap .glb import --- neo/idlib/MapFile_gltf.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/neo/idlib/MapFile_gltf.cpp b/neo/idlib/MapFile_gltf.cpp index 49c5026b..cb4787a7 100644 --- a/neo/idlib/MapFile_gltf.cpp +++ b/neo/idlib/MapFile_gltf.cpp @@ -164,6 +164,10 @@ MapPolygonMesh* MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh_Primitive* p normal.z = vec.z; normal *= transform; + + // renormalize because previous transforms may contain scale operations + normal.Normalize(); + mesh->verts[i].SetNormal( normal ); } @@ -208,6 +212,7 @@ MapPolygonMesh* MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh_Primitive* p tangent.z = vec.z; tangent *= transform; + tangent.Normalize(); mesh->verts[i].SetTangent( tangent ); mesh->verts[i].SetBiTangentSign( vec.w );