Radial Blur

Shader code
shader_type canvas_item;

uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;

uniform float intensity : hint_range(0.0, 2.0) = 1.0;
uniform float falloff : hint_range(0.0, 1.0) = 0.5;
uniform int samples : hint_range(0, 64) = 16;
uniform vec2 center = vec2(0.5, 0.5);

void fragment() {
	vec2 uv = SCREEN_UV;
	vec2 dir = uv - clamp(center, vec2(0.0), vec2(1.0));

	float dist = length(dir) * 2.0;
	float fall = pow(min(dist, 1.0), 3.0 * falloff);
	float step_scale = intensity / float(samples) * 0.05;

	vec4 color = texture(screen_texture, uv);

	for (int i = 1; i <= samples; i++) {
		float fi = float(i);
		float offset = fi * step_scale * fall;
		color += texture(screen_texture, uv - dir * offset);
	}

	color /= float(samples + 1);
	COLOR = color;
}
Live Preview
Tags
blur, motion blur, radial blur
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

Radial Blur

Radial Blur Shader

3D Radial Motion Blur Shader For Propellers and Wheels

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments