瀏覽代碼

Fixing tangent frame generation so it properly accumulates tangents/normals

BearishSun 9 年之前
父節點
當前提交
7df08fef41
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      Source/BansheeCore/Source/BsMeshUtility.cpp

+ 5 - 2
Source/BansheeCore/Source/BsMeshUtility.cpp

@@ -750,6 +750,7 @@ namespace BansheeEngine
 		{
 			VertexFaces& faces = connectivity.vertexFaces[i];
 
+			normals[i] = Vector3::ZERO;
 			for (UINT32 j = 0; j < faces.numFaces; j++)
 			{
 				UINT32 faceIdx = faces.faces[j];
@@ -809,8 +810,7 @@ namespace BansheeEngine
 				faceBitangents[i].normalize();
 			}
 
-			// Note: Potentially don't normalize here in order to weigh the normals
-			// by triangle size
+			// Note: Potentially don't normalize here in order to weight the normals by triangle size
 		}
 
 		VertexConnectivity connectivity(indices, numVertices, numFaces, indexSize);
@@ -818,6 +818,9 @@ namespace BansheeEngine
 		{
 			VertexFaces& faces = connectivity.vertexFaces[i];
 
+			tangents[i] = Vector3::ZERO;
+			bitangents[i] = Vector3::ZERO;
+
 			for (UINT32 j = 0; j < faces.numFaces; j++)
 			{
 				UINT32 faceIdx = faces.faces[j];