Forráskód Böngészése

Merge branch '3.7-beta' into 3.7-beta-cpp

badlogic 7 éve
szülő
commit
d8dfa62016
15 módosított fájl, 126 hozzáadás és 217 törlés
  1. 14 0
      CHANGELOG.md
  2. 10 3
      spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Shaders/Spine-Skeleton-Fill.shader
  3. 9 2
      spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Shaders/Spine-Skeleton-Tint.shader
  4. 0 9
      spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Shaders/Straight Alpha.meta
  5. 0 56
      spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Shaders/Straight Alpha/Spine-Straight-Skeleton-Fill.shader
  6. 0 9
      spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Shaders/Straight Alpha/Spine-Straight-Skeleton-Fill.shader.meta
  7. 0 99
      spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Shaders/Straight Alpha/Spine-Straight-Skeleton-Tint.shader
  8. 0 7
      spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Shaders/Straight Alpha/Spine-Straight-Skeleton-Tint.shader.meta
  9. 8 1
      spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/Shaders/Spine-SkeletonGraphic-TintBlack.shader
  10. 10 2
      spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/Shaders/Spine-SkeletonGraphic.shader
  11. 7 0
      spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SlotBlendModes/Spine-Skeleton-PMA-Multiply.shader
  12. 7 0
      spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SlotBlendModes/Spine-Skeleton-PMA-Screen.shader
  13. 8 1
      spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton-TintBlack.shader
  14. 44 27
      spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton.shader
  15. 9 1
      spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-SkeletonLit.shader

+ 14 - 0
CHANGELOG.md

@@ -98,6 +98,20 @@
 *  **SpineAtlasAsset** The existing `AtlasAsset` type has been renamed to `SpineAtlasAsset` to signify that it specifically uses a Spine/libGDX atlas as its source. Serialization should be intact but user code will need to be updated to refer to existing atlases as `SpineAtlasAsset`.
 	* **AtlasAssetBase** `SpineAtlasAsset` now has an abstract base class called `SpineAtlasAsset`. This is the base class to derive when using alternate atlas sources. Existing SkeletonDataAsset field "atlasAssets" now have the "AtlasAssetBase" type. Serialization should be intact, but user code will need to be updated to refer to the atlas assets accordingly.
 	* This change is in preparation for alternate atlas options such as Unity's SpriteAtlas.
+* **Optional Straight Alpha for shaders** Spine-Unity's included Unity shaders now have a `_STRAIGHT_ALPHA_INPUT` shader_feature, toggled as a checkbox in the Material's inspector. This allows the Material to use a non-premultiplied alpha/straight alpha input texture.
+	* The following shaders now have the "Straight Alpha Texture" checkbox when used on a material:
+		* `Spine/Skeleton`
+		* `Spine/Skeleton Tint Black`
+		* `Spine/Skeleton Lit`
+		* `Spine/Skeleton Tint`	
+		* `Spine/Skeleton Fill`
+		* `Spine/SkeletonGraphic (Premultiply Alpha)` was renamed to `Spine/SkeletonGraphic`
+		* `Spine/SkeletonGraphic Tint Black (Premultiply Alpha)` was renamed to `Spine/SkeletonGraphic Tint Black`
+		* `Spine/Skeleton PMA Multiply`
+		* `Spine/Skeleton PMA Screen`
+	* Dedicated straight alpha shaders were removed from the runtime.
+		* `Spine/Straight Alpha/Skeleton Fill`
+		* `Spine/Straight Alpha/Skeleton Tint`
 
 ### XNA/MonoGame
 * Added support for any `Effect` to be used by `SkeletonRenderer`

+ 10 - 3
spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Shaders/Spine-Skeleton-Fill.shader

@@ -1,12 +1,13 @@
 // - Unlit + no shadow
