You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.1 KiB
71 lines
1.1 KiB
Shader "Hidden/RadialBlur" |
|
{ |
|
Properties { |
|
_MainTex ("Base (RGB)", 2D) = "" {} |
|
} |
|
|
|
// Shader code pasted into all further CGPROGRAM blocks |
|
CGINCLUDE |
|
|
|
#include "UnityCG.cginc" |
|
|
|
struct v2f { |
|
float4 pos : SV_POSITION; |
|
float2 uv : TEXCOORD0; |
|
float2 blurVector : TEXCOORD1; |
|
}; |
|
|
|
sampler2D _MainTex; |
|
|
|
float4 _BlurRadius4; |
|
float4 _SunPosition; |
|
|
|
float4 _MainTex_TexelSize; |
|
|
|
v2f vert( appdata_img v ) { |
|
v2f o; |
|
o.pos = UnityObjectToClipPos(v.vertex); |
|
o.uv.xy = v.texcoord.xy; |
|
|
|
o.blurVector = (_SunPosition.xy - v.texcoord.xy) * _BlurRadius4.xy; |
|
|
|
return o; |
|
} |
|
|
|
#define SAMPLES_FLOAT 6.0f |
|
#define SAMPLES_INT 6 |
|
|
|
half4 frag(v2f i) : SV_Target |
|
{ |
|
half4 color = half4(0,0,0,0); |
|
|
|
for(int j = 0; j < SAMPLES_INT; j++) |
|
{ |
|
half4 tmpColor = tex2D(_MainTex, i.uv.xy); |
|
color += tmpColor; |
|
|
|
i.uv.xy += i.blurVector; |
|
} |
|
|
|
return color / SAMPLES_FLOAT; |
|
} |
|
|
|
ENDCG |
|
|
|
Subshader |
|
{ |
|
Blend One Zero |
|
Pass { |
|
ZTest Always Cull Off ZWrite Off |
|
|
|
CGPROGRAM |
|
#pragma vertex vert |
|
#pragma fragment frag |
|
|
|
ENDCG |
|
} // Pass |
|
} // Subshader |
|
|
|
Fallback off |
|
|
|
} // shader
|
|
|