2020-12-14 02:56:35 +00:00
|
|
|
Shader "Custom/MaskedUIBlur" {
|
2020-12-12 00:02:00 +00:00
|
|
|
Properties {
|
|
|
|
|
_Size ("Blur", Range(0, 30)) = 1
|
|
|
|
|
[HideInInspector] _MainTex ("Masking Texture", 2D) = "white" {}
|
|
|
|
|
_AdditiveColor ("Additive Tint color", Color) = (0, 0, 0, 0)
|
|
|
|
|
_MultiplyColor ("Multiply Tint color", Color) = (1, 1, 1, 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Category {
|
|
|
|
|
|
|
|
|
|
// We must be transparent, so other objects are drawn before this one.
|
|
|
|
|
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Opaque" }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SubShader
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
ZTest Off
|
|
|
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
Cull Off
|
|
|
|
|
Lighting Off
|
|
|
|
|
ZWrite Off
|
|
|
|
|
ZTest [unity_GUIZTestMode]
|
|
|
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
|
|
|
|
|
|
|
|
Pass
|
|
|
|
|
{
|
|
|
|
|
CGPROGRAM
|
|
|
|
|
#pragma vertex vert
|
|
|
|
|
#pragma fragment frag
|
|
|
|
|
#pragma fragmentoption ARB_precision_hint_fastest
|
|
|
|
|
#include "UnityCG.cginc"
|
|
|
|
|
|
|
|
|
|
struct appdata_t {
|
2020-12-14 02:56:35 +00:00
|
|
|
float4 vertex : POSITION;
|
|
|
|
|
float4 color : COLOR;
|
2020-12-12 00:02:00 +00:00
|
|
|
float2 texcoord : TEXCOORD0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct v2f {
|
|
|
|
|
float4 vertex : POSITION;
|
2020-12-14 02:56:35 +00:00
|
|
|
fixed4 color : COLOR;
|
2020-12-12 00:02:00 +00:00
|
|
|
float4 uvgrab : TEXCOORD0;
|
|
|
|
|
float2 uvmain : TEXCOORD1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
sampler2D _MainTex;
|
|
|
|
|
float4 _MainTex_ST;
|
|
|
|
|
float4 _MultiplyColor;
|
|
|
|
|
|
|
|
|
|
v2f vert (appdata_t v) {
|
|
|
|
|
v2f o;
|
|
|
|
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
|
|
|
|
|
2020-12-14 02:56:35 +00:00
|
|
|
// #if UNITY_UV_STARTS_AT_TOP
|
|
|
|
|
// float scale = -1.0;
|
|
|
|
|
// #else
|
|
|
|
|
// float scale = 1.0;
|
|
|
|
|
// #endif
|
2020-12-12 00:02:00 +00:00
|
|
|
|
2020-12-14 02:56:35 +00:00
|
|
|
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y) + o.vertex.w) * 0.5;
|
2020-12-12 00:02:00 +00:00
|
|
|
o.uvgrab.zw = o.vertex.zw;
|
|
|
|
|
|
|
|
|
|
o.uvmain = TRANSFORM_TEX(v.texcoord, _MainTex);
|
2020-12-14 02:56:35 +00:00
|
|
|
o.color = v.color * _MultiplyColor;
|
2020-12-12 00:02:00 +00:00
|
|
|
|
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-14 02:56:35 +00:00
|
|
|
sampler2D _CameraBlur;
|
|
|
|
|
float4 _CameraBlur_TexelSize;
|
2020-12-12 00:02:00 +00:00
|
|
|
float _Size;
|
|
|
|
|
float4 _AdditiveColor;
|
|
|
|
|
|
|
|
|
|
half4 frag( v2f i ) : COLOR
|
|
|
|
|
{
|
2020-12-14 02:56:35 +00:00
|
|
|
half4 sum = tex2D( _CameraBlur, UNITY_PROJ_COORD(float4(i.uvgrab.x, i.uvgrab.y, i.uvgrab.z, i.uvgrab.w)).xy);
|
|
|
|
|
|
|
|
|
|
half4 result = half4(sum.r * i.color.r + _AdditiveColor.r,
|
|
|
|
|
sum.g * i.color.g + _AdditiveColor.g,
|
|
|
|
|
sum.b * i.color.b + _AdditiveColor.b,
|
|
|
|
|
tex2D(_MainTex, i.uvmain).a * i.color.a);
|
2020-12-12 00:02:00 +00:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
ENDCG
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|