Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Range("Range",Range(0,1))=0
_FadeRange("FadeRange",Range(3,100))=3
}
SubShader
{
Tags { "RenderType"="Opaque" }
Blend srcAlpha OneMinusSrcAlpha
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 _FadeRange;
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-1);
float x=i.uv.y;
if(_Range<1)
x=smoothstep(abs(1-_Range),1,x);
else
x=1;
fixed3 target=col;
return fixed4(target,_FadeRange*x);
}
ENDCG
}
}