Hey! I'm trying to make a shader like this:
Here's my pathetic attempt at getting somewhere near that:
shader_type canvas_item;
uniform sampler2D palette_texture;
uniform float palette_number;
uniform float total_palettes : hint_range(1, 12);
void fragment(){
vec4 referenceColors[12];
for (int ind = 0; ind < 12; ind++) {
/* referenceColors[ind] = vec4(float(ind), 0.2, 0.2, 1); */
/* referenceColors[ind] = texture(palette_texture, vec2(float(ind%4), 0.2)); */
referenceColors[ind] = vec4(float(1/(ind%4)), 0.2, 0.2, 1);
}
vec4 textureColor = texture(TEXTURE, UV);
COLOR.rgb = referenceColors[int(floor(textureColor.r * float(total_palettes)))].rgb;
COLOR.a = textureColor.a;
}
If you have suggestions for better ways to do something similar, please let me know also!