mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] Fixed Spine/Sprite core shaders now correctly drawing Additive Slots. Closes #1853.
This commit is contained in:
parent
c5c71747c3
commit
47e357aa88
@ -109,16 +109,11 @@ sampler2D _MainTex;
|
|||||||
fixed4 frag (VertexOutput i) : SV_Target {
|
fixed4 frag (VertexOutput i) : SV_Target {
|
||||||
fixed4 tex = tex2D(_MainTex, i.uv0);
|
fixed4 tex = tex2D(_MainTex, i.uv0);
|
||||||
ALPHA_CLIP(tex, i.color);
|
ALPHA_CLIP(tex, i.color);
|
||||||
|
|
||||||
fixed4 col;
|
|
||||||
#if defined(_STRAIGHT_ALPHA_INPUT)
|
#if defined(_STRAIGHT_ALPHA_INPUT)
|
||||||
col.rgb = tex * i.color * tex.a;
|
tex.rgb *= tex.a;
|
||||||
#else
|
|
||||||
col.rgb = tex * i.color;
|
|
||||||
#endif
|
#endif
|
||||||
|
fixed4 col = tex * i.color;
|
||||||
col *= 2;
|
col.rgb *= 2;
|
||||||
col.a = tex.a * i.color.a;
|
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -240,6 +240,20 @@ uniform fixed _Cutoff;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
// Additive Slot blend mode
|
||||||
|
// return unlit textureColor, alpha clip textureColor.a only
|
||||||
|
//
|
||||||
|
#if defined(_ALPHAPREMULTIPLY_ON)
|
||||||
|
#define RETURN_UNLIT_IF_ADDITIVE_SLOT(textureColor, vertexColor) \
|
||||||
|
if (vertexColor.a == 0 && (vertexColor.r || vertexColor.g || vertexColor.b)) {\
|
||||||
|
ALPHA_CLIP(texureColor, fixed4(1, 1, 1, 1))\
|
||||||
|
return texureColor * vertexColor;\
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define RETURN_UNLIT_IF_ADDITIVE_SLOT(textureColor, vertexColor)
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// Color functions
|
// Color functions
|
||||||
//
|
//
|
||||||
|
|||||||
@ -163,10 +163,10 @@ VertexOutput vert(VertexInput v)
|
|||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// Fragment programs
|
// Fragment programs
|
||||||
//
|
//
|
||||||
|
|
||||||
fixed4 fragBase(VertexOutput input) : SV_Target
|
fixed4 fragBase(VertexOutput input) : SV_Target
|
||||||
{
|
{
|
||||||
fixed4 texureColor = calculateTexturePixel(input.texcoord);
|
fixed4 texureColor = calculateTexturePixel(input.texcoord);
|
||||||
|
RETURN_UNLIT_IF_ADDITIVE_SLOT(texureColor, input.color) // shall be called before ALPHA_CLIP
|
||||||
ALPHA_CLIP(texureColor, input.color)
|
ALPHA_CLIP(texureColor, input.color)
|
||||||
|
|
||||||
//Get normal direction
|
//Get normal direction
|
||||||
|
|||||||
@ -52,15 +52,11 @@ VertexOutput vert(VertexInput input)
|
|||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// Fragment program
|
// Fragment program
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fixed4 frag(VertexOutput input) : SV_Target
|
fixed4 frag(VertexOutput input) : SV_Target
|
||||||
{
|
{
|
||||||
fixed4 texureColor = calculateTexturePixel(input.texcoord.xy);
|
fixed4 texureColor = calculateTexturePixel(input.texcoord.xy);
|
||||||
|
RETURN_UNLIT_IF_ADDITIVE_SLOT(texureColor, input.color) // shall be called before ALPHA_CLIP
|
||||||
ALPHA_CLIP(texureColor, input.color)
|
ALPHA_CLIP(texureColor, input.color)
|
||||||
|
|
||||||
fixed4 pixel = calculatePixel(texureColor, input.color);
|
fixed4 pixel = calculatePixel(texureColor, input.color);
|
||||||
|
|
||||||
COLORISE(pixel)
|
COLORISE(pixel)
|
||||||
|
|||||||
@ -399,10 +399,10 @@ VertexOutput vert(VertexInput input)
|
|||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// Fragment program
|
// Fragment program
|
||||||
//
|
//
|
||||||
|
|
||||||
fixed4 frag(VertexOutput input) : SV_Target
|
fixed4 frag(VertexOutput input) : SV_Target
|
||||||
{
|
{
|
||||||
fixed4 texureColor = calculateTexturePixel(input.texcoord.xy);
|
fixed4 texureColor = calculateTexturePixel(input.texcoord.xy);
|
||||||
|
RETURN_UNLIT_IF_ADDITIVE_SLOT(texureColor, input.color) // shall be called before ALPHA_CLIP
|
||||||
ALPHA_CLIP(texureColor, input.color)
|
ALPHA_CLIP(texureColor, input.color)
|
||||||
|
|
||||||
#if defined(PER_PIXEL_LIGHTING)
|
#if defined(PER_PIXEL_LIGHTING)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user