mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[unity] Fixed URP 2D shaders ignoring texture alpha at Additive light blend style. Closes #2250.
This commit is contained in:
parent
11f261ba1f
commit
b64942b257
@ -92,8 +92,9 @@ half4 CombinedShapeLightFragment(VertexOutputSpriteURP2D input) : SV_Target
|
|||||||
half4 main = texureColor * input.vertexColor;
|
half4 main = texureColor * input.vertexColor;
|
||||||
|
|
||||||
half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, input.texcoord.xy);
|
half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, input.texcoord.xy);
|
||||||
|
main.rgb = main.a == 0 ? main.rgb : main.rgb / main.a; // un-premultiply for additive lights in CombinedShapeLightShared, reapply afterwards
|
||||||
#if UNITY_VERSION < 202120
|
#if UNITY_VERSION < 202120
|
||||||
half4 pixel = half4(CombinedShapeLightShared(half4(main.rgb, 1), mask, input.lightingUV).rgb, main.a);
|
half4 pixel = half4(CombinedShapeLightShared(half4(main.rgb, 1), mask, input.lightingUV).rgb * main.a, main.a);
|
||||||
#else
|
#else
|
||||||
SurfaceData2D surfaceData;
|
SurfaceData2D surfaceData;
|
||||||
InputData2D inputData;
|
InputData2D inputData;
|
||||||
@ -102,7 +103,7 @@ half4 CombinedShapeLightFragment(VertexOutputSpriteURP2D input) : SV_Target
|
|||||||
surfaceData.mask = mask;
|
surfaceData.mask = mask;
|
||||||
inputData.uv = input.texcoord;
|
inputData.uv = input.texcoord;
|
||||||
inputData.lightingUV = input.lightingUV;
|
inputData.lightingUV = input.lightingUV;
|
||||||
half4 pixel = half4(CombinedShapeLightShared(surfaceData, inputData).rgb, main.a);
|
half4 pixel = half4(CombinedShapeLightShared(surfaceData, inputData).rgb * main.a, main.a);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_RIM_LIGHTING)
|
#if defined(_RIM_LIGHTING)
|
||||||
|
|||||||
@ -94,6 +94,8 @@
|
|||||||
float4 clipVertex = o.positionCS / o.positionCS.w;
|
float4 clipVertex = o.positionCS / o.positionCS.w;
|
||||||
o.lightingUV = ComputeScreenPos(clipVertex).xy;
|
o.lightingUV = ComputeScreenPos(clipVertex).xy;
|
||||||
o.color = PMAGammaToTargetSpace(v.color);
|
o.color = PMAGammaToTargetSpace(v.color);
|
||||||
|
// un-premultiply for additive lights in CombinedShapeLightShared, reapply afterwards
|
||||||
|
o.color.rgb = o.color.a == 0 ? o.color.rgb : o.color.rgb / o.color.a;
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,18 +104,19 @@
|
|||||||
half4 CombinedShapeLightFragment(Varyings i) : SV_Target
|
half4 CombinedShapeLightFragment(Varyings i) : SV_Target
|
||||||
{
|
{
|
||||||
half4 tex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
half4 tex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
||||||
#if defined(_STRAIGHT_ALPHA_INPUT)
|
#if !defined(_STRAIGHT_ALPHA_INPUT)
|
||||||
tex.rgb *= tex.a;
|
// un-premultiply for additive lights in CombinedShapeLightShared, reapply afterwards
|
||||||
#endif
|
tex.rgb = tex.a == 0 ? tex.rgb : tex.rgb / tex.a;
|
||||||
|
#endif
|
||||||
|
|
||||||
half4 main = tex * i.color;
|
half4 main = tex * i.color;
|
||||||
#if !defined(_LIGHT_AFFECTS_ADDITIVE)
|
#if !defined(_LIGHT_AFFECTS_ADDITIVE)
|
||||||
if (i.color.a == 0)
|
if (i.color.a == 0)
|
||||||
return main;
|
return half4(main.rgb * main.a, main.a);
|
||||||
#endif
|
#endif
|
||||||
half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, i.uv);
|
half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, i.uv);
|
||||||
#if UNITY_VERSION < 202120
|
#if UNITY_VERSION < 202120
|
||||||
return half4(CombinedShapeLightShared(half4(main.rgb, 1), mask, i.lightingUV).rgb, main.a);
|
return half4(CombinedShapeLightShared(half4(main.rgb, 1), mask, i.lightingUV).rgb * main.a, main.a);
|
||||||
#else
|
#else
|
||||||
SurfaceData2D surfaceData;
|
SurfaceData2D surfaceData;
|
||||||
InputData2D inputData;
|
InputData2D inputData;
|
||||||
@ -122,7 +125,7 @@
|
|||||||
surfaceData.mask = mask;
|
surfaceData.mask = mask;
|
||||||
inputData.uv = i.uv;
|
inputData.uv = i.uv;
|
||||||
inputData.lightingUV = i.lightingUV;
|
inputData.lightingUV = i.lightingUV;
|
||||||
return half4(CombinedShapeLightShared(surfaceData, inputData).rgb, main.a);
|
return half4(CombinedShapeLightShared(surfaceData, inputData).rgb * main.a, main.a);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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.7",
|
"version": "4.1.8",
|
||||||
"unity": "2019.3",
|
"unity": "2019.3",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Esoteric Software",
|
"name": "Esoteric Software",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user