-// - Premultiplied Alpha Blending (One OneMinusSrcAlpha)
+// - Premultiplied Alpha Blending (Optional straight alpha input)
 // - Double-sided, no depth
 
 Shader "Spine/Skeleton Fill" {
 	Properties {
 		_FillColor ("FillColor", Color) = (1,1,1,1)
 		_FillPhase ("FillPhase", Range(0, 1)) = 0
-		[NoScaleOffset]_MainTex ("MainTex", 2D) = "white" {}
+		[NoScaleOffset] _MainTex ("MainTex", 2D) = "white" {}
+		[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
 	}
 	SubShader {
 		Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
@@ -17,6 +18,7 @@ Shader "Spine/Skeleton Fill" {
 
 		Pass {
 			CGPROGRAM
+			#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
 			#pragma vertex vert
 			#pragma fragment frag
 			#include "UnityCG.cginc"
@@ -40,13 +42,18 @@ Shader "Spine/Skeleton Fill" {
 				VertexOutput o = (VertexOutput)0;
 				o.uv = v.uv;
 				o.vertexColor = v.vertexColor;
-				o.pos = UnityObjectToClipPos(v.vertex); // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
+				o.pos = UnityObjectToClipPos(v.vertex);
 				return o;
 			}
 
 			float4 frag (VertexOutput i) : COLOR {
 				float4 rawColor = tex2D(_MainTex,i.uv);
 				float finalAlpha = (rawColor.a * i.vertexColor.a);
+
+				#if defined(_STRAIGHT_ALPHA_INPUT)
+				rawColor.rgb *= rawColor.a;
+				#endif
+
 				float3 finalColor = lerp((rawColor.rgb * i.vertexColor.rgb), (_FillColor.rgb * finalAlpha), _FillPhase); // make sure to PMA _FillColor.
 				return fixed4(finalColor, finalAlpha);
 			}

+ 9 - 2
spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Shaders/Spine-Skeleton-Tint.shader

@@ -1,7 +1,7 @@
 // Spine/Skeleton Tint
 // - Two color tint
 // - unlit
-// - Premultiplied alpha blending
+// - Premultiplied alpha blending (Optional straight alpha input)
 // - No depth, no backface culling, no fog.
 
 Shader "Spine/Skeleton Tint" {
@@ -9,6 +9,7 @@ Shader "Spine/Skeleton Tint" {
 		_Color ("Tint Color", Color) = (1,1,1,1)
 		_Black ("Black Point", Color) = (0,0,0,0)
 		[NoScaleOffset] _MainTex ("MainTex", 2D) = "black" {}
+		[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
 		_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
 	}
 
@@ -23,6 +24,7 @@ Shader "Spine/Skeleton Tint" {
 
 		Pass {
 			CGPROGRAM
+			#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
 			#pragma vertex vert
 			#pragma fragment frag
 			#include "UnityCG.cginc"
@@ -44,7 +46,7 @@ Shader "Spine/Skeleton Tint" {
 
 			VertexOutput vert (VertexInput v) {
 				VertexOutput o;
-				o.pos = UnityObjectToClipPos(v.vertex); // replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
+				o.pos = UnityObjectToClipPos(v.vertex);
 				o.uv = v.uv;
 				o.vertexColor = v.vertexColor * float4(_Color.rgb * _Color.a, _Color.a); // Combine a PMA version of _Color with vertexColor.
 				return o;
@@ -52,6 +54,11 @@ Shader "Spine/Skeleton Tint" {
 
 			float4 frag (VertexOutput i) : COLOR {
 				float4 texColor = tex2D(_MainTex, i.uv);
+
+				#if defined(_STRAIGHT_ALPHA_INPUT)
+				texColor.rgb *= texColor.a;
+				#endif
+
 				return (texColor * i.vertexColor) + float4(((1-texColor.rgb) * _Black.rgb * texColor.a*_Color.a*i.vertexColor.a), 0);
 			}
 			ENDCG

+ 0 - 9
spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Shaders/Straight Alpha.meta

@@ -1,9 +0,0 @@
-fileFormatVersion: 2
-guid: d6f7e10049c6d6348ae5c92ccb3825e0
-folderAsset: yes
-timeCreated: 1521392482
-licenseType: Free
-DefaultImporter:
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 56
spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Shaders/Straight Alpha/Spine-Straight-Skeleton-Fill.shader

@@ -1,56 +0,0 @@
-// - Unlit + no shadow
-// - Double-sided, no depth
-
-Shader "Spine/Straight Alpha/Skeleton Fill" {
-	Properties {
-		_FillColor ("FillColor", Color) = (1,1,1,1)
-		_FillPhase ("FillPhase", Range(0, 1)) = 0
-		[NoScaleOffset]_MainTex ("MainTex", 2D) = "white" {}
-	}
-	SubShader {
-		Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
-		Blend One OneMinusSrcAlpha
-		Cull Off
-		ZWrite Off
-		Lighting Off
-
-		Pass {
-			CGPROGRAM
-			#pragma vertex vert
-			#pragma fragment frag
-			#include "UnityCG.cginc"
-			sampler2D _MainTex;
-			float4 _FillColor;
-			float _FillPhase;
-
-			struct VertexInput {
-				float4 vertex : POSITION;
-				float2 uv : TEXCOORD0;
-				float4 vertexColor : COLOR;
-			};
-
-			struct VertexOutput {
-				float4 pos : SV_POSITION;
-				float2 uv : TEXCOORD0;
-				float4 vertexColor : COLOR;
-			};
-
-			VertexOutput vert (VertexInput v) {
-				VertexOutput o = (VertexOutput)0;
-				o.uv = v.uv;
-				o.vertexColor = v.vertexColor;
-				o.pos = UnityObjectToClipPos(v.vertex);
-				return o;
-			}
-
-			float4 frag (VertexOutput i) : COLOR {
-				float4 rawColor = tex2D(_MainTex,i.uv);
-				float finalAlpha = (rawColor.a * i.vertexColor.a);
-				float3 finalColor = lerp((rawColor.rgb * i.vertexColor.rgb * rawColor.a), (_FillColor.rgb * finalAlpha), _FillPhase);
-				return fixed4(finalColor, finalAlpha);
-			}
-			ENDCG
-		}
-	}
-	FallBack "Diffuse"
-}

+ 0 - 9
spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Shaders/Straight Alpha/Spine-Straight-Skeleton-Fill.shader.meta

@@ -1,9 +0,0 @@
-fileFormatVersion: 2
-guid: ec3c686f972ccf5459c2b55555e6635f
-timeCreated: 1492385797
-licenseType: Free
-ShaderImporter:
-  defaultTextures: []
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 99
spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Shaders/Straight Alpha/Spine-Straight-Skeleton-Tint.shader

@@ -1,99 +0,0 @@
-// - Two color tint
-// - unlit
-// - No depth, no backface culling, no fog.
-
-Shader "Spine/Straight Alpha/Skeleton Tint" {
-	Properties {
-		_Color ("Tint Color", Color) = (1,1,1,1)
-		_Black ("Black Point", Color) = (0,0,0,0)
-		[NoScaleOffset] _MainTex ("MainTex", 2D) = "black" {}
-		_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
-	}
-
-	SubShader {
-		Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
-
-		Fog { Mode Off }
-		Cull Off
-		ZWrite Off
-		Blend One OneMinusSrcAlpha
-		Lighting Off
-
-		Pass {
-			CGPROGRAM
-			#pragma vertex vert
-			#pragma fragment frag
-			#include "UnityCG.cginc"
-			sampler2D _MainTex;
-			float4 _Color;
-			float4 _Black;
-
-			struct VertexInput {
-				float4 vertex : POSITION;
-				float2 uv : TEXCOORD0;
-				float4 vertexColor : COLOR;
-			};
-
-			struct VertexOutput {
-				float4 pos : SV_POSITION;
-				float2 uv : TEXCOORD0;
-				float4 vertexColor : COLOR;
-			};
-
-			VertexOutput vert (VertexInput v) {
-				VertexOutput o;
-				o.pos = UnityObjectToClipPos(v.vertex); // replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
-				o.uv = v.uv;
-				o.vertexColor = v.vertexColor * float4(_Color.rgb * _Color.a, _Color.a); // Combine a PMA version of _Color with vertexColor.
-				return o;
-			}
-
-			float4 frag (VertexOutput i) : COLOR {
-				float4 texColor = tex2D(_MainTex, i.uv);
-				texColor = float4(texColor.rgb * texColor.a, texColor.a);
-				return (texColor * i.vertexColor) + float4(((1-texColor.rgb) * _Black.rgb * texColor.a*_Color.a*i.vertexColor.a), 0);
-			}
-			ENDCG
-		}
-
-		Pass {
-			Name "Caster"
-			Tags { "LightMode"="ShadowCaster" }
-			Offset 1, 1
-			ZWrite On
-			ZTest LEqual
-
-			Fog { Mode Off }
-			Cull Off
-			Lighting Off
-
-			CGPROGRAM
-			#pragma vertex vert
-			#pragma fragment frag
-			#pragma multi_compile_shadowcaster
-			#pragma fragmentoption ARB_precision_hint_fastest
-			#include "UnityCG.cginc"
-			sampler2D _MainTex;
-			fixed _Cutoff;
-
-			struct VertexOutput { 
-				V2F_SHADOW_CASTER;
-				float2 uv : TEXCOORD1;
-			};
-
-			VertexOutput vert (appdata_base v) {
-				VertexOutput o;
-				o.uv = v.texcoord;
-				TRANSFER_SHADOW_CASTER(o)
-				return o;
-			}
-
-			float4 frag (VertexOutput i) : COLOR {
-				fixed4 texcol = tex2D(_MainTex, i.uv);
-				clip(texcol.a - _Cutoff);
-				SHADOW_CASTER_FRAGMENT(i)
-			}
-			ENDCG
-		}
-	}
-}

+ 0 - 7
spine-unity/Assets/Spine/Runtime/spine-unity/Modules/Shaders/Straight Alpha/Spine-Straight-Skeleton-Tint.shader.meta

@@ -1,7 +0,0 @@
-fileFormatVersion: 2
-guid: c9a84b3418d033a4f9749511a6ac36d6
-ShaderImporter:
-  defaultTextures: []
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 8 - 1
spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/Shaders/Spine-SkeletonGraphic-TintBlack.shader

@@ -1,10 +1,12 @@
 // This is a premultiply-alpha adaptation of the built-in Unity shader "UI/Default" to allow Unity UI stencil masking.
 
-Shader "Spine/SkeletonGraphic Tint Black (Premultiply Alpha)"
+Shader "Spine/SkeletonGraphic Tint Black"
 {
 	Properties
 	{
 		[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
+		[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
+
 		_Color ("Tint", Color) = (1,1,1,1)
 		_Black ("Black Point", Color) = (0,0,0,0)
 
@@ -50,6 +52,7 @@ Shader "Spine/SkeletonGraphic Tint Black (Premultiply Alpha)"
 		Pass
 		{
 		CGPROGRAM
+			#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
 			#pragma vertex vert
 			#pragma fragment frag
 
@@ -104,6 +107,10 @@ Shader "Spine/SkeletonGraphic Tint Black (Premultiply Alpha)"
 			{
 				half4 texColor = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd);
 
+				#if defined(_STRAIGHT_ALPHA_INPUT)
+				texColor.rgb *= texColor.a;
+				#endif
+
 				texColor.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
 
 				#ifdef UNITY_UI_ALPHACLIP

+ 10 - 2
spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SkeletonGraphic/Shaders/Spine-SkeletonGraphic.shader

@@ -1,10 +1,11 @@
 // This is a premultiply-alpha adaptation of the built-in Unity shader "UI/Default" in Unity 5.6.2 to allow Unity UI stencil masking.
 
-Shader "Spine/SkeletonGraphic (Premultiply Alpha)"
+Shader "Spine/SkeletonGraphic"
 {
 	Properties
 	{
 		[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
+		[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
 		_Color ("Tint", Color) = (1,1,1,1)
 		
 		_StencilComp ("Stencil Comparison", Float) = 8
@@ -49,6 +50,7 @@ Shader "Spine/SkeletonGraphic (Premultiply Alpha)"
 		Pass
 		{
 		CGPROGRAM
+			#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
 			#pragma vertex vert
 			#pragma fragment frag
 			#pragma target 2.0
@@ -99,7 +101,13 @@ Shader "Spine/SkeletonGraphic (Premultiply Alpha)"
 
 			fixed4 frag (VertexOutput IN) : SV_Target
 			{
-				half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
+				half4 texColor = tex2D(_MainTex, IN.texcoord);
+
+				#if defined(_STRAIGHT_ALPHA_INPUT)
+				texColor.rgb *= texColor.a;
+				#endif
+
+				half4 color = (texColor + _TextureSampleAdd) * IN.color;
 
 				color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
 

+ 7 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SlotBlendModes/Spine-Skeleton-PMA-Multiply.shader

@@ -11,6 +11,7 @@ Shader "Spine/Skeleton PMA Multiply" {
 	Properties {
 		_Color ("Tint Color", Color) = (1,1,1,1)
 		[NoScaleOffset] _MainTex ("MainTex", 2D) = "black" {}
+		[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
 		_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
 	}
 
@@ -26,6 +27,7 @@ Shader "Spine/Skeleton PMA Multiply" {
 
 		Pass {
 			CGPROGRAM
+			#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
 			#pragma vertex vert
 			#pragma fragment frag
 			#include "UnityCG.cginc"
@@ -54,6 +56,11 @@ Shader "Spine/Skeleton PMA Multiply" {
 
 			float4 frag (VertexOutput i) : COLOR {
 				float4 texColor = tex2D(_MainTex, i.uv);
+				
+				#if defined(_STRAIGHT_ALPHA_INPUT)
+				texColor.rgb *= texColor.a;
+				#endif
+
 				return (texColor * i.vertexColor);
 			}
 			ENDCG

+ 7 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Modules/SlotBlendModes/Spine-Skeleton-PMA-Screen.shader

@@ -9,6 +9,7 @@ Shader "Spine/Skeleton PMA Screen" {
 	Properties {
 		_Color ("Tint Color", Color) = (1,1,1,1)
 		[NoScaleOffset] _MainTex ("MainTex", 2D) = "black" {}
+		[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
 		_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
 	}
 
@@ -24,6 +25,7 @@ Shader "Spine/Skeleton PMA Screen" {
 
 		Pass {
 			CGPROGRAM
+			#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
 			#pragma vertex vert
 			#pragma fragment frag
 			#include "UnityCG.cginc"
@@ -52,6 +54,11 @@ Shader "Spine/Skeleton PMA Screen" {
 
 			float4 frag (VertexOutput i) : COLOR {
 				float4 texColor = tex2D(_MainTex, i.uv);
+
+				#if defined(_STRAIGHT_ALPHA_INPUT)
+				texColor.rgb *= texColor.a;
+				#endif
+
 				return (texColor * i.vertexColor);
 			}
 			ENDCG

+ 8 - 1
spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton-TintBlack.shader

@@ -3,7 +3,7 @@
 // - UV2 and UV3 as Black Tint color.
 // - Final black tint is (UV black data and _Black/"Black Point")
 // - unlit
-// - Premultiplied alpha blending
+// - Premultiplied alpha blending (optional straight alpha input)
 // - No depth, no backface culling, no fog.
 
 Shader "Spine/Skeleton Tint Black" {
@@ -11,6 +11,7 @@ Shader "Spine/Skeleton Tint Black" {
 		_Color ("Tint Color", Color) = (1,1,1,1)
 		_Black ("Black Point", Color) = (0,0,0,0)
 		[NoScaleOffset] _MainTex ("MainTex", 2D) = "black" {}
+		[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
 		_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
 	}
 
@@ -26,6 +27,7 @@ Shader "Spine/Skeleton Tint Black" {
 
 		Pass {
 			CGPROGRAM
+			#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
 			#pragma vertex vert
 			#pragma fragment frag
 			#include "UnityCG.cginc"
@@ -61,6 +63,11 @@ Shader "Spine/Skeleton Tint Black" {
 
 			float4 frag (VertexOutput i) : COLOR {
 				float4 texColor = tex2D(_MainTex, i.uv);
+				
+				#if defined(_STRAIGHT_ALPHA_INPUT)
+				texColor.rgb *= texColor.a;
+				#endif
+
 				return (texColor * i.vertexColor) + float4(((1-texColor.rgb) * (_Black.rgb + float3(i.uv1.r, i.uv1.g, i.uv2.r)) * texColor.a*_Color.a*i.vertexColor.a), 0);
 			}
 			ENDCG

+ 44 - 27
spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-Skeleton.shader

@@ -2,10 +2,11 @@ Shader "Spine/Skeleton" {
 	Properties {
 		_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
 		[NoScaleOffset] _MainTex ("Main Texture", 2D) = "black" {}
+		[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
 	}
 
 	SubShader {
-		Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane"}
+		Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
 
 		Fog { Mode Off }
 		Cull Off
@@ -14,11 +15,43 @@ Shader "Spine/Skeleton" {
 		Lighting Off
 
 		Pass {
-			Fog { Mode Off }
-			ColorMaterial AmbientAndDiffuse
-			SetTexture [_MainTex] {
-				Combine texture * primary
+			CGPROGRAM
+			#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
+			#pragma vertex vert
+			#pragma fragment frag
+			#include "UnityCG.cginc"
+			sampler2D _MainTex;
+
+			struct VertexInput {
+				float4 vertex : POSITION;
+				float2 uv : TEXCOORD0;
+				float4 vertexColor : COLOR;
+			};
+
+			struct VertexOutput {
+				float4 pos : SV_POSITION;
+				float2 uv : TEXCOORD0;
+				float4 vertexColor : COLOR;
+			};
+
+			VertexOutput vert (VertexInput v) {
+				VertexOutput o;
+				o.pos = UnityObjectToClipPos(v.vertex);
+				o.uv = v.uv;
+				o.vertexColor = v.vertexColor;
+				return o;
+			}
+
+			float4 frag (VertexOutput i) : COLOR {
+				float4 texColor = tex2D(_MainTex, i.uv);
+
+				#if defined(_STRAIGHT_ALPHA_INPUT)
+				texColor.rgb *= texColor.a;
+				#endif
+
+				return (texColor * i.vertexColor);
 			}
+			ENDCG
 		}
 
 		Pass {
@@ -41,19 +74,19 @@ Shader "Spine/Skeleton" {
 			sampler2D _MainTex;
 			fixed _Cutoff;
 
-			struct v2f { 
+			struct VertexOutput { 
 				V2F_SHADOW_CASTER;
-				float2  uv : TEXCOORD1;
+				float2 uv : TEXCOORD1;
 			};
 
-			v2f vert (appdata_base v) {
-				v2f o;
-				TRANSFER_SHADOW_CASTER(o)
+			VertexOutput vert (appdata_base v) {
+				VertexOutput o;
 				o.uv = v.texcoord;
+				TRANSFER_SHADOW_CASTER(o)
 				return o;
 			}
 
-			float4 frag (v2f i) : COLOR {
+			float4 frag (VertexOutput i) : COLOR {
 				fixed4 texcol = tex2D(_MainTex, i.uv);
 				clip(texcol.a - _Cutoff);
 				SHADOW_CASTER_FRAGMENT(i)
@@ -61,20 +94,4 @@ Shader "Spine/Skeleton" {
 			ENDCG
 		}
 	}
-
-	SubShader {
-		Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
-
-		Cull Off
-		ZWrite Off
-		Blend One OneMinusSrcAlpha
-		Lighting Off
-
-		Pass {
-			ColorMaterial AmbientAndDiffuse
-			SetTexture [_MainTex] {
-				Combine texture * primary DOUBLE, texture * primary
-			}
-		}
-	}
 }

+ 9 - 1
spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Spine-SkeletonLit.shader

@@ -1,11 +1,12 @@
 // - Vertex Lit + ShadowCaster
-// - Premultiplied Alpha Blending (One OneMinusSrcAlpha)
+// - Premultiplied Alpha Blending (Optional straight alpha input)
 // - Double-sided, no depth
 
 Shader "Spine/Skeleton Lit" {
 	Properties {
 		_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
 		[NoScaleOffset] _MainTex ("Main Texture", 2D) = "black" {}
+		[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
 	}
 
 	SubShader {
@@ -38,6 +39,7 @@ Shader "Spine/Skeleton Lit" {
 			Blend One OneMinusSrcAlpha
 
 			CGPROGRAM
+			#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
 			#pragma vertex vert
 			#pragma fragment frag
 			#pragma target 2.0
@@ -135,7 +137,13 @@ Shader "Spine/Skeleton Lit" {
 				fixed4 tex = tex2D(_MainTex, i.uv0);
 
 				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;
 				return col;