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);
    }
}
Tags
masque
The shader code and all code snippets in this post are under MIT license and can be used freely. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

color splash (show only one color)

Color remover

Smooth Color Gradient

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments