2D spine动画 消融

接到新的需求   spine 要做一个死亡消融的动画,美术的意思最好是在原来的基础改下。增加一个贴图让他们控制消融形式

 思路   1,用一张燥波图做为消融贴图

            2,消融不要出现层次错乱的问题 

特别注意, 渲染层次问题,!!!

 

hader "Spine/Skeleton/2Ddissolve"
{
	Properties {
	    _Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
		[NoScaleOffset] _MainTex ("Main Texture", 2D) = "black" {}
		_DissolveTex ("Dissolution texture", 2D) = "gray" {}
		_Threshold ("Threshold", Range(0., 1.01)) = 0.1
	
	}

	SubShader {

	//	Tags { "Queue"="Transparent" }
	//	Blend SrcAlpha OneMinusSrcAlpha
		Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane"}
	     Fog { Mode Off }
		Cull Off
		ZWrite Off
		//Blend One OneMinusSrcAlpha
		Blend SrcAlpha OneMinusSrcAlpha
		Lighting Off
		Pass {
			
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag

			#include "UnityCG.cginc"

			
			sampler2D _DissolveTex;
			float4   _DissolveTex_ST;
			sampler2D _MainTex;
			float4 _MainTex_ST;
			float _Threshold;
			



			struct v2f {
				float4 pos : SV_POSITION;
				float2 uv : TEXCOORD0;
				float2 uv1 : TEXCOORD1;
			};
			
			

			v2f vert(appdata_base v) {
				v2f o;
				o.pos = UnityObjectToClipPos(v.vertex);
				//o.uv = v.texcoord;
				o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
				o.uv1 = TRANSFORM_TEX(v.texcoord, _DissolveTex);
				return o;
			}


			fixed4 frag(v2f i) : SV_Target {
				float4 c = tex2D(_MainTex, i.uv);
				float val = tex2D(_DissolveTex, i.uv1).r;

				c.a *= step(_Threshold, val);
				return c;
			}
			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 v2f { 
				V2F_SHADOW_CASTER;
				float2  uv : TEXCOORD1;
			};

			v2f vert (appdata_base v) {
				v2f o;
				TRANSFER_SHADOW_CASTER(o)
				o.uv = v.texcoord;
				return o;
			}

			float4 frag (v2f i) : COLOR {
				fixed4 texcol = tex2D(_MainTex, i.uv);
				clip(texcol.a - _Cutoff);
				SHADOW_CASTER_FRAGMENT(i)
			}
			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
			}
		}
	}
}

 

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页