+1 vote

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.

asked Apr 30 in Engine by denxi (403 points)

1 Answer

0 votes
Best answer

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

answered Apr 30 by kidscancode (17,762 points)
selected May 1 by denxi

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

You could look at the example in https://github.com/godotengine/godot-demo-projects

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.