# 【暗角】
画面四周显示黑色暗角。
对应的 Shader 文件 ScreenAfterEffectShader3.shader
Shader "Hidden/ScreenAfterEffectShader3"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_VignetteIntensity("暗角强度",Range(0.05,3.0)) = 1.5
_VignetteRoundness("暗角圆大小",Range(1.0,6.0)) = 5.0
_VignetteSmoothness("暗角平滑度",Range(0.05,5.0)) = 5.0
}
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
float _VignetteIntensity;
float _VignetteRoundness;
float _VignetteSmoothness;
fixed4 frag (v2f_img i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
float2 d = abs(i.uv - half2(0.5,0.5)) * _VignetteIntensity;
d = pow(saturate(d),_VignetteRoundness);
float dist = length(d);
float vdactor = pow(saturate(1.0 - dist * dist),_VignetteSmoothness);
return col * vdactor.xxxx;
}
ENDCG
}
}
}