Color Masque
Designed for 2D Sprites in Godot and supports masqueing color(s) within a given threshold. If a color is found that is within the threshold the user sets replace the found color(s) with the masque color.
The shader is non-destructive if no color(s) match the parameters given.
Screenshots show a simple purple color masque. In which I’m masque the color purple with green
Shader code
uniform vec3 color_to_replace = vec3(152.0, 91.0, 255.0);
uniform vec3 masque = vec3(28.0, 255.0, 28.0);
uniform float threshold = 0.31;
void fragment() {
COLOR = texture(TEXTURE, UV);
if (distance(COLOR.rgb, normalize(color_to_replace)) < threshold) {
// Replace the color
COLOR.rgb = normalize(masque);
}
}