mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-24 10:41:24 +08:00
Merge branch '4.1' into 4.2-beta
This commit is contained in:
commit
9cef3b443a
@ -194,106 +194,106 @@ export class Shader implements Disposable, Restorable {
|
|||||||
|
|
||||||
public static newColoredTextured (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
public static newColoredTextured (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
||||||
let vs = `
|
let vs = `
|
||||||
attribute vec4 ${Shader.POSITION};
|
attribute vec4 ${Shader.POSITION};
|
||||||
attribute vec4 ${Shader.COLOR};
|
attribute vec4 ${Shader.COLOR};
|
||||||
attribute vec2 ${Shader.TEXCOORDS};
|
attribute vec2 ${Shader.TEXCOORDS};
|
||||||
uniform mat4 ${Shader.MVP_MATRIX};
|
uniform mat4 ${Shader.MVP_MATRIX};
|
||||||
varying vec4 v_color;
|
varying vec4 v_color;
|
||||||
varying vec2 v_texCoords;
|
varying vec2 v_texCoords;
|
||||||
|
|
||||||
void main () {
|
void main () {
|
||||||
v_color = ${Shader.COLOR};
|
v_color = ${Shader.COLOR};
|
||||||
v_texCoords = ${Shader.TEXCOORDS};
|
v_texCoords = ${Shader.TEXCOORDS};
|
||||||
gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
let fs = `
|
let fs = `
|
||||||
#ifdef GL_ES
|
#ifdef GL_ES
|
||||||
#define LOWP lowp
|
#define LOWP lowp
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
#else
|
#else
|
||||||
#define LOWP
|
#define LOWP
|
||||||
#endif
|
#endif
|
||||||
varying LOWP vec4 v_color;
|
varying LOWP vec4 v_color;
|
||||||
varying vec2 v_texCoords;
|
varying vec2 v_texCoords;
|
||||||
uniform sampler2D u_texture;
|
uniform sampler2D u_texture;
|
||||||
|
|
||||||
void main () {
|
void main () {
|
||||||
gl_FragColor = v_color * texture2D(u_texture, v_texCoords);
|
gl_FragColor = v_color * texture2D(u_texture, v_texCoords);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
return new Shader(context, vs, fs);
|
return new Shader(context, vs, fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static newTwoColoredTextured (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
public static newTwoColoredTextured (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
||||||
let vs = `
|
let vs = `
|
||||||
attribute vec4 ${Shader.POSITION};
|
attribute vec4 ${Shader.POSITION};
|
||||||
attribute vec4 ${Shader.COLOR};
|
attribute vec4 ${Shader.COLOR};
|
||||||
attribute vec4 ${Shader.COLOR2};
|
attribute vec4 ${Shader.COLOR2};
|
||||||
attribute vec2 ${Shader.TEXCOORDS};
|
attribute vec2 ${Shader.TEXCOORDS};
|
||||||
uniform mat4 ${Shader.MVP_MATRIX};
|
uniform mat4 ${Shader.MVP_MATRIX};
|
||||||
varying vec4 v_light;
|
varying vec4 v_light;
|
||||||
varying vec4 v_dark;
|
varying vec4 v_dark;
|
||||||
varying vec2 v_texCoords;
|
varying vec2 v_texCoords;
|
||||||
|
|
||||||
void main () {
|
void main () {
|
||||||
v_light = ${Shader.COLOR};
|
v_light = ${Shader.COLOR};
|
||||||
v_dark = ${Shader.COLOR2};
|
v_dark = ${Shader.COLOR2};
|
||||||
v_texCoords = ${Shader.TEXCOORDS};
|
v_texCoords = ${Shader.TEXCOORDS};
|
||||||
gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
let fs = `
|
let fs = `
|
||||||
#ifdef GL_ES
|
#ifdef GL_ES
|
||||||
#define LOWP lowp
|
#define LOWP lowp
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
#else
|
#else
|
||||||
#define LOWP
|
#define LOWP
|
||||||
#endif
|
#endif
|
||||||
varying LOWP vec4 v_light;
|
varying LOWP vec4 v_light;
|
||||||
varying LOWP vec4 v_dark;
|
varying LOWP vec4 v_dark;
|
||||||
varying vec2 v_texCoords;
|
varying vec2 v_texCoords;
|
||||||
uniform sampler2D u_texture;
|
uniform sampler2D u_texture;
|
||||||
|
|
||||||
void main () {
|
void main () {
|
||||||
vec4 texColor = texture2D(u_texture, v_texCoords);
|
vec4 texColor = texture2D(u_texture, v_texCoords);
|
||||||
gl_FragColor.a = texColor.a * v_light.a;
|
gl_FragColor.a = texColor.a * v_light.a;
|
||||||
gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
|
gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
return new Shader(context, vs, fs);
|
return new Shader(context, vs, fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static newColored (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
public static newColored (context: ManagedWebGLRenderingContext | WebGLRenderingContext): Shader {
|
||||||
let vs = `
|
let vs = `
|
||||||
attribute vec4 ${Shader.POSITION};
|
attribute vec4 ${Shader.POSITION};
|
||||||
attribute vec4 ${Shader.COLOR};
|
attribute vec4 ${Shader.COLOR};
|
||||||
uniform mat4 ${Shader.MVP_MATRIX};
|
uniform mat4 ${Shader.MVP_MATRIX};
|
||||||
varying vec4 v_color;
|
varying vec4 v_color;
|
||||||
|
|
||||||
void main () {
|
void main () {
|
||||||
v_color = ${Shader.COLOR};
|
v_color = ${Shader.COLOR};
|
||||||
gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
gl_Position = ${Shader.MVP_MATRIX} * ${Shader.POSITION};
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
let fs = `
|
let fs = `
|
||||||
#ifdef GL_ES
|
#ifdef GL_ES
|
||||||
#define LOWP lowp
|
#define LOWP lowp
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
#else
|
#else
|
||||||
#define LOWP
|
#define LOWP
|
||||||
#endif
|
#endif
|
||||||
varying LOWP vec4 v_color;
|
varying LOWP vec4 v_color;
|
||||||
|
|
||||||
void main () {
|
void main () {
|
||||||
gl_FragColor = v_color;
|
gl_FragColor = v_color;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
return new Shader(context, vs, fs);
|
return new Shader(context, vs, fs);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,7 +135,6 @@ void USpineSkeletonRendererComponent::UpdateMaterial(UTexture2D *Texture, UMater
|
|||||||
material->SetTextureParameterValue(TextureParameterName, Texture);
|
material->SetTextureParameterValue(TextureParameterName, Texture);
|
||||||
CurrentInstance = material;
|
CurrentInstance = material;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void USpineSkeletonRendererComponent::Flush(int &Idx, TArray<FVector> &Vertices, TArray<int32> &Indices, TArray<FVector> &Normals, TArray<FVector2D> &Uvs, TArray<FColor> &Colors, UMaterialInstanceDynamic *Material) {
|
void USpineSkeletonRendererComponent::Flush(int &Idx, TArray<FVector> &Vertices, TArray<int32> &Indices, TArray<FVector> &Normals, TArray<FVector2D> &Uvs, TArray<FColor> &Colors, UMaterialInstanceDynamic *Material) {
|
||||||
@ -167,13 +166,13 @@ void USpineSkeletonRendererComponent::UpdateMesh(USpineSkeletonComponent *compon
|
|||||||
normals.Empty();
|
normals.Empty();
|
||||||
uvs.Empty();
|
uvs.Empty();
|
||||||
colors.Empty();
|
colors.Empty();
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
int meshSection = 0;
|
int meshSection = 0;
|
||||||
UMaterialInstanceDynamic *lastMaterial = nullptr;
|
UMaterialInstanceDynamic *lastMaterial = nullptr;
|
||||||
|
|
||||||
ClearAllMeshSections();
|
ClearAllMeshSections();
|
||||||
|
|
||||||
// Early out if skeleton is invisible
|
// Early out if skeleton is invisible
|
||||||
if (Skeleton->getColor().a == 0) return;
|
if (Skeleton->getColor().a == 0) return;
|
||||||
|
|
||||||
@ -226,13 +225,13 @@ void USpineSkeletonRendererComponent::UpdateMesh(USpineSkeletonComponent *compon
|
|||||||
numIndices = 6;
|
numIndices = 6;
|
||||||
} else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
|
} else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
|
||||||
MeshAttachment *mesh = (MeshAttachment *) attachment;
|
MeshAttachment *mesh = (MeshAttachment *) attachment;
|
||||||
|
|
||||||
// Early out if region is invisible
|
// Early out if region is invisible
|
||||||
if (mesh->getColor().a == 0) {
|
if (mesh->getColor().a == 0) {
|
||||||
clipper.clipEnd(*slot);
|
clipper.clipEnd(*slot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
attachmentColor.set(mesh->getColor());
|
attachmentColor.set(mesh->getColor());
|
||||||
attachmentVertices->setSize(mesh->getWorldVerticesLength(), 0);
|
attachmentVertices->setSize(mesh->getWorldVerticesLength(), 0);
|
||||||
mesh->computeWorldVertices(*slot, 0, mesh->getWorldVerticesLength(), attachmentVertices->buffer(), 0, 2);
|
mesh->computeWorldVertices(*slot, 0, mesh->getWorldVerticesLength(), attachmentVertices->buffer(), 0, 2);
|
||||||
@ -259,14 +258,14 @@ void USpineSkeletonRendererComponent::UpdateMesh(USpineSkeletonComponent *compon
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the user switches the atlas data while not having switched
|
// if the user switches the atlas data while not having switched
|
||||||
// to the correct skeleton data yet, we won't find any regions.
|
// to the correct skeleton data yet, we won't find any regions.
|
||||||
// ignore regions for which we can't find a material
|
// ignore regions for which we can't find a material
|
||||||
UMaterialInstanceDynamic* material = nullptr;
|
UMaterialInstanceDynamic *material = nullptr;
|
||||||
int foundPageIndex = -1;
|
int foundPageIndex = -1;
|
||||||
for (int pageIndex = 0; i < component->Atlas->atlasPages.Num(); pageIndex++) {
|
for (int pageIndex = 0; i < component->Atlas->atlasPages.Num(); pageIndex++) {
|
||||||
AtlasPage* page = component->Atlas->GetAtlas()->getPages()[pageIndex];
|
AtlasPage *page = component->Atlas->GetAtlas()->getPages()[pageIndex];
|
||||||
if (attachmentAtlasRegion->page == page) {
|
if (attachmentAtlasRegion->page == page) {
|
||||||
foundPageIndex = pageIndex;
|
foundPageIndex = pageIndex;
|
||||||
break;
|
break;
|
||||||
@ -277,74 +276,74 @@ void USpineSkeletonRendererComponent::UpdateMesh(USpineSkeletonComponent *compon
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
switch (slot->getData().getBlendMode()) {
|
switch (slot->getData().getBlendMode()) {
|
||||||
case BlendMode_Additive:
|
case BlendMode_Additive:
|
||||||
if (i >= atlasAdditiveBlendMaterials.Num()) {
|
if (i >= atlasAdditiveBlendMaterials.Num()) {
|
||||||
clipper.clipEnd(*slot);
|
clipper.clipEnd(*slot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
material = atlasAdditiveBlendMaterials[i];
|
material = atlasAdditiveBlendMaterials[i];
|
||||||
break;
|
break;
|
||||||
case BlendMode_Multiply:
|
case BlendMode_Multiply:
|
||||||
if (i >= atlasMultiplyBlendMaterials.Num()) {
|
if (i >= atlasMultiplyBlendMaterials.Num()) {
|
||||||
clipper.clipEnd(*slot);
|
clipper.clipEnd(*slot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
material = atlasMultiplyBlendMaterials[i];
|
material = atlasMultiplyBlendMaterials[i];
|
||||||
break;
|
break;
|
||||||
case BlendMode_Screen:
|
case BlendMode_Screen:
|
||||||
if (i >= atlasScreenBlendMaterials.Num()) {
|
if (i >= atlasScreenBlendMaterials.Num()) {
|
||||||
clipper.clipEnd(*slot);
|
clipper.clipEnd(*slot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
material = atlasScreenBlendMaterials[i];
|
material = atlasScreenBlendMaterials[i];
|
||||||
break;
|
break;
|
||||||
case BlendMode_Normal:
|
case BlendMode_Normal:
|
||||||
default:
|
default:
|
||||||
if (i >= atlasNormalBlendMaterials.Num()) {
|
if (i >= atlasNormalBlendMaterials.Num()) {
|
||||||
clipper.clipEnd(*slot);
|
clipper.clipEnd(*slot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
material = atlasNormalBlendMaterials[i];
|
material = atlasNormalBlendMaterials[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastMaterial != material) {
|
if (lastMaterial != material) {
|
||||||
Flush(meshSection, vertices, indices, normals, uvs, colors, lastMaterial);
|
Flush(meshSection, vertices, indices, normals, uvs, colors, lastMaterial);
|
||||||
lastMaterial = material;
|
lastMaterial = material;
|
||||||
idx = 0;
|
idx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMaterial(meshSection, material);
|
SetMaterial(meshSection, material);
|
||||||
|
|
||||||
uint8 r = static_cast<uint8>(Skeleton->getColor().r * slot->getColor().r * attachmentColor.r * 255);
|
uint8 r = static_cast<uint8>(Skeleton->getColor().r * slot->getColor().r * attachmentColor.r * 255);
|
||||||
uint8 g = static_cast<uint8>(Skeleton->getColor().g * slot->getColor().g * attachmentColor.g * 255);
|
uint8 g = static_cast<uint8>(Skeleton->getColor().g * slot->getColor().g * attachmentColor.g * 255);
|
||||||
uint8 b = static_cast<uint8>(Skeleton->getColor().b * slot->getColor().b * attachmentColor.b * 255);
|
uint8 b = static_cast<uint8>(Skeleton->getColor().b * slot->getColor().b * attachmentColor.b * 255);
|
||||||
uint8 a = static_cast<uint8>(Skeleton->getColor().a * slot->getColor().a * attachmentColor.a * 255);
|
uint8 a = static_cast<uint8>(Skeleton->getColor().a * slot->getColor().a * attachmentColor.a * 255);
|
||||||
|
|
||||||
float* verticesPtr = attachmentVertices->buffer();
|
float *verticesPtr = attachmentVertices->buffer();
|
||||||
for (int j = 0; j < numVertices << 1; j += 2) {
|
for (int j = 0; j < numVertices << 1; j += 2) {
|
||||||
colors.Add(FColor(r, g, b, a));
|
colors.Add(FColor(r, g, b, a));
|
||||||
vertices.Add(FVector(verticesPtr[j], depthOffset, verticesPtr[j + 1]));
|
vertices.Add(FVector(verticesPtr[j], depthOffset, verticesPtr[j + 1]));
|
||||||
uvs.Add(FVector2D(attachmentUvs[j], attachmentUvs[j + 1]));
|
uvs.Add(FVector2D(attachmentUvs[j], attachmentUvs[j + 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < numIndices; j++) {
|
for (int j = 0; j < numIndices; j++) {
|
||||||
indices.Add(idx + attachmentIndices[j]);
|
indices.Add(idx + attachmentIndices[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int numTriangles = indices.Num() / 3;
|
int numTriangles = indices.Num() / 3;
|
||||||
for (int j = 0; j < numTriangles; j++) {
|
for (int j = 0; j < numTriangles; j++) {
|
||||||
const int triangleIndex = j * 3;
|
const int triangleIndex = j * 3;
|
||||||
if (FVector::CrossProduct(
|
if (FVector::CrossProduct(
|
||||||
vertices[indices[triangleIndex + 2]] - vertices[indices[triangleIndex]],
|
vertices[indices[triangleIndex + 2]] - vertices[indices[triangleIndex]],
|
||||||
vertices[indices[triangleIndex + 1]] - vertices[indices[triangleIndex]])
|
vertices[indices[triangleIndex + 1]] - vertices[indices[triangleIndex]])
|
||||||
.Y < 0.f) {
|
.Y < 0.f) {
|
||||||
const int32 targetVertex = indices[triangleIndex];
|
const int32 targetVertex = indices[triangleIndex];
|
||||||
indices[triangleIndex] = indices[triangleIndex + 2];
|
indices[triangleIndex] = indices[triangleIndex + 2];
|
||||||
indices[triangleIndex + 2] = targetVertex;
|
indices[triangleIndex + 2] = targetVertex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FVector normal = FVector(0, 1, 0);
|
FVector normal = FVector(0, 1, 0);
|
||||||
for (int j = 0; j < numVertices; j++) {
|
for (int j = 0; j < numVertices; j++) {
|
||||||
normals.Add(normal);
|
normals.Add(normal);
|
||||||
|
|||||||
@ -331,12 +331,12 @@ bool USpineWidget::HasBone(const FString BoneName) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FTransform USpineWidget::GetBoneTransform(const FString& BoneName) {
|
FTransform USpineWidget::GetBoneTransform(const FString &BoneName) {
|
||||||
CheckState();
|
CheckState();
|
||||||
if (skeleton) {
|
if (skeleton) {
|
||||||
Bone *bone = skeleton->findBone(TCHAR_TO_UTF8(*BoneName));
|
Bone *bone = skeleton->findBone(TCHAR_TO_UTF8(*BoneName));
|
||||||
if (!bone) return FTransform();
|
if (!bone) return FTransform();
|
||||||
|
|
||||||
FMatrix localTransform;
|
FMatrix localTransform;
|
||||||
localTransform.SetIdentity();
|
localTransform.SetIdentity();
|
||||||
localTransform.SetAxis(2, FVector(bone->getA(), 0, bone->getC()));
|
localTransform.SetAxis(2, FVector(bone->getA(), 0, bone->getC()));
|
||||||
|
|||||||
@ -99,15 +99,15 @@ protected:
|
|||||||
|
|
||||||
spine::Vector<float> worldVertices;
|
spine::Vector<float> worldVertices;
|
||||||
spine::SkeletonClipping clipper;
|
spine::SkeletonClipping clipper;
|
||||||
|
|
||||||
UPROPERTY();
|
UPROPERTY();
|
||||||
TArray<FVector> vertices;
|
TArray<FVector> vertices;
|
||||||
UPROPERTY();
|
UPROPERTY();
|
||||||
TArray<int32> indices;
|
TArray<int32> indices;
|
||||||
UPROPERTY();
|
UPROPERTY();
|
||||||
TArray<FVector> normals;
|
TArray<FVector> normals;
|
||||||
UPROPERTY();
|
UPROPERTY();
|
||||||
TArray<FVector2D> uvs;
|
TArray<FVector2D> uvs;
|
||||||
UPROPERTY();
|
UPROPERTY();
|
||||||
TArray<FColor> colors;
|
TArray<FColor> colors;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -101,7 +101,7 @@ half4 CombinedShapeLightFragment(VertexOutputSpriteURP2D input) : SV_Target
|
|||||||
surfaceData.albedo = main.rgb;
|
surfaceData.albedo = main.rgb;
|
||||||
surfaceData.alpha = 1;
|
surfaceData.alpha = 1;
|
||||||
surfaceData.mask = mask;
|
surfaceData.mask = mask;
|
||||||
inputData.uv = input.texcoord;
|
inputData.uv = input.texcoord.xy;
|
||||||
inputData.lightingUV = input.lightingUV;
|
inputData.lightingUV = input.lightingUV;
|
||||||
half4 pixel = half4(CombinedShapeLightShared(surfaceData, inputData).rgb * main.a, main.a);
|
half4 pixel = half4(CombinedShapeLightShared(surfaceData, inputData).rgb * main.a, main.a);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -65,7 +65,7 @@ half3 LightweightLightVertexSimplified(float3 positionWS, half3 normalWS, out ha
|
|||||||
additionalLightColor += ProcessLight(positionWS, normalWS, meshRenderingLayers, lightIndex);
|
additionalLightColor += ProcessLight(positionWS, normalWS, meshRenderingLayers, lightIndex);
|
||||||
}
|
}
|
||||||
#else // !USE_FORWARD_PLUS
|
#else // !USE_FORWARD_PLUS
|
||||||
int pixelLightCount = GetAdditionalLightsCount();
|
uint pixelLightCount = GetAdditionalLightsCount();
|
||||||
LIGHT_LOOP_BEGIN_SPINE(pixelLightCount)
|
LIGHT_LOOP_BEGIN_SPINE(pixelLightCount)
|
||||||
additionalLightColor += ProcessLight(positionWS, normalWS, meshRenderingLayers, lightIndex);
|
additionalLightColor += ProcessLight(positionWS, normalWS, meshRenderingLayers, lightIndex);
|
||||||
LIGHT_LOOP_END_SPINE
|
LIGHT_LOOP_END_SPINE
|
||||||
@ -84,9 +84,9 @@ half3 LightweightLightFragmentSimplified(float3 positionWS, float2 positionCS, h
|
|||||||
InputData inputData; // LIGHT_LOOP_BEGIN macro requires InputData struct in USE_FORWARD_PLUS branch
|
InputData inputData; // LIGHT_LOOP_BEGIN macro requires InputData struct in USE_FORWARD_PLUS branch
|
||||||
inputData.positionWS = positionWS;
|
inputData.positionWS = positionWS;
|
||||||
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(positionCS);
|
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(positionCS);
|
||||||
|
|
||||||
uint meshRenderingLayers = GetMeshRenderingLayerBackwardsCompatible();
|
uint meshRenderingLayers = GetMeshRenderingLayerBackwardsCompatible();
|
||||||
int pixelLightCount = GetAdditionalLightsCount();
|
uint pixelLightCount = GetAdditionalLightsCount();
|
||||||
LIGHT_LOOP_BEGIN_SPINE(pixelLightCount)
|
LIGHT_LOOP_BEGIN_SPINE(pixelLightCount)
|
||||||
additionalLightColor += ProcessLight(positionWS, normalWS, meshRenderingLayers, lightIndex);
|
additionalLightColor += ProcessLight(positionWS, normalWS, meshRenderingLayers, lightIndex);
|
||||||
LIGHT_LOOP_END_SPINE
|
LIGHT_LOOP_END_SPINE
|
||||||
@ -124,7 +124,7 @@ VertexOutput vert(appdata v) {
|
|||||||
if (color.a == 0) {
|
if (color.a == 0) {
|
||||||
o.color = color;
|
o.color = color;
|
||||||
#if defined(SKELETONLIT_RECEIVE_SHADOWS)
|
#if defined(SKELETONLIT_RECEIVE_SHADOWS)
|
||||||
o.shadowedColor = color;
|
o.shadowedColor = color.rgb;
|
||||||
o.shadowCoord = float4(0, 0, 0, 0);
|
o.shadowCoord = float4(0, 0, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
return o;
|
return o;
|
||||||
@ -169,9 +169,11 @@ half4 frag(VertexOutput i
|
|||||||
// USE_FORWARD_PLUS lights need to be processed in fragment shader,
|
// USE_FORWARD_PLUS lights need to be processed in fragment shader,
|
||||||
// otherwise light culling by vertex will create a very bad lighting result.
|
// otherwise light culling by vertex will create a very bad lighting result.
|
||||||
half3 shadowedColor;
|
half3 shadowedColor;
|
||||||
i.color.rgb += LightweightLightFragmentSimplified(i.positionWS, i.pos, i.normalWS, shadowedColor);
|
i.color.rgb += LightweightLightFragmentSimplified(i.positionWS, i.pos.xy, i.normalWS, shadowedColor);
|
||||||
|
#if defined(SKELETONLIT_RECEIVE_SHADOWS)
|
||||||
i.shadowedColor += shadowedColor;
|
i.shadowedColor += shadowedColor;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(SKELETONLIT_RECEIVE_SHADOWS)
|
#if defined(SKELETONLIT_RECEIVE_SHADOWS)
|
||||||
half shadowAttenuation = MainLightRealtimeShadow(i.shadowCoord);
|
half shadowAttenuation = MainLightRealtimeShadow(i.shadowCoord);
|
||||||
|
|||||||
@ -131,7 +131,7 @@ half4 LightweightFragmentPBRSimplified(InputData inputData, half4 texAlbedoAlpha
|
|||||||
|
|
||||||
#ifdef _ADDITIONAL_LIGHTS
|
#ifdef _ADDITIONAL_LIGHTS
|
||||||
uint meshRenderingLayers = GetMeshRenderingLayerBackwardsCompatible();
|
uint meshRenderingLayers = GetMeshRenderingLayerBackwardsCompatible();
|
||||||
|
|
||||||
#if defined(_ADDITIONAL_LIGHT_SHADOWS) && !defined(_RECEIVE_SHADOWS_OFF)
|
#if defined(_ADDITIONAL_LIGHT_SHADOWS) && !defined(_RECEIVE_SHADOWS_OFF)
|
||||||
half4 shadowMask = CalculateShadowMaskBackwardsCompatible(inputData);
|
half4 shadowMask = CalculateShadowMaskBackwardsCompatible(inputData);
|
||||||
#else
|
#else
|
||||||
@ -145,7 +145,7 @@ half4 LightweightFragmentPBRSimplified(InputData inputData, half4 texAlbedoAlpha
|
|||||||
finalColor += ProcessLightPBRSimplified(inputData, brdfData, shadowMask, meshRenderingLayers, lightIndex);
|
finalColor += ProcessLightPBRSimplified(inputData, brdfData, shadowMask, meshRenderingLayers, lightIndex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
int pixelLightCount = GetAdditionalLightsCount();
|
uint pixelLightCount = GetAdditionalLightsCount();
|
||||||
LIGHT_LOOP_BEGIN_SPINE(pixelLightCount)
|
LIGHT_LOOP_BEGIN_SPINE(pixelLightCount)
|
||||||
finalColor += ProcessLightPBRSimplified(inputData, brdfData, shadowMask, meshRenderingLayers, lightIndex);
|
finalColor += ProcessLightPBRSimplified(inputData, brdfData, shadowMask, meshRenderingLayers, lightIndex);
|
||||||
LIGHT_LOOP_END_SPINE
|
LIGHT_LOOP_END_SPINE
|
||||||
@ -221,11 +221,11 @@ half4 LightweightFragmentBlinnPhongSimplified(InputData inputData, half4 texDiff
|
|||||||
diffuseLighting += ProcessLightLambert(inputData, shadowMask, meshRenderingLayers, lightIndex);
|
diffuseLighting += ProcessLightLambert(inputData, shadowMask, meshRenderingLayers, lightIndex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
int pixelLightCount = GetAdditionalLightsCount();
|
uint pixelLightCount = GetAdditionalLightsCount();
|
||||||
LIGHT_LOOP_BEGIN(pixelLightCount)
|
LIGHT_LOOP_BEGIN(pixelLightCount)
|
||||||
diffuseLighting += ProcessLightLambert(inputData, shadowMask, meshRenderingLayers, lightIndex);
|
diffuseLighting += ProcessLightLambert(inputData, shadowMask, meshRenderingLayers, lightIndex);
|
||||||
LIGHT_LOOP_END
|
LIGHT_LOOP_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
#ifdef _ADDITIONAL_LIGHTS_VERTEX
|
||||||
diffuseLighting += inputData.vertexLighting;
|
diffuseLighting += inputData.vertexLighting;
|
||||||
@ -329,7 +329,7 @@ half4 ForwardPassFragmentSprite(VertexOutputLWRP input
|
|||||||
#else
|
#else
|
||||||
inputData.normalizedScreenSpaceUV = 0;
|
inputData.normalizedScreenSpaceUV = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SPECULAR)
|
#if defined(SPECULAR)
|
||||||
half2 metallicGloss = getMetallicGloss(input.texcoord.xy);
|
half2 metallicGloss = getMetallicGloss(input.texcoord.xy);
|
||||||
half metallic = metallicGloss.x;
|
half metallic = metallicGloss.x;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "com.esotericsoftware.spine.urp-shaders",
|
"name": "com.esotericsoftware.spine.urp-shaders",
|
||||||
"displayName": "Spine Universal RP Shaders",
|
"displayName": "Spine Universal RP Shaders",
|
||||||
"description": "This plugin provides universal render pipeline (URP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 4.1.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
|
"description": "This plugin provides universal render pipeline (URP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 4.1.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
|
||||||
"version": "4.1.8",
|
"version": "4.1.9",
|
||||||
"unity": "2019.3",
|
"unity": "2019.3",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Esoteric Software",
|
"name": "Esoteric Software",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user