Palette cycler / swapper ignores colors

Godot Version

4

Question

im using the palette swapper by > KoBeWi

im having issues where it is ignoring random colors.

ive noticed that using the index of the palette which is 11 colors long it only swaps the colors at 0, 5, and 10, and skips all others


ive set the second palette to a bright solid color so i coud see exaclty which colors werent being swapped. i havent done anything with the shader code wise.

shader_type canvas_item;

uniform sampler2D palette;
uniform bool skip_first_row = true;
uniform bool use_palette_alpha = false;
uniform float fps = 6;

void fragment() {
	vec4 original_color = texture(TEXTURE, UV);
	ivec3 colori = ivec3(round(original_color.rgb * 255.0));
	
	ivec2 color_count = textureSize(palette, 0);
	
	float idx = -1.0;
	for (int i = 0; i < color_count.x; i++) {
		vec3 color2 = texture(palette, vec2(float(i) / float(color_count.x - 1), 0)).rgb;
		ivec3 colori2 = ivec3(round(color2 * 255.0));
		
		if (colori == colori2) {
			idx = float(i);
			break;
		}
	}
	
	if (idx >= 0.0) {
		vec2 uv;
		uv.x = idx / float(color_count.x - 1);
		uv.y = (mod(TIME * fps, max(float(color_count.y - 1 - int(skip_first_row)), 1.0)) + float(skip_first_row))  / float(color_count.y - 1);
		
		vec4 palette_color = texture(palette, uv);
		COLOR = vec4(palette_color.rgb, mix(original_color.a, palette_color.a, float(use_palette_alpha)));
	} else {
		COLOR = original_color;
	}
}

if fixed it by adding : filter_nearest; to the palette.

apparently shaders use their own texture filter that ignores the filter set in the project settings. why? why is the “global” texture filter option in project settings NOT global.
last i checked global means everywhere.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.