Blurry texture (image) in shader

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


I had no issue with Godot 3, but I upgraded my project to Godot 4, since then I can’t get my image to be sharp as it should be.

I loaded my image texture without compression:

But then I get this blurry image:

In Godot 3, I simply disabled the filter:

Then everything worked:

Is this a bug? Or did I do something wrong?
I would happily open an issue on their github, but they already have 7000+ open issues…

I don’t see the images

Kirito | 2023-03-11 22:29

I’m sorry, it was working for me.
I changed the hosting website.
I also changed the content, because I was wrong about the alpha channel, it’s actually blur all the time.

bl0ggy | 2023-03-11 22:56

:bust_in_silhouette: Reply From: bl0ggy

Okay so it seems it’s not possible to do it anymore in the visual shaders with Godot 4, I haven’t found how to do.
The only way that worked is to create a textual shader and add filter_nearest like the following:

uniform sampler2D textureImage: filter_nearest;
:bust_in_silhouette: Reply From: Anselme

I found a way to set a nearest filter on a texture in a visual shader.

By changing the texture source to “SamplerPort”, and plugging it to a Texture2DParameter with its filter option set to “Nearest”.


the generated shader code matches what you expect :

shader_type spatial;
uniform sampler2D Texture2DParameter : filter_nearest;

Well done! But sad it has to be so complex :confused:

bl0ggy | 2023-04-15 15:16