From 16e3de63cc514253d37781a3f5f3713c647b6a24 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 3 Mar 2021 17:07:42 +0100 Subject: [PATCH 1/7] [unity] `NewSkeletonAnimationGameObject` and `Initialize()` now provide a `quiet` parameter to omit material warnings. Closes #1852. --- .../spine-unity/Components/SkeletonAnimation.cs | 14 ++++++++------ .../spine-unity/Components/SkeletonMecanim.cs | 4 ++-- .../spine-unity/Components/SkeletonRenderer.cs | 12 ++++++------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs index cfc5ddf29..315f9e37e 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs @@ -134,14 +134,16 @@ namespace Spine.Unity { #region Runtime Instantiation /// Adds and prepares a SkeletonAnimation component to a GameObject at runtime. /// The newly instantiated SkeletonAnimation - public static SkeletonAnimation AddToGameObject (GameObject gameObject, SkeletonDataAsset skeletonDataAsset) { - return SkeletonRenderer.AddSpineComponent(gameObject, skeletonDataAsset); + public static SkeletonAnimation AddToGameObject (GameObject gameObject, SkeletonDataAsset skeletonDataAsset, + bool quiet = false) { + return SkeletonRenderer.AddSpineComponent(gameObject, skeletonDataAsset, quiet); } /// Instantiates a new UnityEngine.GameObject and adds a prepared SkeletonAnimation component to it. /// The newly instantiated SkeletonAnimation component. - public static SkeletonAnimation NewSkeletonAnimationGameObject (SkeletonDataAsset skeletonDataAsset) { - return SkeletonRenderer.NewSpineGameObject(skeletonDataAsset); + public static SkeletonAnimation NewSkeletonAnimationGameObject (SkeletonDataAsset skeletonDataAsset, + bool quiet = false) { + return SkeletonRenderer.NewSpineGameObject(skeletonDataAsset, quiet); } #endregion @@ -155,10 +157,10 @@ namespace Spine.Unity { /// /// Initialize this component. Attempts to load the SkeletonData and creates the internal Spine objects and buffers. /// If set to true, force overwrite an already initialized object. - public override void Initialize (bool overwrite) { + public override void Initialize (bool overwrite, bool quiet = false) { if (valid && !overwrite) return; - base.Initialize(overwrite); + base.Initialize(overwrite, quiet); if (!valid) return; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs index c6bf63b27..14b30c7cc 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonMecanim.cs @@ -69,11 +69,11 @@ namespace Spine.Unity { public event UpdateBonesDelegate UpdateComplete { add { _UpdateComplete += value; } remove { _UpdateComplete -= value; } } #endregion - public override void Initialize (bool overwrite) { + public override void Initialize (bool overwrite, bool quiet = false) { if (valid && !overwrite) return; - base.Initialize(overwrite); + base.Initialize(overwrite, quiet); if (!valid) return; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs index 2fea2f7d4..bf442ce19 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs @@ -247,17 +247,17 @@ namespace Spine.Unity { public SkeletonDataAsset SkeletonDataAsset { get { return skeletonDataAsset; } } // ISkeletonComponent #region Runtime Instantiation - public static T NewSpineGameObject (SkeletonDataAsset skeletonDataAsset) where T : SkeletonRenderer { - return SkeletonRenderer.AddSpineComponent(new GameObject("New Spine GameObject"), skeletonDataAsset); + public static T NewSpineGameObject (SkeletonDataAsset skeletonDataAsset, bool quiet = false) where T : SkeletonRenderer { + return SkeletonRenderer.AddSpineComponent(new GameObject("New Spine GameObject"), skeletonDataAsset, quiet); } /// Add and prepare a Spine component that derives from SkeletonRenderer to a GameObject at runtime. /// T should be SkeletonRenderer or any of its derived classes. - public static T AddSpineComponent (GameObject gameObject, SkeletonDataAsset skeletonDataAsset) where T : SkeletonRenderer { + public static T AddSpineComponent (GameObject gameObject, SkeletonDataAsset skeletonDataAsset, bool quiet = false) where T : SkeletonRenderer { var c = gameObject.AddComponent(); if (skeletonDataAsset != null) { c.skeletonDataAsset = skeletonDataAsset; - c.Initialize(false); + c.Initialize(false, quiet); } return c; } @@ -315,7 +315,7 @@ namespace Spine.Unity { /// /// Initialize this component. Attempts to load the SkeletonData and creates the internal Skeleton object and buffers. /// If set to true, it will overwrite internal objects if they were already generated. Otherwise, the initialized component will ignore subsequent calls to initialize. - public virtual void Initialize (bool overwrite) { + public virtual void Initialize (bool overwrite, bool quiet = false) { if (valid && !overwrite) return; @@ -361,7 +361,7 @@ namespace Spine.Unity { #if UNITY_EDITOR if (!Application.isPlaying) { string errorMessage = null; - if (MaterialChecks.IsMaterialSetupProblematic(this, ref errorMessage)) + if (quiet || MaterialChecks.IsMaterialSetupProblematic(this, ref errorMessage)) Debug.LogWarningFormat(this, "Problematic material setup at {0}: {1}", this.name, errorMessage); } #endif From c5c71747c3a0ca4d242a23722bc272e5004cd1b5 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 3 Mar 2021 20:17:03 +0100 Subject: [PATCH 2/7] [unity] Fixed single pass additive slot blend mode for all URP and LWRP shaders (2D and 3D). Closes #1850. --- .../Spine-SkeletonLit-ForwardPass-LW.hlsl | 35 +++++++++++-------- .../Spine-Sprite-ForwardPass-LW.hlsl | 4 +++ .../Spine-Sprite-StandardPass-URP-2D.hlsl | 4 +++ .../2D/Spine-SkeletonLit-URP-2D.shader | 11 +++--- .../Spine-SkeletonLit-ForwardPass-URP.hlsl | 34 ++++++++++-------- .../Include/Spine-Sprite-ForwardPass-URP.hlsl | 4 +++ 6 files changed, 56 insertions(+), 36 deletions(-) diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-SkeletonLit-ForwardPass-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-SkeletonLit-ForwardPass-LW.hlsl index f84e8f0f4..a2caada38 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-SkeletonLit-ForwardPass-LW.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-SkeletonLit-ForwardPass-LW.hlsl @@ -59,6 +59,8 @@ VertexOutput vert(appdata v) { float3 positionWS = TransformObjectToWorld(v.pos); half3 fixedNormal = half3(0, 0, -1); half3 normalWS = normalize(mul((float3x3)unity_ObjectToWorld, fixedNormal)); + o.uv0 = v.uv0; + o.pos = TransformWorldToHClip(positionWS); #ifdef _DOUBLE_SIDED_LIGHTING // unfortunately we have to compute the sign here in the vertex shader @@ -69,7 +71,16 @@ VertexOutput vert(appdata v) { #endif half3 shadowedColor; - color.rgb = LightweightLightVertexSimplified(positionWS, normalWS, shadowedColor); + if (color.a == 0) { + o.color = color; +#if defined(SKELETONLIT_RECEIVE_SHADOWS) + o.shadowedColor = color; + o.shadowCoord = float4(0, 0, 0, 0); +#endif + return o; + } + + color.rgb *= LightweightLightVertexSimplified(positionWS, normalWS, shadowedColor); #if defined(SKELETONLIT_RECEIVE_SHADOWS) o.shadowedColor = shadowedColor; #endif @@ -78,10 +89,7 @@ VertexOutput vert(appdata v) { half3 vertexSH; OUTPUT_SH(normalWS.xyz, vertexSH); color.rgb += SAMPLE_GI(input.lightmapUV, vertexSH, normalWS); - o.color = color; - o.uv0 = v.uv0; - o.pos = TransformWorldToHClip(positionWS); #if defined(SKELETONLIT_RECEIVE_SHADOWS) VertexPositionInputs vertexInput; @@ -94,22 +102,19 @@ VertexOutput vert(appdata v) { half4 frag(VertexOutput i) : SV_Target{ half4 tex = tex2D(_MainTex, i.uv0); - half4 col; + #if defined(_STRAIGHT_ALPHA_INPUT) + tex.rgb *= tex.a; + #endif + + if (i.color.a == 0) + return tex * i.color; #if defined(SKELETONLIT_RECEIVE_SHADOWS) half shadowAttenuation = MainLightRealtimeShadow(i.shadowCoord); i.color.rgb = lerp(i.shadowedColor, i.color.rgb, shadowAttenuation); #endif - - #if defined(_STRAIGHT_ALPHA_INPUT) - col.rgb = tex.rgb * i.color.rgb * tex.a; - #else - col.rgb = tex.rgb * i.color.rgb; - #endif - - - col.a = tex.a * i.color.a; - return col; + return tex * i.color; } + #endif diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl index ece0c54b3..f07d94f54 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl @@ -213,6 +213,10 @@ half4 ForwardPassFragmentSprite(VertexOutputLWRP input) : SV_Target fixed4 texureColor = calculateTexturePixel(input.texcoord.xy); ALPHA_CLIP(texureColor, input.vertexColor) +#if !defined(_MULTIPLYBLEND) && !defined(_MULTIPLYBLEND_X2) + if (input.vertexColor.a == 0) + return texureColor * input.vertexColor; +#endif // fill out InputData struct InputData inputData; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl index 01aba038d..d2b70c758 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl @@ -89,6 +89,10 @@ half4 CombinedShapeLightFragment(VertexOutputSpriteURP2D input) : SV_Target fixed4 texureColor = calculateTexturePixel(input.texcoord.xy); ALPHA_CLIP(texureColor, input.vertexColor) texureColor *= input.vertexColor; +#if !defined(_MULTIPLYBLEND) && !defined(_MULTIPLYBLEND_X2) + if (input.vertexColor.a == 0) + return texureColor; +#endif half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, input.texcoord.xy); half4 pixel = CombinedShapeLightShared(texureColor, mask, input.lightingUV); diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-SkeletonLit-URP-2D.shader b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-SkeletonLit-URP-2D.shader index 7cf903eeb..4a4c7a70e 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-SkeletonLit-URP-2D.shader +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-SkeletonLit-URP-2D.shader @@ -98,14 +98,13 @@ half4 CombinedShapeLightFragment(Varyings i) : SV_Target { half4 tex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv); - - half4 main; #if defined(_STRAIGHT_ALPHA_INPUT) - main.rgb = tex.rgb * i.color.rgb * tex.a; - #else - main.rgb = tex.rgb * i.color.rgb; + tex.rgb *= tex.a; #endif - main.a = tex.a * i.color.a; + + half4 main = tex * i.color; + if (i.color.a == 0) + return main; half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, i.uv); return CombinedShapeLightShared(main, mask, i.lightingUV); diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ForwardPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ForwardPass-URP.hlsl index d73bd55e5..453986e04 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ForwardPass-URP.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ForwardPass-URP.hlsl @@ -59,6 +59,8 @@ VertexOutput vert(appdata v) { float3 positionWS = TransformObjectToWorld(v.pos); half3 fixedNormal = half3(0, 0, -1); half3 normalWS = normalize(mul((float3x3)unity_ObjectToWorld, fixedNormal)); + o.uv0 = v.uv0; + o.pos = TransformWorldToHClip(positionWS); #ifdef _DOUBLE_SIDED_LIGHTING // unfortunately we have to compute the sign here in the vertex shader @@ -69,7 +71,16 @@ VertexOutput vert(appdata v) { #endif half3 shadowedColor; - color.rgb = LightweightLightVertexSimplified(positionWS, normalWS, shadowedColor); + if (color.a == 0) { + o.color = color; +#if defined(SKELETONLIT_RECEIVE_SHADOWS) + o.shadowedColor = color; + o.shadowCoord = float4(0, 0, 0, 0); +#endif + return o; + } + + color.rgb *= LightweightLightVertexSimplified(positionWS, normalWS, shadowedColor); #if defined(SKELETONLIT_RECEIVE_SHADOWS) o.shadowedColor = shadowedColor; #endif @@ -78,10 +89,7 @@ VertexOutput vert(appdata v) { half3 vertexSH; OUTPUT_SH(normalWS.xyz, vertexSH); color.rgb += SAMPLE_GI(input.lightmapUV, vertexSH, normalWS); - o.color = color; - o.uv0 = v.uv0; - o.pos = TransformWorldToHClip(positionWS); #if defined(SKELETONLIT_RECEIVE_SHADOWS) VertexPositionInputs vertexInput; @@ -94,22 +102,18 @@ VertexOutput vert(appdata v) { half4 frag(VertexOutput i) : SV_Target{ half4 tex = tex2D(_MainTex, i.uv0); - half4 col; + #if defined(_STRAIGHT_ALPHA_INPUT) + tex.rgb *= tex.a; + #endif + + if (i.color.a == 0) + return tex * i.color; #if defined(SKELETONLIT_RECEIVE_SHADOWS) half shadowAttenuation = MainLightRealtimeShadow(i.shadowCoord); i.color.rgb = lerp(i.shadowedColor, i.color.rgb, shadowAttenuation); #endif - - #if defined(_STRAIGHT_ALPHA_INPUT) - col.rgb = tex.rgb * i.color.rgb * tex.a; - #else - col.rgb = tex.rgb * i.color.rgb; - #endif - - - col.a = tex.a * i.color.a; - return col; + return tex * i.color; } #endif diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl index cb578cba9..5065a73c2 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl @@ -223,6 +223,10 @@ half4 ForwardPassFragmentSprite(VertexOutputLWRP input) : SV_Target fixed4 texureColor = calculateTexturePixel(input.texcoord.xy); ALPHA_CLIP(texureColor, input.vertexColor) +#if !defined(_MULTIPLYBLEND) && !defined(_MULTIPLYBLEND_X2) + if (input.vertexColor.a == 0) + return texureColor * input.vertexColor; +#endif // fill out InputData struct InputData inputData; From 47e357aa88df51c874de46d1f4cb06fb6b7c15cc Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 4 Mar 2021 17:02:18 +0100 Subject: [PATCH 3/7] [unity] Fixed `Spine/Sprite` core shaders now correctly drawing Additive Slots. Closes #1853. --- .../Spine-Skeleton-Lit-Common.cginc | 15 ++-- .../Sprite/CGIncludes/ShaderShared.cginc | 14 +++ .../CGIncludes/SpritePixelLighting.cginc | 88 +++++++++---------- .../Sprite/CGIncludes/SpriteUnlit.cginc | 24 +++-- .../CGIncludes/SpriteVertexLighting.cginc | 2 +- 5 files changed, 74 insertions(+), 69 deletions(-) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Skeleton-Lit-Common.cginc b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Skeleton-Lit-Common.cginc index 73a6e1875..10fbbf08a 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Skeleton-Lit-Common.cginc +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Skeleton-Lit-Common.cginc @@ -109,16 +109,11 @@ sampler2D _MainTex; fixed4 frag (VertexOutput i) : SV_Target { fixed4 tex = tex2D(_MainTex, i.uv0); ALPHA_CLIP(tex, i.color); - - fixed4 col; - #if defined(_STRAIGHT_ALPHA_INPUT) - col.rgb = tex * i.color * tex.a; - #else - col.rgb = tex * i.color; - #endif - - col *= 2; - col.a = tex.a * i.color.a; +#if defined(_STRAIGHT_ALPHA_INPUT) + tex.rgb *= tex.a; +#endif + fixed4 col = tex * i.color; + col.rgb *= 2; return col; } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc index f7d6ffc65..dd5d83fe4 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc @@ -240,6 +240,20 @@ uniform fixed _Cutoff; #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 // diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpritePixelLighting.cginc b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpritePixelLighting.cginc index 8c763f48d..8878df766 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpritePixelLighting.cginc +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpritePixelLighting.cginc @@ -1,6 +1,6 @@ #ifndef SPRITE_PIXEL_LIGHTING_INCLUDED #define SPRITE_PIXEL_LIGHTING_INCLUDED - + #include "ShaderShared.cginc" #include "SpriteLighting.cginc" #include "SpriteSpecular.cginc" @@ -24,24 +24,24 @@ #define _LIGHT_COORD_INDEX_0 4 #define _LIGHT_COORD_INDEX_1 5 #define _FOG_COORD_INDEX 6 -#endif // _NORMALMAP +#endif // _NORMALMAP struct VertexOutput { - float4 pos : SV_POSITION; + float4 pos : SV_POSITION; fixed4 color : COLOR; float2 texcoord : TEXCOORD0; float4 posWorld : TEXCOORD1; half3 normalWorld : TEXCOORD2; #if defined(_NORMALMAP) - half3 tangentWorld : TEXCOORD3; + half3 tangentWorld : TEXCOORD3; half3 binormalWorld : TEXCOORD4; #endif // _NORMALMAP fixed3 vertexLighting : _VERTEX_LIGHTING_INDEX; LIGHTING_COORDS(_LIGHT_COORD_INDEX_0, _LIGHT_COORD_INDEX_1) #if defined(_FOG) UNITY_FOG_COORDS(_FOG_COORD_INDEX) -#endif // _FOG +#endif // _FOG UNITY_VERTEX_OUTPUT_STEREO }; @@ -56,16 +56,16 @@ inline fixed3 calculateLightDiffuse(VertexOutput input, float3 normalWorld, inou { //For directional lights _WorldSpaceLightPos0.w is set to zero float3 lightWorldDirection = normalize(_WorldSpaceLightPos0.xyz - input.posWorld.xyz * _WorldSpaceLightPos0.w); - + float attenuation = LIGHT_ATTENUATION(input); float angleDot = max(0, dot(normalWorld, lightWorldDirection)); - + #if defined(_DIFFUSE_RAMP) fixed3 lightDiffuse = calculateRampedDiffuse(_LightColor0.rgb, attenuation, angleDot); #else fixed3 lightDiffuse = _LightColor0.rgb * (attenuation * angleDot); #endif // _DIFFUSE_RAMP - + return lightDiffuse; } @@ -96,7 +96,7 @@ fixed3 calculateAmbientLight(half3 normalWorld) { #if defined(_SPHERICAL_HARMONICS) fixed3 ambient = ShadeSH9(half4(normalWorld, 1.0)); -#else +#else fixed3 ambient = unity_AmbientSky.rgb; #endif return ambient; @@ -129,124 +129,124 @@ fixed4 calculateSpecularLightAdditive(SpecularCommonData s, float3 viewDir, floa VertexOutput vert(VertexInput v) { VertexOutput output; - + UNITY_SETUP_INSTANCE_ID(input); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); - + output.pos = calculateLocalPos(v.vertex); output.color = calculateVertexColor(v.color); output.texcoord = calculateTextureCoord(v.texcoord); output.posWorld = calculateWorldPos(v.vertex); - + float backFaceSign = 1; -#if defined(FIXED_NORMALS_BACKFACE_RENDERING) +#if defined(FIXED_NORMALS_BACKFACE_RENDERING) backFaceSign = calculateBackfacingSign(output.posWorld.xyz); -#endif +#endif output.normalWorld = calculateSpriteWorldNormal(v, backFaceSign); output.vertexLighting = calculateVertexLighting(output.posWorld, output.normalWorld); - + #if defined(_NORMALMAP) output.tangentWorld = calculateWorldTangent(v.tangent); output.binormalWorld = calculateSpriteWorldBinormal(v, output.normalWorld, output.tangentWorld, backFaceSign); #endif TRANSFER_VERTEX_TO_FRAGMENT(output) - + #if defined(_FOG) UNITY_TRANSFER_FOG(output,output.pos); -#endif // _FOG - +#endif // _FOG + return output; } //////////////////////////////////////// // Fragment programs // - fixed4 fragBase(VertexOutput input) : SV_Target { fixed4 texureColor = calculateTexturePixel(input.texcoord); + RETURN_UNLIT_IF_ADDITIVE_SLOT(texureColor, input.color) // shall be called before ALPHA_CLIP ALPHA_CLIP(texureColor, input.color) - + //Get normal direction fixed3 normalWorld = calculateNormalWorld(input); //Get Ambient diffuse fixed3 ambient = calculateAmbientLight(normalWorld); - + #if defined(SPECULAR) - + //For directional lights _WorldSpaceLightPos0.w is set to zero float3 lightWorldDirection = normalize(_WorldSpaceLightPos0.xyz - input.posWorld.xyz * _WorldSpaceLightPos0.w); float attenuation = LIGHT_ATTENUATION(input); - + //Returns pixel lit by light, texture color should inlcluded alpha half3 viewDir = normalize(_WorldSpaceCameraPos - input.posWorld.xyz); fixed4 pixel = calculateSpecularLight(getSpecularData(input.texcoord.xy, texureColor, input.color), viewDir, normalWorld, lightWorldDirection, _LightColor0.rgb * attenuation, ambient + input.vertexLighting); - + APPLY_EMISSION_SPECULAR(pixel, input.texcoord) - + #else //Get primary pixel light diffuse fixed3 diffuse = calculateLightDiffuse(input, normalWorld, texureColor); - + //Combine along with vertex lighting for the base lighting pass fixed3 lighting = ambient + diffuse + input.vertexLighting; - + APPLY_EMISSION(lighting, input.texcoord) - + fixed4 pixel = calculateLitPixel(texureColor, input.color, lighting); - + #endif - + #if defined(_RIM_LIGHTING) pixel.rgb = applyRimLighting(input.posWorld, normalWorld, pixel); #endif - + COLORISE(pixel) APPLY_FOG(pixel, input) - + return pixel; } fixed4 fragAdd(VertexOutput input) : SV_Target { fixed4 texureColor = calculateTexturePixel(input.texcoord); - + #if defined(_COLOR_ADJUST) texureColor = adjustColor(texureColor); -#endif // _COLOR_ADJUST +#endif // _COLOR_ADJUST ALPHA_CLIP(texureColor, input.color) - + //Get normal direction fixed3 normalWorld = calculateNormalWorld(input); - + #if defined(SPECULAR) - + //For directional lights _WorldSpaceLightPos0.w is set to zero float3 lightWorldDirection = normalize(_WorldSpaceLightPos0.xyz - input.posWorld.xyz * _WorldSpaceLightPos0.w); float attenuation = LIGHT_ATTENUATION(input); - + half3 viewDir = normalize(_WorldSpaceCameraPos - input.posWorld.xyz); fixed4 pixel = calculateSpecularLightAdditive(getSpecularData(input.texcoord.xy, texureColor, input.color), viewDir, normalWorld, lightWorldDirection, _LightColor0.rgb * attenuation); - + #else - + //Get light diffuse fixed3 lighting = calculateLightDiffuse(input, normalWorld, texureColor); fixed4 pixel = calculateAdditiveLitPixel(texureColor, input.color, lighting); - + #endif - + COLORISE_ADDITIVE(pixel) APPLY_FOG_ADDITIVE(pixel, input) - + return pixel; } -#endif // SPRITE_PIXEL_LIGHTING_INCLUDED \ No newline at end of file +#endif // SPRITE_PIXEL_LIGHTING_INCLUDED diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteUnlit.cginc b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteUnlit.cginc index 4385ffcc5..60b37bbaa 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteUnlit.cginc +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteUnlit.cginc @@ -6,7 +6,7 @@ //////////////////////////////////////// // Vertex structs // - + struct VertexInput { float4 vertex : POSITION; @@ -22,7 +22,7 @@ struct VertexOutput fixed4 color : COLOR; #if defined(_FOG) UNITY_FOG_COORDS(1) -#endif // _FOG +#endif // _FOG UNITY_VERTEX_OUTPUT_STEREO }; @@ -34,39 +34,35 @@ struct VertexOutput VertexOutput vert(VertexInput input) { VertexOutput output; - + UNITY_SETUP_INSTANCE_ID(input); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); - - output.pos = calculateLocalPos(input.vertex); + + output.pos = calculateLocalPos(input.vertex); output.texcoord = calculateTextureCoord(input.texcoord); output.color = calculateVertexColor(input.color); #if defined(_FOG) UNITY_TRANSFER_FOG(output,output.pos); #endif // _FOG - + return output; } //////////////////////////////////////// // Fragment program // - - - - fixed4 frag(VertexOutput input) : SV_Target { 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) - fixed4 pixel = calculatePixel(texureColor, input.color); - + COLORISE(pixel) APPLY_FOG(pixel, input) - + return pixel; } -#endif // SPRITE_UNLIT_INCLUDED \ No newline at end of file +#endif // SPRITE_UNLIT_INCLUDED diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteVertexLighting.cginc b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteVertexLighting.cginc index 3d8ee540e..0fc7ad49d 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteVertexLighting.cginc +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteVertexLighting.cginc @@ -399,10 +399,10 @@ VertexOutput vert(VertexInput input) //////////////////////////////////////// // Fragment program // - fixed4 frag(VertexOutput input) : SV_Target { 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) #if defined(PER_PIXEL_LIGHTING) From d50cdef325d04b594c0098326dc8c929767290a5 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 4 Mar 2021 17:47:48 +0100 Subject: [PATCH 4/7] [unity] Corrected and unified Additive Slot behaviour of commit c5c7174 for URP and LWRP shaders (2D and 3D). Now only active for PMA blending and correctly performing alpha clip. See #1850. --- .../Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl | 5 +---- .../2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl | 6 ++---- .../Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl | 5 +---- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl index f07d94f54..403db1599 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl @@ -212,11 +212,8 @@ half4 ForwardPassFragmentSprite(VertexOutputLWRP input) : SV_Target UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); fixed4 texureColor = calculateTexturePixel(input.texcoord.xy); + RETURN_UNLIT_IF_ADDITIVE_SLOT(texureColor, input.vertexColor) // shall be called before ALPHA_CLIP ALPHA_CLIP(texureColor, input.vertexColor) -#if !defined(_MULTIPLYBLEND) && !defined(_MULTIPLYBLEND_X2) - if (input.vertexColor.a == 0) - return texureColor * input.vertexColor; -#endif // fill out InputData struct InputData inputData; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl index d2b70c758..ac32a9498 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl @@ -87,12 +87,10 @@ VertexOutputSpriteURP2D CombinedShapeLightVertex(VertexInput input) half4 CombinedShapeLightFragment(VertexOutputSpriteURP2D input) : SV_Target { fixed4 texureColor = calculateTexturePixel(input.texcoord.xy); + RETURN_UNLIT_IF_ADDITIVE_SLOT(texureColor, input.vertexColor) // shall be called before ALPHA_CLIP ALPHA_CLIP(texureColor, input.vertexColor) + texureColor *= input.vertexColor; -#if !defined(_MULTIPLYBLEND) && !defined(_MULTIPLYBLEND_X2) - if (input.vertexColor.a == 0) - return texureColor; -#endif half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, input.texcoord.xy); half4 pixel = CombinedShapeLightShared(texureColor, mask, input.lightingUV); diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl index 5065a73c2..f10b92bec 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl @@ -222,11 +222,8 @@ half4 ForwardPassFragmentSprite(VertexOutputLWRP input) : SV_Target UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); fixed4 texureColor = calculateTexturePixel(input.texcoord.xy); + RETURN_UNLIT_IF_ADDITIVE_SLOT(texureColor, input.vertexColor) // shall be called before ALPHA_CLIP ALPHA_CLIP(texureColor, input.vertexColor) -#if !defined(_MULTIPLYBLEND) && !defined(_MULTIPLYBLEND_X2) - if (input.vertexColor.a == 0) - return texureColor * input.vertexColor; -#endif // fill out InputData struct InputData inputData; From 07b7b9371c73207592801c7ffd00e3621baeca16 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 4 Mar 2021 18:31:18 +0100 Subject: [PATCH 5/7] [unity] Increased UPM package versions for changes of last commit d50cdef. --- .../com.esotericsoftware.spine.lwrp-shaders/package-2019.1.json | 2 +- .../com.esotericsoftware.spine.lwrp-shaders/package-2019.2.json | 2 +- .../com.esotericsoftware.spine.lwrp-shaders/package.json | 2 +- .../Modules/com.esotericsoftware.spine.urp-shaders/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.1.json b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.1.json index 929bc1cff..b309970af 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.1.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.1.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.lwrp-shaders", "displayName": "Spine Lightweight RP Shaders", "description": "This plugin provides lightweight render pipeline (LWRP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 3.8.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "3.8.1", + "version": "3.8.2", "unity": "2019.1", "author": { "name": "Esoteric Software", diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.2.json b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.2.json index 0224c58af..fc57d566c 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.2.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.2.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.lwrp-shaders", "displayName": "Spine Lightweight RP Shaders", "description": "This plugin provides lightweight render pipeline (LWRP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 3.8.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "3.8.1", + "version": "3.8.2", "unity": "2019.2", "author": { "name": "Esoteric Software", diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package.json b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package.json index 929bc1cff..b309970af 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.lwrp-shaders", "displayName": "Spine Lightweight RP Shaders", "description": "This plugin provides lightweight render pipeline (LWRP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 3.8.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "3.8.1", + "version": "3.8.2", "unity": "2019.1", "author": { "name": "Esoteric Software", diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json index 7aa32495a..dd02ce173 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.urp-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 3.8.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "3.8.1", + "version": "3.8.2", "unity": "2019.3", "author": { "name": "Esoteric Software", From bd6a4df888a3618295e712cfa8e3b87ec7402333 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 4 Mar 2021 18:42:45 +0100 Subject: [PATCH 6/7] [unity] Updated UPM package version numbers in package.json description files. --- .../package-2019.1.json | 4 ++-- .../package-2019.2.json | 4 ++-- .../com.esotericsoftware.spine.lwrp-shaders/package.json | 4 ++-- .../Modules/com.esotericsoftware.spine.timeline/package.json | 4 ++-- .../com.esotericsoftware.spine.urp-shaders/package.json | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.1.json b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.1.json index b309970af..d0cfe3ae6 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.1.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.1.json @@ -1,8 +1,8 @@ { "name": "com.esotericsoftware.spine.lwrp-shaders", "displayName": "Spine Lightweight RP Shaders", - "description": "This plugin provides lightweight render pipeline (LWRP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 3.8.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "3.8.2", + "description": "This plugin provides lightweight render pipeline (LWRP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 4.0.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", + "version": "4.0.2", "unity": "2019.1", "author": { "name": "Esoteric Software", diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.2.json b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.2.json index fc57d566c..41902138c 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.2.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.2.json @@ -1,8 +1,8 @@ { "name": "com.esotericsoftware.spine.lwrp-shaders", "displayName": "Spine Lightweight RP Shaders", - "description": "This plugin provides lightweight render pipeline (LWRP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 3.8.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "3.8.2", + "description": "This plugin provides lightweight render pipeline (LWRP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 4.0.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", + "version": "4.0.2", "unity": "2019.2", "author": { "name": "Esoteric Software", diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package.json b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package.json index b309970af..d0cfe3ae6 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package.json @@ -1,8 +1,8 @@ { "name": "com.esotericsoftware.spine.lwrp-shaders", "displayName": "Spine Lightweight RP Shaders", - "description": "This plugin provides lightweight render pipeline (LWRP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 3.8.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "3.8.2", + "description": "This plugin provides lightweight render pipeline (LWRP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 4.0.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", + "version": "4.0.2", "unity": "2019.1", "author": { "name": "Esoteric Software", diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/package.json b/spine-unity/Modules/com.esotericsoftware.spine.timeline/package.json index d4ebe02cc..664c571e6 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/package.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/package.json @@ -1,8 +1,8 @@ { "name": "com.esotericsoftware.spine.timeline", "displayName": "Spine Timeline Extensions", - "description": "This plugin provides integration of spine-unity for the Unity Timeline.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 3.8 from 2019-10-03 or newer.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "3.8.2", + "description": "This plugin provides integration of spine-unity for the Unity Timeline.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 4.0.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", + "version": "4.0.2", "unity": "2018.3", "author": { "name": "Esoteric Software", diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json index dd02ce173..6908d3d9d 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json @@ -1,8 +1,8 @@ { "name": "com.esotericsoftware.spine.urp-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 3.8.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "3.8.2", + "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.0.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", + "version": "4.0.2", "unity": "2019.3", "author": { "name": "Esoteric Software", From b6793b9a9da283e758e8850610ec1a6ccf12367b Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Thu, 4 Mar 2021 18:55:57 +0100 Subject: [PATCH 7/7] [unity] Fixed `Sprite` shaders incorrectly applying PMA vertex colors again in `Premultiply Alpha` blend mode. Closes #1854. --- CHANGELOG.md | 1 + .../spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 192aac86d..1c97198e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ * Removed redundant `Spine.SkeletonExtensions` extension methods `Skeleton.Set*ToSetupPose()`. Also removed less commonly used extension methods `TrackEntry.AllowImmediateQueue()` and `Attachment.IsRenderable()`. * `Skin.Attachments` now replaces `Skin.GetAttachments()`, returning an `ICollection`. This makes access more consistent and intuitive. To fix any compile errors, replace any occurrances of `skin.GetAttachments()` by `skin.Attachments`. * Reverted changes: `BoneFollower` property `followLocalScale` has intermediately been renamed to `followScale` but was renamed back to `followLocalScale`. Serialized values (scenes and prefabs) will automatically be upgraded, only code accessing `followScale` needs to be adapted. + * Corrected blending behaviour of all `Sprite` shaders in `Premultiply Alpha` blend mode (including URP and LWRP packages). Previously vertex color alpha was premultiplied again, even though `Premultiply Alpha` blend mode assumes PMA texture and PMA vertex color input. Slot-alpha blending will thus be correctly lighter after upgrading to 4.0. If you have compensated this problem by disabling `Advanced - PMA Vertex Colors` you can now re-enable this parameter, also allowing for rendering Additive slots in a single pass. * **Additions** * Additional **Fix Draw Order** parameter at SkeletonRenderer, defaults to `disabled` (previous behaviour). diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc index dd5d83fe4..4bd1933e6 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc @@ -137,7 +137,7 @@ inline fixed4 prepareLitPixelForOutput(fixed4 finalPixel, fixed4 color) : SV_Tar finalPixel.rgb *= finalPixel.a; #elif defined(_ALPHAPREMULTIPLY_ON) //Pre multiplied alpha - finalPixel.rgb *= color.a; + // texture and vertex colors are premultiplied already #elif defined(_MULTIPLYBLEND) //Multiply finalPixel = lerp(fixed4(1,1,1,1), finalPixel, finalPixel.a);