Shader "Custom/Effect_RongJie"
{
Properties
{
_MianTex("MainTex", 2D) = ""{}
_NoiseTex("NoiseTex", 2D) = ""{}
_NoiseValue("NoiseValue", Range(0,1)) = 0
_Edgree("Edgree", Range(0,0.2)) = 0
_FirstColor("FirstColor", Color) = (1,1,1,1)
_SecondColor("SecondColor", Color) = (1,1,1,1)
}
SubShader
{
Tags{"Queue"="Transparent"}
Cull Off
pass
{
Tags{"LightMode"="ForwardBase"}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f
{
float4 pos : SV_POSITION;
float4 uv : TEXCOORD0;
};
sampler2D _MianTex;
float4 _MianTex_ST;
sampler2D _NoiseTex;
float4 _NoiseTex_ST;
float _NoiseValue;
float _Edgree;
fixed4 _FirstColor;
fixed4 _SecondColor;
v2f vert(appdata_base v)
{
v2f f;
f.pos = UnityObjectToClipPos(v.vertex);
f.uv.xy = TRANSFORM_TEX(v.texcoord.xy, _MianTex);
f.uv.zw = TRANSFORM_TEX(v.texcoord.xy, _NoiseTex);
return f;
}
fixed4 frag(v2f i) : SV_TARGET
{
float noise = tex2D(_NoiseTex, i.uv.zw).r;
clip(noise - _NoiseValue);
float edgree = saturate((noise - _NoiseValue) / _Edgree);
fixed4 edgreeColor = lerp(_FirstColor, _SecondColor, edgree);
float4 Mian = tex2D(_MianTex, i.uv.xy);
float4 col = lerp(edgreeColor, Mian, edgree);
return fixed4(col.rgb, 1);
}
ENDCG
}
pass
{
Tags{"LightMode"="ShadowCaster"}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_shadowcaster
#include "UnityCG.cginc"
struct v2f
{
V2F_SHADOW_CASTER;
float2 uv : TEXCOORD0;
};
sampler2D _NoiseTex;
float _NoiseValue;
v2f vert(appdata_base v)
{
v2f f;
f.uv = v.texcoord.xy;
TRANSFER_SHADOW_CASTER_NORMALOFFSET(f)
return f;
}
fixed4 frag(v2f i) : SV_TARGET
{
fixed4 noiseClip = tex2D(_NoiseTex, i.uv);
clip(noiseClip - _NoiseValue);
SHADOW_CASTER_FRAGMENT(i)
}
ENDCG
}
}
}