Radial Blur Shader

A radial blur shader.

Shader code
/*
	放射状ブラーエフェクト by あるる(きのもと 結衣) @arlez80
	Radial Blur Effect by Yui Kinomoto

	MIT License
*/
shader_type canvas_item;

// 発射中央部
uniform vec2 blur_center = vec2( 0.5, 0.5 );
// ブラー強度
uniform float blur_power : hint_range( 0.0, 1.0 ) = 0.01;
// サンプリング回数
uniform int sampling_count : hint_range( 1, 64 ) = 6;

void fragment( )
{
	vec2 direction = SCREEN_UV - blur_center;
	vec3 c = vec3( 0.0, 0.0, 0.0 );
	float f = 1.0 / float( sampling_count );
	for( int i=0; i < sampling_count; i++ ) {
		c += texture( SCREEN_TEXTURE, SCREEN_UV - blur_power * direction * float(i) ).rgb * f;
	}
	COLOR.rgb = c;
}
Live Preview
Tags
blur, radial
The shader code and all code snippets in this post are under MIT license and can be used freely. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from arlez80

Related shaders

guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Instructions
1 year ago

Well made, thanks for sharing!

Zombyra
Zombyra
1 year ago

Updated for Godot 4.3
/*
   Radial Blur Effect by Yui Kinomoto
   MIT License
*/
shader_type canvas_item;
uniform vec2 blur_center = vec2( 0.5, 0.5 );
uniform float blur_power : hint_range( 0.0, 1.0 ) = 0.01;
uniform int sampling_count : hint_range( 1, 64 ) = 6;
uniform sampler2D texturescreen : hint_screen_texture;

void fragment( )
{
   vec2 direction = SCREEN_UV – blur_center;
   vec3 c = vec3( 0.0, 0.0, 0.0 );
   float f = 1.0 / float( sampling_count );
   for( int i=0; i < sampling_count; i++ ) {
       c += texture( texturescreen, SCREEN_UV – blur_power * direction * float(i) ).rgb * f;
   }
   COLOR.rgb = c;
}