// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "RadialBlur" {
	Properties{
		_MainTex("Main Tex",2D) = "while"{}
		//_Intensity("Intensity", Range(1,10)) = 10
		_Center_Params("Center", Vector) = (0.5, 0.5, 0, 0)
	}
		SubShader{
			Pass
			{
				HLSLPROGRAM
			   #pragma vertex vert
			   #pragma fragment frag
			   sampler2D _MainTex;
			   //float _Intensity;
			   float4 _Center_Params;

			    #define Center  _Center_Params.xy
				#define Intensity  _Center_Params.z

				#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" 
				#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
				#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl" 

			   struct appdata
			   {
				   float4 vertex : POSITION;
				   float2 uv : TEXCOORD0;
			   };

				struct v2f {
					half4 vertex : POSITION;
					half2 uv : TEXCOORD;
				};

				v2f vert(appdata v) {
					v2f o;
					o.vertex = TransformObjectToHClip(v.vertex.xyz);
					o.uv = v.uv;
					return o;
				}

				half4 frag(v2f i) : SV_Target{
					half4 c;
					half2 uv = i.uv - Center;
					half3 c1 = half3(0,0,0);
					for (half j = 0; j < Intensity; j++) {
						c1 += tex2D(_MainTex,uv * (1 - 0.02 * j) + Center).rgb;
					}
					c.rgb = c1 / Intensity;
					c.a = 1;
					return c;
				}
				ENDHLSL
			}
		}
}