Shader "Geri/Blur" { Properties { _Radius("Radius", Range(0, 4)) = 1 [HideInInspector] _MainTex ("Sprite Texture", 2D) = "white" {} } Category { Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Opaque" } SubShader { GrabPass { Tags { "LightMode" = "Always" } } Pass { Tags { "LightMode" = "Always" } CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma fragmentoption ARB_precision_hint_fastest #include "Blur.cginc" sampler2D _GrabTexture; float4 _GrabTexture_TexelSize; float _Radius; int _Enabled; half4 first_pass(v2f i) { half4 sum = half4(0, 0, 0, 0); sum += GRABXYPIXEL(0.0, 0.0); int measurments = 1; for (float range = 1.f; range <= _Radius * 2; range += 1.f) { sum += GRABXYPIXEL(range, range); sum += GRABXYPIXEL(-range, range); sum += GRABXYPIXEL(range, 0); sum += GRABXYPIXEL(0, range); measurments += 4; } half4 color = sum / measurments; i.color.a *= _Radius / 4.0; color = i.color * i.color.a + color * (1 - i.color.a); return color; } half4 frag(v2f i) : COLOR { return first_pass(i); } ENDCG } } } }