Jelajahi Sumber

[ue4] SpineSkeletonRendererComponent explicitely generates normals now. Added SpineLitNormalMaterial, a masked material for use with UE4s lighting.

badlogic 6 tahun lalu
induk
melakukan
f6f3ed9542

+ 0 - 1
spine-ue4/Config/DefaultEngine.ini

@@ -58,4 +58,3 @@ SyncSceneSmoothingFactor=0.000000
 InitialAverageFrameRate=0.016667
 InitialAverageFrameRate=0.016667
 PhysXTreeRebuildRate=10
 PhysXTreeRebuildRate=10
 DefaultBroadphaseSettings=(bUseMBPOnClient=False,bUseMBPOnServer=False,MBPBounds=(Min=(X=0.000000,Y=0.000000,Z=0.000000),Max=(X=0.000000,Y=0.000000,Z=0.000000),IsValid=0),MBPNumSubdivs=2)
 DefaultBroadphaseSettings=(bUseMBPOnClient=False,bUseMBPOnServer=False,MBPBounds=(Min=(X=0.000000,Y=0.000000,Z=0.000000),Max=(X=0.000000,Y=0.000000,Z=0.000000),IsValid=0),MBPNumSubdivs=2)
-

TEMPAT SAMPAH
spine-ue4/Content/Test/NewWorld.umap


TEMPAT SAMPAH
spine-ue4/Plugins/SpinePlugin/Content/SpineLitNormalMaterial.uasset


+ 7 - 4
spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonRendererComponent.cpp

@@ -170,14 +170,15 @@ void USpineSkeletonRendererComponent::UpdateRenderer(USpineSkeletonComponent* sk
 	}
 	}
 }
 }
 
 
-void USpineSkeletonRendererComponent::Flush (int &Idx, TArray<FVector> &Vertices, TArray<int32> &Indices, TArray<FVector2D> &Uvs, TArray<FColor> &Colors, TArray<FVector>& Colors2, UMaterialInstanceDynamic* Material) {
+void USpineSkeletonRendererComponent::Flush (int &Idx, TArray<FVector> &Vertices, TArray<int32> &Indices, TArray<FVector> &Normals, TArray<FVector2D> &Uvs, TArray<FColor> &Colors, TArray<FVector>& Colors2, UMaterialInstanceDynamic* Material) {
 	if (Vertices.Num() == 0) return;
 	if (Vertices.Num() == 0) return;
 	SetMaterial(Idx, Material);
 	SetMaterial(Idx, Material);
 
 
-	CreateMeshSection(Idx, Vertices, Indices, TArray<FVector>(), Uvs, Colors, TArray<FProcMeshTangent>(), bCreateCollision);
+	CreateMeshSection(Idx, Vertices, Indices, Normals, Uvs, Colors, TArray<FProcMeshTangent>(), bCreateCollision);
 
 
 	Vertices.SetNum(0);
 	Vertices.SetNum(0);
 	Indices.SetNum(0);
 	Indices.SetNum(0);
+	Normals.SetNum(0);
 	Uvs.SetNum(0);
 	Uvs.SetNum(0);
 	Colors.SetNum(0);
 	Colors.SetNum(0);
 	Colors2.SetNum(0);
 	Colors2.SetNum(0);
@@ -187,6 +188,7 @@ void USpineSkeletonRendererComponent::Flush (int &Idx, TArray<FVector> &Vertices
 void USpineSkeletonRendererComponent::UpdateMesh(Skeleton* Skeleton) {
 void USpineSkeletonRendererComponent::UpdateMesh(Skeleton* Skeleton) {
 	TArray<FVector> vertices;
 	TArray<FVector> vertices;
 	TArray<int32> indices;
 	TArray<int32> indices;
+	TArray<FVector> normals;
 	TArray<FVector2D> uvs;
 	TArray<FVector2D> uvs;
 	TArray<FColor> colors;
 	TArray<FColor> colors;
 	TArray<FVector> darkColors;
 	TArray<FVector> darkColors;
@@ -299,7 +301,7 @@ void USpineSkeletonRendererComponent::UpdateMesh(Skeleton* Skeleton) {
 		}
 		}
 
 
 		if (lastMaterial != material) {
 		if (lastMaterial != material) {
-			Flush(meshSection, vertices, indices, uvs, colors, darkColors, lastMaterial);
+			Flush(meshSection, vertices, indices, normals, uvs, colors, darkColors, lastMaterial);
 			lastMaterial = material;
 			lastMaterial = material;
 			idx = 0;
 			idx = 0;
 		}
 		}
@@ -319,6 +321,7 @@ void USpineSkeletonRendererComponent::UpdateMesh(Skeleton* Skeleton) {
 			colors.Add(FColor(r, g, b, a));
 			colors.Add(FColor(r, g, b, a));
 			darkColors.Add(FVector(dr, dg, db));
 			darkColors.Add(FVector(dr, dg, db));
 			vertices.Add(FVector(attachmentVertices[j], depthOffset, attachmentVertices[j + 1]));
 			vertices.Add(FVector(attachmentVertices[j], depthOffset, attachmentVertices[j + 1]));
+			normals.Add(FVector(0, -1, 0));
 			uvs.Add(FVector2D(attachmentUvs[j], attachmentUvs[j + 1]));
 			uvs.Add(FVector2D(attachmentUvs[j], attachmentUvs[j + 1]));
 		}
 		}
 
 
@@ -332,7 +335,7 @@ void USpineSkeletonRendererComponent::UpdateMesh(Skeleton* Skeleton) {
 		clipper.clipEnd(*slot);			
 		clipper.clipEnd(*slot);			
 	}
 	}
 	
 	
-	Flush(meshSection, vertices, indices, uvs, colors, darkColors, lastMaterial);
+	Flush(meshSection, vertices, indices, normals, uvs, colors, darkColors, lastMaterial);
 	clipper.clipEnd();
 	clipper.clipEnd();
 }
 }
 
 

+ 1 - 1
spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Public/SpineSkeletonRendererComponent.h

@@ -97,7 +97,7 @@ public:
 protected:
 protected:
 	void UpdateMesh (spine::Skeleton* Skeleton);
 	void UpdateMesh (spine::Skeleton* Skeleton);
 
 
-	void Flush (int &Idx, TArray<FVector> &Vertices, TArray<int32> &Indices, TArray<FVector2D> &Uvs, TArray<FColor> &Colors, TArray<FVector> &Colors2, UMaterialInstanceDynamic* Material);
+	void Flush (int &Idx, TArray<FVector> &Vertices, TArray<int32> &Indices, TArray<FVector> &Normals, TArray<FVector2D> &Uvs, TArray<FColor> &Colors, TArray<FVector> &Colors2, UMaterialInstanceDynamic* Material);
 	
 	
 	spine::Vector<float> worldVertices;
 	spine::Vector<float> worldVertices;
 	spine::SkeletonClipping clipper;
 	spine::SkeletonClipping clipper;