mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-11 17:48:45 +08:00
[unity] Fixed Shadow alpha cutoff shader parameters ignoring SlotColor.alpha at all Spine shaders. Now the texture color is multiplied with slot color before the alpha test. Closes #1350.
This commit is contained in:
parent
3b17c20c9b
commit
215c12cb22
@ -91,19 +91,20 @@ Shader "Spine/Skeleton Fill" {
|
||||
|
||||
struct VertexOutput {
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 uv : TEXCOORD1;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
VertexOutput vert (appdata_base v) {
|
||||
VertexOutput vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
VertexOutput o;
|
||||
o.uv = v.texcoord;
|
||||
o.uvAndAlpha = v.texcoord;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag (VertexOutput i) : COLOR {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uv);
|
||||
clip(texcol.a - _Cutoff);
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
|
||||
@ -94,19 +94,20 @@ Shader "Spine/Skeleton Tint" {
|
||||
|
||||
struct VertexOutput {
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 uv : TEXCOORD1;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
VertexOutput vert (appdata_base v) {
|
||||
VertexOutput vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
VertexOutput o;
|
||||
o.uv = v.texcoord;
|
||||
o.uvAndAlpha = v.texcoord;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag (VertexOutput i) : COLOR {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uv);
|
||||
clip(texcol.a - _Cutoff);
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
|
||||
@ -91,19 +91,20 @@ Shader "Spine/Special/Skeleton Grayscale" {
|
||||
|
||||
struct VertexOutput {
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 uv : TEXCOORD1;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
VertexOutput vert (appdata_base v) {
|
||||
VertexOutput vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
VertexOutput o;
|
||||
o.uv = v.texcoord;
|
||||
o.uvAndAlpha = v.texcoord;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag (VertexOutput i) : COLOR {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uv);
|
||||
clip(texcol.a - _Cutoff);
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
|
||||
@ -16,18 +16,20 @@ struct vertexInput
|
||||
struct vertexOutput
|
||||
{
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 texcoord : TEXCOORD1;
|
||||
float4 texcoordAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
////////////////////////////////////////
|
||||
// Vertex program
|
||||
//
|
||||
|
||||
vertexOutput vert(vertexInput v)
|
||||
vertexOutput vert(vertexInput v, float4 vertexColor : COLOR)
|
||||
{
|
||||
vertexOutput o;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.texcoord = calculateTextureCoord(v.texcoord);
|
||||
o.texcoordAndAlpha.xy = calculateTextureCoord(v.texcoord);
|
||||
o.texcoordAndAlpha.z = 0;
|
||||
o.texcoordAndAlpha.a = vertexColor.a;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -40,8 +42,8 @@ uniform fixed _ShadowAlphaCutoff;
|
||||
|
||||
fixed4 frag(vertexOutput IN) : COLOR
|
||||
{
|
||||
fixed4 texureColor = calculateTexturePixel(IN.texcoord);
|
||||
clip(texureColor.a - _ShadowAlphaCutoff);
|
||||
fixed4 texureColor = calculateTexturePixel(IN.texcoordAndAlpha.xy);
|
||||
clip(texureColor.a * IN.texcoordAndAlpha.a - _ShadowAlphaCutoff);
|
||||
|
||||
SHADOW_CASTER_FRAGMENT(IN)
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ struct vertexInput
|
||||
struct vertexOutput
|
||||
{
|
||||
V2F_SHADOW_CASTER;
|
||||
float4 texcoord : TEXCOORD1;
|
||||
float4 texcoordAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
////////////////////////////////////////
|
||||
@ -26,11 +26,13 @@ struct vertexOutput
|
||||
uniform sampler2D _MainTex;
|
||||
uniform fixed4 _MainTex_ST;
|
||||
|
||||
vertexOutput vert(vertexInput v)
|
||||
vertexOutput vert(vertexInput v, float4 vertexColor : COLOR)
|
||||
{
|
||||
vertexOutput o;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.texcoord = float4(TRANSFORM_TEX(v.texcoord, _MainTex), 0, 0);
|
||||
o.texcoordAndAlpha.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.texcoordAndAlpha.z = 0;
|
||||
o.texcoordAndAlpha.a = vertexColor.a;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -43,8 +45,8 @@ uniform fixed _ShadowAlphaCutoff;
|
||||
|
||||
fixed4 frag(vertexOutput IN) : COLOR
|
||||
{
|
||||
fixed4 texureColor = tex2D(_MainTex, IN.texcoord.xy);
|
||||
clip(texureColor.a - _ShadowAlphaCutoff);
|
||||
fixed4 texureColor = tex2D(_MainTex, IN.texcoordAndAlpha.xy);
|
||||
clip(texureColor.a * IN.texcoordAndAlpha.a - _ShadowAlphaCutoff);
|
||||
|
||||
SHADOW_CASTER_FRAGMENT(IN)
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ Shader "Spine/Sprite/Unlit"
|
||||
Cull Off
|
||||
Lighting Off
|
||||
|
||||
CGPROGRAM
|
||||
CGPROGRAM
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma multi_compile _ PIXELSNAP_ON
|
||||
|
||||
@ -88,15 +88,17 @@ Shader "Spine/Blend Modes/Skeleton PMA Additive" {
|
||||
#include "UnityCG.cginc"
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 uv : TEXCOORD1;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
uniform float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_base v) {
|
||||
v2f vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
v2f o;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.uvAndAlpha.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.uvAndAlpha.z = 0;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -104,8 +106,8 @@ Shader "Spine/Blend Modes/Skeleton PMA Additive" {
|
||||
uniform fixed _Cutoff;
|
||||
|
||||
float4 frag (v2f i) : COLOR {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uv);
|
||||
clip(texcol.a - _Cutoff);
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
|
||||
@ -88,15 +88,17 @@ Shader "Spine/Blend Modes/Skeleton PMA Multiply" {
|
||||
#include "UnityCG.cginc"
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 uv : TEXCOORD1;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
uniform float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_base v) {
|
||||
v2f vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
v2f o;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.uvAndAlpha.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.uvAndAlpha.z = 0;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -104,8 +106,8 @@ Shader "Spine/Blend Modes/Skeleton PMA Multiply" {
|
||||
uniform fixed _Cutoff;
|
||||
|
||||
float4 frag (v2f i) : COLOR {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uv);
|
||||
clip(texcol.a - _Cutoff);
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
|
||||
@ -88,15 +88,17 @@ Shader "Spine/Blend Modes/Skeleton PMA Screen" {
|
||||
#include "UnityCG.cginc"
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 uv : TEXCOORD1;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
uniform float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_base v) {
|
||||
v2f vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
v2f o;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.uvAndAlpha.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.uvAndAlpha.z = 0;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -104,8 +106,8 @@ Shader "Spine/Blend Modes/Skeleton PMA Screen" {
|
||||
uniform fixed _Cutoff;
|
||||
|
||||
float4 frag (v2f i) : COLOR {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uv);
|
||||
clip(texcol.a - _Cutoff);
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
|
||||
@ -100,19 +100,20 @@ Shader "Spine/Skeleton Tint Black" {
|
||||
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 uv : TEXCOORD1;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
v2f vert (appdata_base v) {
|
||||
v2f vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
v2f o;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.uv = v.texcoord;
|
||||
o.uvAndAlpha = v.texcoord;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag (v2f i) : COLOR {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uv);
|
||||
clip(texcol.a - _Cutoff);
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
|
||||
@ -84,19 +84,20 @@ Shader "Spine/Skeleton" {
|
||||
|
||||
struct VertexOutput {
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 uv : TEXCOORD1;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
VertexOutput vert (appdata_base v) {
|
||||
VertexOutput vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
VertexOutput o;
|
||||
o.uv = v.texcoord;
|
||||
o.uvAndAlpha = v.texcoord;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag (VertexOutput i) : COLOR {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uv);
|
||||
clip(texcol.a - _Cutoff);
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
|
||||
@ -179,15 +179,17 @@ Shader "Spine/Skeleton Lit" {
|
||||
#include "UnityCG.cginc"
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 uv : TEXCOORD1;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
uniform float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_base v) {
|
||||
v2f vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
v2f o;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.uvAndAlpha.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.uvAndAlpha.z = 0;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -195,8 +197,8 @@ Shader "Spine/Skeleton Lit" {
|
||||
uniform fixed _Cutoff;
|
||||
|
||||
float4 frag (v2f i) : COLOR {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uv);
|
||||
clip(texcol.a - _Cutoff);
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user