Palette Shader
Converts an image to a color pallete.
Shader code
shader_type canvas_item;
void fragment(){
vec3 palette[] = {vec3(0)}; // Can be any list of RGB colors, but there must be at least one.
vec3 color = texture(TEXTURE,UV).rgb;
vec3 new_color = palette[0];
for (int i = 0; i<pallete.length(); i++){
if (distance(palette[i],color) < distance(new_color, color)){
new_color = palette[i];
}
COLOR.rgb = new_color;
COLOR.a = texture(TEXTURE,UV).a
}
}
Nice job but, at line 6 you put ‘pallete’ and the correct is ‘palette’
Also the sprite get black and I can´t change the color =(
How do I use it? How to apply colors to palette?