hi, i followed this tutorial here: https://www.youtube.com/watch?v=ME6of_bGkKY
after fixing obvious bugs (stupidly forgot to put one "i" in the for loop :D) and tinkering around, my sprite 2D still get's colored completely in the last color of the new color palette.
as recommended in the comments i changed the if statement block in the custom code part and checked any settings that could fiddle around with the pixel art.
i'm at a loss here because i never touched shaders before and literally have no idea of specifics code wise.
and yes, i checked if the code change is the problem, the original gives the same output.
if needed, here is the whole code (in the video it's never fully clear in one shot) including the change mentioned above:
vec2 new_uv = vec2(0, 0);
for (int i = 0; i < colors_count; i++) {
float u = (float(i) + 0.5) / float(colors_count);
float v = 0.5;
vec2 uv = vec2(u, v);
vec4 original_palette_color = texture(original_palette, uv);
float dist = distance(color, original_palette_color);new_uv = mix(new_uv, uv, step(0.0, dist)); #<- here was the original if statement}
new_color = texture(new_palette, new_uv);
this is the original if statement:
if (dist == 0.0) {
new_uv = uv;
break;
}
if anybody could help, that would be cool, i will share the solution in the comment section of the tutorial video for the poor souls that have the same problem.
edit: i forgot the fact that the transparent color works, only non transparent pixels all have the same color.
it's the first color of the palette, if that is of some significance.
Palette swap visual shader in Godot 4 is a great way to recolor sprites in real time, without needing to redraw whole spritesheets. It saves time and makes you game size smaller. All you need is one spritesheet, the original palette, and new palettes for recoloring. Learn how to export the palettes you need from Aseprite, create the palette swap...