shader_type canvas_item;
render_mode unshaded;

uniform vec4 original_0: source_color;
uniform vec4 original_1: source_color;
uniform vec4 original_2: source_color;
uniform vec4 original_3: source_color;
uniform vec4 original_4: source_color;
uniform vec4 original_5: source_color;
uniform vec4 original_6: source_color;
uniform vec4 replace_0: source_color;
uniform vec4 replace_1: source_color;
uniform vec4 replace_2: source_color;
uniform vec4 replace_3: source_color;
uniform vec4 replace_4: source_color;
uniform vec4 replace_5: source_color;
uniform vec4 replace_6: source_color;

uniform vec4 tint: source_color = vec4(1.0);

const float precision = 0.1;
const int Colz = 7;

vec4 swap_color(vec4 color){
	vec4 original_colors[Colz] = vec4[Colz] (original_0, original_1, original_2, original_3, original_4, original_5, original_6);
	vec4 replace_colors[Colz] = vec4[Colz] (replace_0, replace_1, replace_2, replace_3, replace_4, replace_5, replace_6);
	for (int i = 0; i < Colz; i ++) {
		if (distance(color, original_colors[i]) <= precision){
			return replace_colors[i];
		}
	}
	return color;
}


void fragment() {
	vec4 col = swap_color(texture(TEXTURE, UV));
	//#COLOR = mix(col, tint, 1.0);
	COLOR = col * tint;
}




















