Просмотр исходного кода

Fixing tangent frame generation so it properly accumulates tangents/normals

BearishSun 9 лет назад
Родитель
Сommit
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];
 			VertexFaces& faces = connectivity.vertexFaces[i];
 
 
+			normals[i] = Vector3::ZERO;
 			for (UINT32 j = 0; j < faces.numFaces; j++)
 			for (UINT32 j = 0; j < faces.numFaces; j++)
 			{
 			{
 				UINT32 faceIdx = faces.faces[j];
 				UINT32 faceIdx = faces.faces[j];
@@ -809,8 +810,7 @@ namespace BansheeEngine
 				faceBitangents[i].normalize();
 				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);
 		VertexConnectivity connectivity(indices, numVertices, numFaces, indexSize);
@@ -818,6 +818,9 @@ namespace BansheeEngine
 		{
 		{
 			VertexFaces& faces = connectivity.vertexFaces[i];
 			VertexFaces& faces = connectivity.vertexFaces[i];
 
 
+			tangents[i] = Vector3::ZERO;
+			bitangents[i] = Vector3::ZERO;
+
 			for (UINT32 j = 0; j < faces.numFaces; j++)
 			for (UINT32 j = 0; j < faces.numFaces; j++)
 			{
 			{
 				UINT32 faceIdx = faces.faces[j];
 				UINT32 faceIdx = faces.faces[j];