ソースを参照

[unity] All lit shaders now provide an additional parameter `Light Affects Additive` which defaults to `false`. This re-introduces flexibility taken away in commit aa46f411. See #1301.

Harald Csaszar 4 年 前
コミット
02f87a0f9f
21 ファイル変更63 行追加16 行削除
  1. 2 0
      CHANGELOG.md
  2. 10 0
      spine-unity/Assets/Spine/Editor/spine-unity/Editor/Shaders/SpineSpriteShaderGUI.cs
  3. 10 2
      spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Skeleton-Lit-Common.cginc
  4. 2 0
      spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton-Lit-ZWrite.shader
  5. 2 0
      spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton-Lit.shader
  6. 2 2
      spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc
  7. 3 0
      spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/SpritesPixelLit.shader
  8. 3 1
      spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/SpritesVertexLit.shader
  9. 2 0
      spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-SkeletonLit-ForwardPass-LW.hlsl
  10. 2 0
      spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-SkeletonLit-LW.shader
  11. 3 0
      spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-Sprite-LW.shader
  12. 1 1
      spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.1.json
  13. 1 1
      spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package-2019.2.json
  14. 1 1
      spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/package.json
  15. 3 4
      spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl
  16. 5 3
      spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-SkeletonLit-URP-2D.shader
  17. 3 0
      spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-Sprite-URP-2D.shader
  18. 2 0
      spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ForwardPass-URP.hlsl
  19. 2 0
      spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-SkeletonLit-URP.shader
  20. 3 0
      spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Sprite-URP.shader
  21. 1 1
      spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json

+ 2 - 0
CHANGELOG.md

@@ -53,6 +53,7 @@
   * 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.
   * Corrected all `Outline` shaders outline thickness when `Advanced - Sample 8 Neighbourhood` is disabled (thus using `4 Neighbourhood`). Previously weighting was incorrectly thick (4x as thick) compared to 8 neighbourhood, now it is more consistent. This might require adjustment of all your outline materials where `Sample 8 Neighbourhood` is disabled to restore the previous outline thickness, by adjusting the `Outline Threshold` parameter through adding a `/4` to make the threshold 4 times smaller.
   * **Linear color space:** Previously Slot colors were not displayed the same in Unity as in the Spine Editor. This is now fixed at all shaders, including URP and LWRP shaders. See section *Additions* below for more details. If you have tweaked Slot colors to look correct in `Linear` color space in Unity but incorrect in Spine, you might want to adjust the tweaked colors. Slot colors displayed in Unity should now match colors displayed in the Spine Editor when configured to display as `Linear` color space in the Spine Editor Settings.
+  * Additive Slots have always been lit before they were written to the target buffer. Now all lit shaders provide an additional parameter `Light Affects Additive` which defaults to `false`, as it is the more intuitive default value. You can enable the old behaviour by setting this parameter to `true`.
 
 * **Additions**
   * Additional **Fix Draw Order** parameter at SkeletonRenderer, defaults to `disabled` (previous behaviour).
@@ -92,6 +93,7 @@
   * `BoneFollower` and `BoneFollowerGraphic` components now provide better support for following bones when the skeleton's Transform is not the parent of the follower's Transform. Previously e.g. rotating a common parent Transform did not lead to the desired result, as well as negatively scaling a skeleton's Transform when it is not a parent of the follower's Transform.
   * **Linear color space:** Previously Slot colors were not displayed the same in Unity as in the Spine Editor (when configured to display as `Linear` color space in Spine Editor Settings). This is now fixed at all shaders, including URP and LWRP shaders.
   * All Spine shaders (also including URP and LWRP shaders) now support `PMA Vertex Colors` in combination with `Linear` color space. Thus when using Spine shaders, you should always enable `PMA Vertex Colors` at the `SkeletonRenderer` component. This allows using single pass `Additive` Slots rendering. Note that textures shall still be exported as `Straight alpha` when using `Linear` color space, so combine `PMA Vertex Colors` with `Straight Texture`. All `Sprite` shaders now provide an additional blend mode for this, named `PMA Vertex, Straight Texture` which shall be the preferred Sprite shader blend mode in `Linear` color space.
