Shader "BF/PostEffect/RadialBlur" { Properties { _MainTex("MainTex", 2D) = "white"{} _BlurRadius("BlurRadius", Float)=0 _RadialCenter("RadialCenter", Vector)=(0,0,0,0) } SubShader { Cull Off ZWrite Off ZTest Always CGINCLUDE #include "UnityCG.cginc" sampler2D _MainTex; float _BlurRadius; float2 _RadialCenter; struct a2v { float4 vertex : POSITION; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : SV_POSITION; half2 texcoord : TEXCOORD0; }; v2f vert(a2v v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.texcoord = v.texcoord; return o; } // fixed4 frag(v2f i) : SV_TARGET // { // float2 uv = i.texcoord - _RadialCenter; // half scale = 1; // half4 color = tex2D(_MainTex, uv * scale + _RadialCenter); // scale = _BlurRadius + 1; // color += tex2D(_MainTex, uv * scale + _RadialCenter); // scale = 2 * _BlurRadius + 1; // color += tex2D(_MainTex, uv * scale + _RadialCenter); // scale = 3 * _BlurRadius + 1; // color += tex2D(_MainTex, uv * scale + _RadialCenter); // color *= 0.25f; // return color; // } half4 frag(v2f i): SV_Target { float2 uv = i.texcoord - _RadialCenter; half scale = 1; half4 color = tex2D(_MainTex, uv * scale + _RadialCenter); //1 MAD scale = _BlurRadius + 1; //1 MAD color += tex2D(_MainTex, uv * scale + _RadialCenter); //1 MAD scale = 2 * _BlurRadius + 1; //1 MAD color += tex2D(_MainTex, uv * scale + _RadialCenter); //1 MAD scale = 3 * _BlurRadius + 1; //1 MAD color += tex2D(_MainTex, uv * scale + _RadialCenter); //1 MAD scale = 4 * _BlurRadius + 1; //1 MAD color += tex2D(_MainTex, uv * scale + _RadialCenter); //1 MAD scale = 5 * _BlurRadius + 1; //1 MAD color += tex2D(_MainTex, uv * scale + _RadialCenter); //1 MAD color *= 0.1667f; // 1/6 return color; } ENDCG Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag ENDCG } } }