Having trouble blurring a texture using shaders

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By denxi

Currently I’m using the following shader in a ColorRect that’s over top of my Sprite to blur said Sprite:

shader_type canvas_item;

uniform float blur_amount = 2.0;

void fragment()
	{
    COLOR = textureLod(SCREEN_TEXTURE, SCREEN_UV, blur_amount);
    }

I’d prefer to simply use a shader attached to the Sprite itself to blur it. I tried using a modified version of the previous code;

shader_type canvas_item;

uniform float blur_amount = 2.0;

void fragment()
    {
    COLOR = textureLod(TEXTURE, UV, blur_amount);
    }

but nothing changes. Obviously I’m misunderstanding something here, if someone could fill me in I’d appreciate it.

:bust_in_silhouette: Reply From: kidscancode

textureLod() will work, but you must import your texture with “Mipmaps” enabled.

textureLod() is slow in android, Is there any alternative?

supper_raptor | 2020-05-01 09:47

You could look at the example in GitHub - godotengine/godot-demo-projects: Demonstration and Template Projects

It uses an averaging of the pixels within a certain radius. The shader can be found here.

kidscancode | 2020-05-01 16:00