+  * Additive Slots have always been lit before they were written to the target buffer. Now all lit shaders provide an additional parameter `Light Affects Additive` which defaults to `false`, as it is the more intuitive default value. You can enable the old behaviour by setting this parameter to `true`.
 
 * **Changes of default values**
 

+ 10 - 0
spine-unity/Assets/Spine/Editor/spine-unity/Editor/Shaders/SpineSpriteShaderGUI.cs

@@ -130,6 +130,8 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
 	MaterialProperty _smoothness = null;
 	MaterialProperty _smoothnessScale = null;
 
+	MaterialProperty _lightAffectsAdditive = null;
+
 	static GUIContent _albedoText = new GUIContent("Albedo", "Albedo (RGB) and Transparency (A)");
 	static GUIContent _maskText = new GUIContent("Light Mask", "Light mask texture (secondary Sprite texture)");
 	static GUIContent _altAlbedoText = new GUIContent("Secondary Albedo", "When a secondary albedo texture is set the albedo will be a blended mix of the two textures based on the blend value.");
@@ -190,6 +192,7 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
 	static GUIContent _meshRequiresNormalsText = new GUIContent("Note: Material requires a mesh with normals.");
 	static GUIContent _meshRequiresNormalsAndTangentsText = new GUIContent("Note: Material requires a mesh with Normals and Tangents.");
 	static GUIContent[] _fixedDiffuseRampModeOptions = { new GUIContent("Hard"), new GUIContent("Soft"), new GUIContent("Old Hard"), new GUIContent("Old Soft") };
+	static GUIContent _lightAffectsAdditiveText = new GUIContent("Light Affects Additive", "For PMA Additive Slots: When enabled, additive Slots are lit normally before the additive color is written to the target buffer. When disabled, the additive color is directly written with intensity 1.");
 
 	const string _primaryMapsText = "Main Maps";
 	const string _depthLabelText = "Depth";
@@ -262,6 +265,8 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
 		_metallicGlossMap = FindProperty("_MetallicGlossMap", props, false);
 		_smoothness = FindProperty("_Glossiness", props, false);
 		_smoothnessScale = FindProperty("_GlossMapScale", props, false);
+
+		_lightAffectsAdditive = FindProperty("_LightAffectsAdditive", props, false);
 	}
 
 	static bool BoldToggleField (GUIContent label, bool value) {
@@ -844,6 +849,11 @@ public class SpineSpriteShaderGUI : SpineShaderWithOutlineGUI {
 			dataChanged |= EditorGUI.EndChangeCheck();
 		}
 
+		if (_lightAffectsAdditive != null) {
+			EditorGUI.BeginChangeCheck();
+			_materialEditor.ShaderProperty(_lightAffectsAdditive, _lightAffectsAdditiveText);
+			dataChanged |= EditorGUI.EndChangeCheck();
+		}
 		return dataChanged;
 	}
 

+ 10 - 2
spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Skeleton-Lit-Common.cginc

