Shader "WSP/FrameWork7"
{
Properties
{
[Header(Base Color Group)]
[Space(10)]
_Color("Color",Color) = (0,0,0,0)
_Tex("MainTex",2D) = "White" {}
[Space(15)]
[Header(Dissolve Group)]
[Space(10)]
[Toggle]_DissolveEnabled("DissolveEnabled",int) = 0
_Dissolve("DissolveTex",2D) = "White" {}
[NoScaleOffset]_RampTex("Ramp(RGB)",2D) = "White" {}
_Clip("Clip",Range(0,1)) = 0
}
SubShader
{
pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile _ _DISSOLVEENABLED_ON
#include "UnityCG.cginc"
sampler2D _Tex;
fixed4 _Color;
sampler2D _Dissolve;float4 _Dissolve_ST;
fixed _Clip;
sampler _RampTex;
struct appdata
{
float4 vertex :POSITION;
float4 uv :TEXCOORD;
};
struct v2f
{
float4 pos :POSITION;
float4 uv :TEXCOORD;
};
v2f vert(appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv.xy = v.uv.xy;
//o.uv.zw = v.uv *_Dissolve_ST.xy+_Dissolve_ST.zw;
o.uv.zw = TRANSFORM_TEX(v.uv,_Dissolve);
return o;
}
fixed4 frag(v2f i):SV_TARGET
{
fixed4 c;
fixed4 tex = tex2D(_Tex,i.uv.xy);
c = tex;
c += _Color;
#if _DISSOLVEENABLED_ON
fixed4 dissolveUV = tex2D(_Dissolve,i.uv.zw);
clip(dissolveUV-_Clip);
fixed dissolveValue = saturate((dissolveUV-_Clip)/(_Clip+0.1-_Clip));
fixed4 rampTex = tex1D(_RampTex,dissolveValue);
c += rampTex;
#endif
return c;
}
ENDCG
}
}
}