效果图:
原理:
现在状态不佳,等状态好再详细写
代码:
Shader "Hidden/NewImageEffectShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Noise ("Noise", 2D) = "white"{}
_Crl ("Crl",Range(0,1)) = 0.5
}
SubShader
{
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float2 uv1 : TEXCOORD1;
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
o.uv1 = v.uv;
return o;
}
sampler2D _MainTex;
sampler2D _Noise;
float _Crl;
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
fixed noise = tex2D(_Noise,i.uv1).b;
clip(noise - _Crl);
if(noise-_Crl<0.1)
{
return lerp(fixed4(1,0,0,1), fixed4(0,0,0,1),(noise - _Crl)*10);
}
return col;
}
ENDCG
}
}
}