+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.

in Engine by (429 points)

1 Answer

0 votes
Best answer

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

by (18,383 points)
selected by

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories