Files
JJBB/Assets/Project/GameRes/AlwaysInclude/BlindShader.shader

76 lines
1.4 KiB
Plaintext
Raw Normal View History

2024-08-23 15:49:34 +08:00
Shader "Zhanyou/BlindEffect" {
Properties {
_MainTex("Base (RGB)", 2D) = "white" {}
LightNum("Light", Range(0.0, 1.0)) = 1.0
RadiuRange("Radiu", Range(0.0, 0.5)) = 0.7
}
SubShader {
Tags
{
"IgnoreProjector"="True"
"Queue"="Overlay"
// 防止Shader Replace渲染这个东西
"RenderType"="NoReplace"
}
Pass {
Lighting Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
float LightNum;
float RadiuRange;
struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
struct v2f
{
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord;
o.color = v.color;
return o;
}
fixed4 frag(v2f i) : COLOR
{
fixed4 renderTex = tex2D(_MainTex, i.texcoord);
fixed4 finalColor = renderTex;
float2 center = float2(0.5, 0.45);
float dis = distance(i.texcoord, center);
if (dis >= RadiuRange)
{
finalColor = renderTex * LightNum;
}
else
{
if (dis < RadiuRange )
{
finalColor = renderTex * (LightNum + 1 - dis/RadiuRange);
}
}
return finalColor;
}
ENDCG
}
}
}