如下:
Shader "A/WaveShader"
{
Properties
{
_MainTex("MainTex", 2D) = "white"{}
_NoiseTex("NoiseTex", 2D) = "white"{}
_Cutout("Cutout", Range(-0.1, 1.1)) = 0.0
_Speed("Speed", Vector) = (1, 1, 0, 0)
}
SubShader
{
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex: POSITION;
float2 uv: TEXCOORD0;
};
struct v2f
{
float4 pos: SV_POSITION;
float2 uv: TEXCOORD0;
};
sampler2D _MainTex;
sampler2D _NoiseTex;
float _Cutout;
float4 _Speed;
v2f vert(appdata v)
{
v2f o;
float4 pos_clip = UnityObjectToClipPos(v.vertex);
o.pos = pos_clip;
o.uv = v.uv;
return o;
}
half4 frag(v2f i) : SV_Target
{
half gradient = tex2D(_MainTex, i.uv + _Time.y * _Speed.xy).r;
half noise = tex2D(_NoiseTex, i.uv + _Time.y * _Speed.zw).r;
clip(gradient - noise - _Cutout);
return noise.xxxx;
}
ENDCG
}
}
}