原文链接:http://www.manew.com/thread-100656-1-1.html
Shader "Custom/ImageEffects"
{
Properties
{
_MainTex("Main Tex", 2D) = "white" {}
_MaskColor("Mask Color", color) = (1, 1, 1, 1)
_Speed("Speed", float) = 2
_MaskLimit("MaskLimit", float) = 0.8
}
SubShader
{
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
Pass
{
Tags { "LightMode" = "ForwardBase" }
ZTest off
ZWrite off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#define PI 3.1415962653
sampler2D _MainTex;
fixed3 _MaskColor;
float _Speed;
float _MaskLimit;
struct a2v
{
float4 vertex : POSITION;
float3 texcoord : TEXCOORD0;
};
struct v2f
{
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
v2f vert(a2v v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 c = tex2D(_MainTex, i.uv);
float isMask = sin(_Time.y * _Speed - i.uv.x * 2 * PI);
isMask = step(_MaskLimit, isMask);
c.rgb += _MaskColor * isMask;
return c;
}
ENDCG
}
}
FallBack "Diffuse"
}