[ue4] First steps toward two color tint

This commit is contained in:
badlogic 2017-05-22 19:34:58 +02:00
parent 4b4c3aba22
commit 0dc67709d2
10 changed files with 175 additions and 4 deletions

Binary file not shown.

View File

@ -0,0 +1,13 @@
TwoColorTest.png
size: 512,512
format: RGBA8888
filter: Linear,Linear
repeat: none
squareWithBorder
rotate: false
xy: 2, 2
size: 300, 300
orig: 300, 300
offset: 0, 0
index: -1

View File

@ -0,0 +1,150 @@
{
"skeleton": { "hash": "5Oji/z9A5lQ/crlH60repeTNBg8", "spine": "3.6.07-beta", "width": 1588, "height": 732, "images": "" },
"bones": [
{ "name": "root" },
{ "name": "singleColorTint", "parent": "root", "x": -400 },
{ "name": "singleColorTint2", "parent": "root", "x": -400, "y": -383 },
{ "name": "twoColorTint", "parent": "root", "x": 800 },
{ "name": "twoColorTint2", "parent": "root", "x": 800, "y": -382 },
{ "name": "twoColorTint (blackOnly)", "parent": "root" },
{ "name": "twoColorTint (blackOnly)2", "parent": "root", "y": -391 },
{ "name": "twoColorTint (colorOnly)", "parent": "root", "x": 400 },
{ "name": "twoColorTint (colorOnly)2", "parent": "root", "x": 400, "y": -382 }
],
"slots": [
{ "name": "squareWithBorder", "bone": "singleColorTint", "attachment": "squareWithBorder" },
{ "name": "squareWithBorder7", "bone": "singleColorTint2", "attachment": "squareWithBorder" },
{ "name": "squareWithBorder2", "bone": "twoColorTint (blackOnly)", "dark": "000000", "attachment": "squareWithBorder" },
{ "name": "squareWithBorder8", "bone": "twoColorTint (blackOnly)2", "dark": "000000", "attachment": "squareWithBorder" },
{ "name": "squareWithBorder4", "bone": "twoColorTint (colorOnly)", "dark": "000000", "attachment": "squareWithBorder" },
{ "name": "squareWithBorder5", "bone": "twoColorTint (colorOnly)2", "dark": "000000", "attachment": "squareWithBorder" },
{ "name": "squareWithBorder3", "bone": "twoColorTint", "dark": "000000", "attachment": "squareWithBorder" },
{ "name": "squareWithBorder6", "bone": "twoColorTint2", "dark": "000000", "attachment": "squareWithBorder" }
],
"skins": {
"default": {
"squareWithBorder": {
"squareWithBorder": { "width": 300, "height": 300 }
},
"squareWithBorder2": {
"squareWithBorder": { "width": 300, "height": 300 }
},
"squareWithBorder3": {
"squareWithBorder": { "width": 300, "height": 300 }
},
"squareWithBorder4": {
"squareWithBorder": { "width": 300, "height": 300 }
},
"squareWithBorder5": {
"squareWithBorder": {
"type": "mesh",
"uvs": [ 1, 1, 0, 1, 0, 0, 1, 0 ],
"triangles": [ 1, 2, 3, 1, 3, 0 ],
"vertices": [ 150, -150, -150, -150, -197, 99, 183, 155 ],
"hull": 4,
"edges": [ 0, 2, 2, 4, 4, 6, 0, 6 ],
"width": 300,
"height": 300
}
},
"squareWithBorder6": {
"squareWithBorder": {
"type": "mesh",
"uvs": [ 1, 1, 0, 1, 0, 0, 1, 0 ],
"triangles": [ 1, 2, 3, 1, 3, 0 ],
"vertices": [ 238, -200, -191, -60, -150, 150, 119, 111 ],
"hull": 4,
"edges": [ 0, 2, 2, 4, 4, 6, 0, 6 ],
"width": 300,
"height": 300
}
},
"squareWithBorder7": {
"squareWithBorder": {
"type": "mesh",
"uvs": [ 1, 1, 0, 1, 0, 0, 1, 0 ],
"triangles": [ 1, 2, 3, 1, 3, 0 ],
"vertices": [ 210, -132, -150, -150, -150, 150, 124, 119 ],
"hull": 4,
"edges": [ 0, 2, 2, 4, 4, 6, 0, 6 ],
"width": 300,
"height": 300
}
},
"squareWithBorder8": {
"squareWithBorder": {
"type": "mesh",
"uvs": [ 1, 1, 0, 1, 0, 0, 1, 0 ],
"triangles": [ 1, 2, 3, 1, 3, 0 ],
"vertices": [ 150, -150, -150, -150, -97, 58, 86, 62 ],
"hull": 4,
"edges": [ 0, 2, 2, 4, 4, 6, 0, 6 ],
"width": 300,
"height": 300
}
}
}
},
"animations": {
"animation": {
"slots": {
"squareWithBorder": {
"color": [
{ "time": 0, "color": "fffffffe" },
{ "time": 1, "color": "9e17b3fe" },
{ "time": 2, "color": "fffffffe" }
]
},
"squareWithBorder2": {
"twoColor": [
{ "time": 0, "light": "fffffffe", "dark": "000000" },
{ "time": 1, "light": "fffffffe", "dark": "ff0000" },
{ "time": 2, "light": "fffffffe", "dark": "000000" }
]
},
"squareWithBorder3": {
"twoColor": [
{ "time": 0, "light": "fffffffe", "dark": "000000" },
{ "time": 1, "light": "80ff00fe", "dark": "001cff" },
{ "time": 2, "light": "fffffffe", "dark": "000000" }
]
},
"squareWithBorder4": {
"twoColor": [
{ "time": 0, "light": "fffffffe", "dark": "000000" },
{ "time": 1, "light": "ffd300fe", "dark": "000000" },
{ "time": 2, "light": "fffffffe", "dark": "000000" }
]
},
"squareWithBorder5": {
"twoColor": [
{ "time": 0, "light": "fffffffe", "dark": "000000" },
{ "time": 1, "light": "ffd300fe", "dark": "000000" },
{ "time": 2, "light": "fffffffe", "dark": "000000" }
]
},
"squareWithBorder6": {
"twoColor": [
{ "time": 0, "light": "fffffffe", "dark": "000000" },
{ "time": 1, "light": "80ff00fe", "dark": "001cff" },
{ "time": 2, "light": "fffffffe", "dark": "000000" }
]
},
"squareWithBorder7": {
"color": [
{ "time": 0, "color": "fffffffe" },
{ "time": 1, "color": "9e17b3fe" },
{ "time": 2, "color": "fffffffe" }
]
},
"squareWithBorder8": {
"twoColor": [
{ "time": 0, "light": "fffffffe", "dark": "000000" },
{ "time": 1, "light": "fffffffe", "dark": "ff0000" },
{ "time": 2, "light": "fffffffe", "dark": "000000" }
]
}
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Binary file not shown.

View File

@ -171,8 +171,17 @@ 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) {
if (Vertices.Num() == 0) return;
SetMaterial(Idx, Material);
CreateMeshSection(Idx, Vertices, Indices, TArray<FVector>(), Uvs, Colors, TArray<FRuntimeMeshTangent>(), false);
SetMaterial(Idx, Material);
TArray<FVector2D> darkRG;
TArray<FVector2D> darkB;
for (int32 i = 0; i < Colors2.Num(); i++) {
FVector darkColor = Colors2[i];
darkRG.Add(FVector2D(darkColor.X, darkColor.Y));
darkB.Add(FVector2D(darkColor.Z, 0));
}
CreateMeshSection(Idx, Vertices, Indices, TArray<FVector>(), Uvs, darkRG, Colors, TArray<FRuntimeMeshTangent>(), false);
Vertices.SetNum(0);
Indices.SetNum(0);
Uvs.SetNum(0);
@ -288,7 +297,7 @@ void USpineSkeletonRendererComponent::UpdateMesh(spSkeleton* Skeleton) {
float dr = slot->darkColor ? slot->darkColor->r : 0.0f;
float dg = slot->darkColor ? slot->darkColor->g : 0.0f;
float db = slot->darkColor ? slot->darkColor->b : 0.0f;
float db = slot->darkColor ? slot->darkColor->b : 0.0f;
for (int j = 0; j < numVertices << 1; j += 2) {
colors.Add(FColor(r, g, b, a));

View File

@ -31,7 +31,6 @@
#pragma once
#include "Components/ActorComponent.h"
#include "ProceduralMeshComponent.h"
#include "RuntimeMeshComponent.h"
#include "SpineSkeletonAnimationComponent.h"
#include "SpineSkeletonRendererComponent.generated.h"