[ue4] Using packed vertex format, implemented two color tint in test material.

This commit is contained in:
badlogic 2017-05-23 14:26:34 +02:00
parent 53d80a4020
commit 8ae6f56294
5 changed files with 13 additions and 8 deletions

Binary file not shown.

View File

@ -7,6 +7,7 @@
// Finish all the built in vertex types. // Finish all the built in vertex types.
DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexSimple); DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexSimple);
DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexDualUV); DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexDualUV);
DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexTripleUV);
DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexNoPosition); DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexNoPosition);
DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexNoPositionDualUV); DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexNoPositionDualUV);
DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexHiPrecisionNormals); DEFINE_RUNTIME_MESH_VERTEX(FRuntimeMeshVertexHiPrecisionNormals);
@ -21,7 +22,8 @@ const FRuntimeMeshVertexTypeInfo* FRuntimeMeshComponentVerticesBuilder::GetVerte
{ {
if (HasUVComponent(1)) if (HasUVComponent(1))
{ {
return &FRuntimeMeshVertexDualUV::TypeInfo; if (HasUVComponent(2)) return &FRuntimeMeshVertexTripleUV::TypeInfo;
else return &FRuntimeMeshVertexDualUV::TypeInfo;
} }
else else
{ {

View File

@ -1249,6 +1249,9 @@ DECLARE_RUNTIME_MESH_VERTEXINTERNAL(FRuntimeMeshVertexSimple, true, true, true,
/** Simple vertex with 2 UV channels */ /** Simple vertex with 2 UV channels */
DECLARE_RUNTIME_MESH_VERTEXINTERNAL(FRuntimeMeshVertexDualUV, true, true, true, true, 2, ERuntimeMeshVertexTangentBasisType::Default, ERuntimeMeshVertexUVType::HighPrecision, RUNTIMEMESHCOMPONENT_API) DECLARE_RUNTIME_MESH_VERTEXINTERNAL(FRuntimeMeshVertexDualUV, true, true, true, true, 2, ERuntimeMeshVertexTangentBasisType::Default, ERuntimeMeshVertexUVType::HighPrecision, RUNTIMEMESHCOMPONENT_API)
/** Simple vertex with 3 UV channels */
DECLARE_RUNTIME_MESH_VERTEXINTERNAL(FRuntimeMeshVertexTripleUV, true, true, true, true, 3, ERuntimeMeshVertexTangentBasisType::Default, ERuntimeMeshVertexUVType::HighPrecision, RUNTIMEMESHCOMPONENT_API)
/** Simple vertex with 1 UV channel and NO position component (Meant to be used with separate position buffer) */ /** Simple vertex with 1 UV channel and NO position component (Meant to be used with separate position buffer) */
DECLARE_RUNTIME_MESH_VERTEXINTERNAL(FRuntimeMeshVertexNoPosition, false, true, true, true, 1, ERuntimeMeshVertexTangentBasisType::Default, ERuntimeMeshVertexUVType::HighPrecision, RUNTIMEMESHCOMPONENT_API) DECLARE_RUNTIME_MESH_VERTEXINTERNAL(FRuntimeMeshVertexNoPosition, false, true, true, true, 1, ERuntimeMeshVertexTangentBasisType::Default, ERuntimeMeshVertexUVType::HighPrecision, RUNTIMEMESHCOMPONENT_API)

View File

@ -169,19 +169,19 @@ void USpineSkeletonRendererComponent::TickComponent (float DeltaTime, ELevelTick
} }
} }
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<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);
TArray<FVector2D> darkRG;
TArray<FVector2D> darkB;
for (int32 i = 0; i < Colors2.Num(); i++) { TArray<FRuntimeMeshVertexTripleUV> verts;
FVector darkColor = Colors2[i]; for (int32 i = 0; i < Vertices.Num(); i++) {
darkRG.Add(FVector2D(darkColor.X, darkColor.Y)); verts.Add(FRuntimeMeshVertexTripleUV(Vertices[i], FVector(), FVector(), Colors[i], Uvs[i], FVector2D(Colors2[i].X, Colors2[i].Y), FVector2D(Colors2[i].Z, 0)));
darkB.Add(FVector2D(darkColor.Z, 0));
} }
CreateMeshSection(Idx, Vertices, Indices, TArray<FVector>(), Uvs, darkRG, Colors, TArray<FRuntimeMeshTangent>(), false); CreateMeshSection(Idx, verts, Indices);
// CreateMeshSection(Idx, Vertices, Indices, TArray<FVector>(), Uvs, darkRG, Colors, TArray<FRuntimeMeshTangent>(), false);
Vertices.SetNum(0); Vertices.SetNum(0);
Indices.SetNum(0); Indices.SetNum(0);
Uvs.SetNum(0); Uvs.SetNum(0);