@@ -84,6 +84,8 @@ VertexOutput vert (appdata v) {
 	float3 eyePos = UnityObjectToViewPos(float4(v.pos, 1)).xyz; //mul(UNITY_MATRIX_MV, float4(v.pos,1)).xyz;
 	half3 fixedNormal = half3(0,0,-1);
 	half3 eyeNormal = normalize(mul((float3x3)UNITY_MATRIX_IT_MV, fixedNormal));
+	o.uv0 = v.uv0;
+	o.pos = UnityObjectToClipPos(v.pos);
 
 #ifdef _DOUBLE_SIDED_LIGHTING
 	// unfortunately we have to compute the sign here in the vertex shader
@@ -92,6 +94,14 @@ VertexOutput vert (appdata v) {
 	eyeNormal *= faceSign;
 #endif
 
+	half3 shadowedColor;
+#if !defined(_LIGHT_AFFECTS_ADDITIVE)
+	if (color.a == 0) {
+		o.color = color;
+		return o;
+	}
+#endif // !defined(_LIGHT_AFFECTS_ADDITIVE)
+
 	// Lights
 	half3 lcolor = half4(0,0,0,1).rgb + color.rgb * glstate_lightmodel_ambient.rgb;
 	for (int il = 0; il < LIGHT_LOOP_LIMIT; ++il) {
@@ -100,8 +110,6 @@ VertexOutput vert (appdata v) {
 
 	color.rgb = lcolor.rgb;
 	o.color = saturate(color);
-	o.uv0 = v.uv0;
-	o.pos = UnityObjectToClipPos(v.pos);
 	return o;
 }
 

+ 2 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton-Lit-ZWrite.shader

@@ -9,6 +9,7 @@ Shader "Spine/Skeleton Lit ZWrite" {
 		[NoScaleOffset] _MainTex ("Main Texture", 2D) = "black" {}
 		[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
 		[Toggle(_DOUBLE_SIDED_LIGHTING)] _DoubleSidedLighting("Double-Sided Lighting", Int) = 0
+		[MaterialToggle(_LIGHT_AFFECTS_ADDITIVE)] _LightAffectsAdditive("Light Affects Additive", Float) = 0
 		[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
 		[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
 
@@ -44,6 +45,7 @@ Shader "Spine/Skeleton Lit ZWrite" {
 			CGPROGRAM
 			#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
 			#pragma shader_feature _ _DOUBLE_SIDED_LIGHTING
+			#pragma shader_feature _ _LIGHT_AFFECTS_ADDITIVE
 			#pragma vertex vert
 			#pragma fragment frag
 			#pragma target 2.0

+ 2 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton-Lit.shader

@@ -8,6 +8,7 @@ Shader "Spine/Skeleton Lit" {
 		[NoScaleOffset] _MainTex ("Main Texture", 2D) = "black" {}
 		[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
 		[Toggle(_DOUBLE_SIDED_LIGHTING)] _DoubleSidedLighting("Double-Sided Lighting", Int) = 0
+		[MaterialToggle(_LIGHT_AFFECTS_ADDITIVE)] _LightAffectsAdditive("Light Affects Additive", Float) = 0
 		[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
 		[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
 
@@ -43,6 +44,7 @@ Shader "Spine/Skeleton Lit" {
 			CGPROGRAM
 			#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
 			#pragma shader_feature _ _DOUBLE_SIDED_LIGHTING
+			#pragma shader_feature _ _LIGHT_AFFECTS_ADDITIVE
 			#pragma vertex vert
 			#pragma fragment frag
 			#pragma target 2.0

+ 2 - 2
spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc

@@ -253,13 +253,13 @@ uniform fixed _Cutoff;
 // Additive Slot blend mode
 // return unlit textureColor, alpha clip textureColor.a only
 //
-#if defined(_ALPHAPREMULTIPLY_ON)
+#if defined(_ALPHAPREMULTIPLY_ON) && !defined(_LIGHT_AFFECTS_ADDITIVE)
 	#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;\
 	}
-#elif defined(_ALPHAPREMULTIPLY_VERTEX_ONLY)
+#elif defined(_ALPHAPREMULTIPLY_VERTEX_ONLY) && !defined(_LIGHT_AFFECTS_ADDITIVE)
 	#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))\

+ 3 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/SpritesPixelLit.shader

@@ -37,6 +37,8 @@ Shader "Spine/Sprite/Pixel Lit"
 		_BlendTex ("Blend Texture", 2D) = "white" {}
 		_BlendAmount ("Blend", Range(0,1)) = 0.0
 
+		[MaterialToggle(_LIGHT_AFFECTS_ADDITIVE)] _LightAffectsAdditive("Light Affects Additive", Float) = 0
+
 		[HideInInspector] _SrcBlend ("__src", Float) = 1.0
 		[HideInInspector] _DstBlend ("__dst", Float) = 0.0
 		[HideInInspector] _RenderQueue ("__queue", Float) = 0.0
@@ -91,6 +93,7 @@ Shader "Spine/Sprite/Pixel Lit"
 				#pragma shader_feature _TEXTURE_BLEND
 				#pragma shader_feature _SPHERICAL_HARMONICS
 				#pragma shader_feature _FOG
+				#pragma shader_feature _LIGHT_AFFECTS_ADDITIVE
 
 				#pragma multi_compile_fwdbase
 				#pragma fragmentoption ARB_precision_hint_fastest

+ 3 - 1
spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/SpritesVertexLit.shader

@@ -38,6 +38,8 @@ Shader "Spine/Sprite/Vertex Lit"
 		_BlendTex ("Blend Texture", 2D) = "white" {}
 		_BlendAmount ("Blend", Range(0,1)) = 0.0
 
+		[MaterialToggle(_LIGHT_AFFECTS_ADDITIVE)] _LightAffectsAdditive("Light Affects Additive", Float) = 0
+
 		[HideInInspector] _SrcBlend ("__src", Float) = 1.0
 		[HideInInspector] _DstBlend ("__dst", Float) = 0.0
 		[HideInInspector] _RenderQueue ("__queue", Float) = 0.0
@@ -92,7 +94,7 @@ Shader "Spine/Sprite/Vertex Lit"
 				#pragma shader_feature _TEXTURE_BLEND
 				#pragma shader_feature _SPHERICAL_HARMONICS
 				#pragma shader_feature _FOG
-
+				#pragma shader_feature _LIGHT_AFFECTS_ADDITIVE
 
 				#pragma fragmentoption ARB_precision_hint_fastest
 				#pragma multi_compile_fog

+ 2 - 0
spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-SkeletonLit-ForwardPass-LW.hlsl

@@ -72,6 +72,7 @@ VertexOutput vert(appdata v) {
 #endif
 
 	half3 shadowedColor;
+#if !defined(_LIGHT_AFFECTS_ADDITIVE)
 	if (color.a == 0) {
 		o.color = color;
 #if defined(SKELETONLIT_RECEIVE_SHADOWS)
@@ -80,6 +81,7 @@ VertexOutput vert(appdata v) {
 #endif
 		return o;
 	}
+#endif // !defined(_LIGHT_AFFECTS_ADDITIVE)
 
 	color.rgb *= LightweightLightVertexSimplified(positionWS, normalWS, shadowedColor);
 #if defined(SKELETONLIT_RECEIVE_SHADOWS)

+ 2 - 0
spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-SkeletonLit-LW.shader

@@ -9,6 +9,7 @@ Shader "Lightweight Render Pipeline/Spine/Skeleton Lit" {
 		[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
 		[Toggle(_RECEIVE_SHADOWS)] _ReceiveShadows("Receive Shadows", Int) = 0
 		[Toggle(_DOUBLE_SIDED_LIGHTING)] _DoubleSidedLighting("Double-Sided Lighting", Int) = 0
+		[MaterialToggle(_LIGHT_AFFECTS_ADDITIVE)] _LightAffectsAdditive("Light Affects Additive", Float) = 0
 		[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
 		[Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Compare", Float) = 0.0 // Disabled stencil test by default
 	}
@@ -64,6 +65,7 @@ Shader "Lightweight Render Pipeline/Spine/Skeleton Lit" {
 			#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
 			#pragma shader_feature _ _DOUBLE_SIDED_LIGHTING
 			#pragma shader_feature _RECEIVE_SHADOWS_OFF _RECEIVE_SHADOWS
+			#pragma multi_compile _ _LIGHT_AFFECTS_ADDITIVE
 			#pragma vertex vert
 			#pragma fragment frag
 			#pragma target 2.0

+ 3 - 0
spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-Sprite-LW.shader

@@ -38,6 +38,8 @@ Shader "Lightweight Render Pipeline/Spine/Sprite"
 		_BlendTex("Blend Texture", 2D) = "white" {}
 		_BlendAmount("Blend", Range(0,1)) = 0.0
 
+		[MaterialToggle(_LIGHT_AFFECTS_ADDITIVE)] _LightAffectsAdditive("Light Affects Additive", Float) = 0
+
 		[HideInInspector] _SrcBlend("__src", Float) = 1.0
 		[HideInInspector] _DstBlend("__dst", Float) = 0.0
 		[HideInInspector] _RenderQueue("__queue", Float) = 0.0
@@ -93,6 +95,7 @@ Shader "Lightweight Render Pipeline/Spine/Sprite"
 			#pragma shader_feature _TEXTURE_BLEND
 			#pragma shader_feature _FOG
 			#pragma shader_feature _RECEIVE_SHADOWS_OFF
+			#pragma shader_feature _LIGHT_AFFECTS_ADDITIVE
 
 			#pragma fragmentoption ARB_precision_hint_fastest
 			#pragma multi_compile_fog

+ 1 - 1
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 4.0.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
-	"version": "4.0.3",
+	"version": "4.0.4",
 	"unity": "2019.1",
 	"author": {
 		"name": "Esoteric Software",

+ 1 - 1
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 4.0.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
-	"version": "4.0.3",
+	"version": "4.0.4",
 	"unity": "2019.2",
 	"author": {
 		"name": "Esoteric Software",

+ 1 - 1
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 4.0.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
-	"version": "4.0.3",
+	"version": "4.0.4",
 	"unity": "2019.1",
 	"author": {
 		"name": "Esoteric Software",

+ 3 - 4
spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl

@@ -28,7 +28,7 @@ SAMPLER(sampler_MaskTex);
 struct VertexOutputSpriteURP2D
 {
 	float4 pos : SV_POSITION;
-	fixed4 vertexColor : COLOR;
+	half4 vertexColor : COLOR;
 	float3 texcoord : TEXCOORD0;
 	float2 lightingUV : TEXCOORD1;
 
@@ -89,11 +89,10 @@ 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;
+	half4 main = texureColor * input.vertexColor;
 
 	half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, input.texcoord.xy);
-	half4 pixel = CombinedShapeLightShared(texureColor, mask, input.lightingUV);
+	half4 pixel = half4(CombinedShapeLightShared(half4(main.rgb, 1), mask, input.lightingUV).rgb, main.a);
 
 #if defined(_RIM_LIGHTING)
 	#if defined(_NORMALMAP)

+ 5 - 3
spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-SkeletonLit-URP-2D.shader

@@ -3,6 +3,7 @@
 		[NoScaleOffset] _MainTex ("Main Texture", 2D) = "black" {}
 		[NoScaleOffset] _MaskTex("Mask", 2D) = "white" {}
 		[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
+		[MaterialToggle(_LIGHT_AFFECTS_ADDITIVE)] _LightAffectsAdditive("Light Affects Additive", Float) = 0
 		[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
 		[Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Compare", Float) = 0.0 // Disabled stencil test by default
 	}
@@ -39,6 +40,7 @@
 			#pragma multi_compile USE_SHAPE_LIGHT_TYPE_1 __
 			#pragma multi_compile USE_SHAPE_LIGHT_TYPE_2 __
 			#pragma multi_compile USE_SHAPE_LIGHT_TYPE_3 __
+			#pragma multi_compile _ _LIGHT_AFFECTS_ADDITIVE
 
 			struct Attributes {
 				float3 positionOS : POSITION;
@@ -58,7 +60,6 @@
 			#pragma vertex CombinedShapeLightVertex
 			#pragma fragment CombinedShapeLightFragment
 
-
 			#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl"
 			#define USE_URP
 			#include "../Include/SpineCoreShaders/Spine-Common.cginc"
@@ -106,11 +107,12 @@
 				#endif
 
 				half4 main = tex * i.color;
+			#if !defined(_LIGHT_AFFECTS_ADDITIVE)
 				if (i.color.a == 0)
 					return main;
-
+			#endif
 				half4 mask = SAMPLE_TEXTURE2D(_MaskTex, sampler_MaskTex, i.uv);
-				return CombinedShapeLightShared(main, mask, i.lightingUV);
+				return half4(CombinedShapeLightShared(half4(main.rgb, 1), mask, i.lightingUV).rgb, main.a);
 			}
 
 			ENDHLSL

+ 3 - 0
spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-Sprite-URP-2D.shader

@@ -32,6 +32,8 @@ Shader "Universal Render Pipeline/2D/Spine/Sprite"
 		_BlendTex("Blend Texture", 2D) = "white" {}
 		_BlendAmount("Blend", Range(0,1)) = 0.0
 
+		[MaterialToggle(_LIGHT_AFFECTS_ADDITIVE)] _LightAffectsAdditive("Light Affects Additive", Float) = 0
+
 		[HideInInspector] _SrcBlend("__src", Float) = 1.0
 		[HideInInspector] _DstBlend("__dst", Float) = 0.0
 		[HideInInspector] _RenderQueue("__queue", Float) = 0.0
@@ -82,6 +84,7 @@ Shader "Universal Render Pipeline/2D/Spine/Sprite"
 			#pragma shader_feature _COLOR_ADJUST
 			#pragma shader_feature _RIM_LIGHTING
 			#pragma shader_feature _TEXTURE_BLEND
+			#pragma shader_feature _LIGHT_AFFECTS_ADDITIVE
 
 			#pragma fragmentoption ARB_precision_hint_fastest
 			#pragma multi_compile _ PIXELSNAP_ON

+ 2 - 0
spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ForwardPass-URP.hlsl

@@ -72,6 +72,7 @@ VertexOutput vert(appdata v) {
 #endif
 
 	half3 shadowedColor;
+#if !defined(_LIGHT_AFFECTS_ADDITIVE)
 	if (color.a == 0) {
 		o.color = color;
 #if defined(SKELETONLIT_RECEIVE_SHADOWS)
@@ -80,6 +81,7 @@ VertexOutput vert(appdata v) {
 #endif
 		return o;
 	}
+#endif // !defined(_LIGHT_AFFECTS_ADDITIVE)
 
 	color.rgb *= LightweightLightVertexSimplified(positionWS, normalWS, shadowedColor);
 #if defined(SKELETONLIT_RECEIVE_SHADOWS)

+ 2 - 0
spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-SkeletonLit-URP.shader

@@ -5,6 +5,7 @@
 		[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
 		[Toggle(_RECEIVE_SHADOWS)] _ReceiveShadows("Receive Shadows", Int) = 0
 		[Toggle(_DOUBLE_SIDED_LIGHTING)] _DoubleSidedLighting("Double-Sided Lighting", Int) = 0
+		[MaterialToggle(_LIGHT_AFFECTS_ADDITIVE)] _LightAffectsAdditive("Light Affects Additive", Float) = 0
 		[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
 		[Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Compare", Float) = 0.0 // Disabled stencil test by default
 	}
@@ -45,6 +46,7 @@
 			#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
 			#pragma multi_compile _ _SHADOWS_SOFT
 			#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
+			#pragma multi_compile _ _LIGHT_AFFECTS_ADDITIVE
 
 			// -------------------------------------
 			// Unity defined keywords

+ 3 - 0
spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Sprite-URP.shader

@@ -38,6 +38,8 @@ Shader "Universal Render Pipeline/Spine/Sprite"
 		_BlendTex("Blend Texture", 2D) = "white" {}
 		_BlendAmount("Blend", Range(0,1)) = 0.0
 
+		[MaterialToggle(_LIGHT_AFFECTS_ADDITIVE)] _LightAffectsAdditive("Light Affects Additive", Float) = 0
+
 		[HideInInspector] _SrcBlend("__src", Float) = 1.0
 		[HideInInspector] _DstBlend("__dst", Float) = 0.0
 		[HideInInspector] _RenderQueue("__queue", Float) = 0.0
@@ -92,6 +94,7 @@ Shader "Universal Render Pipeline/Spine/Sprite"
 			#pragma shader_feature _TEXTURE_BLEND
 			#pragma shader_feature _FOG
 			#pragma shader_feature _RECEIVE_SHADOWS_OFF
+			#pragma shader_feature _LIGHT_AFFECTS_ADDITIVE
 
 			#pragma fragmentoption ARB_precision_hint_fastest
 			#pragma multi_compile_fog

+ 1 - 1
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 4.0.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
-  "version": "4.0.3",
+  "version": "4.0.4",
   "unity": "2019.3",
   "author": {
     "name": "Esoteric Software",