根据RGB通道颜色决定优先消融的色块
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Range("Range",Range(0,1))=0
_Speed("Speed",Range(0,1))=0
}
SubShader
{
Tags { "RenderType"="AlphaTest" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float _Range;
float _Speed;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
_Range+=_Time.y*_Speed;
clip(col.r-_Range);
return col;
}
ENDCG
}
}