My Shader is making my pixel art blurry

Godot Version

v4.4.1

Question

Shaders continue to be the absolute bane of my existence. I’m trying to replicate what is shown in the below two videos in Godot. There is a Youtube Shorts version and a longer video. The TLDR is dynamic coloring at runtime via some kind of post-processing shader (I think I’m getting all those terms right).

Short
Full Video

The issue I’m running into is that the shader makes the images blurry. I have a source, a color map, and a color lookup table, which I have pasted below.

When I set a Sprite’s texture to one of these, it appears as clear as in the above images. I made a canvas shader for the next step though and it appears blurry, as shown below.

This is the entire shader:

shader_type canvas_item;

uniform sampler2D lookup_texture;

void fragment() {
	COLOR = texture(lookup_texture, UV);
}

It seems like it’s appearing as though the texture filter were set to linear instead of nearest, but I can’t seem to find a way to confirm or deny that, let alone fix it. Any help would be greatly appreciated.

Hi,

Try specifying the nearest filtering in the sampler declaration:

uniform sampler2D lookup_texture: filter_nearest;
1 Like

This worked, thank you. Do you just know that from experience, or is a good place in the docs to find something like that? I wasn’t able to find any good sources from googling.

1 Like

I believe I’ve learnt that on this page: Shading language — Godot Engine (stable) documentation in English, which is just a huge list of Godot’s shader language features. I obviously did not read it fully, but I’m used to documentations like this so I guess I just looked for the filtering info when I needed it for the first time :smile:

1 Like

I have a video tutorial on this topic. In it, I explain the use of parameters for sampler2D in shaders, so it might be useful.