Constant COLOR_REPLACE

Source
const COLOR_REPLACE: &str = r#"
void main() {
    vec2 uv = gl_FragCoord.xy / u_res;
    vec4 src = texture(tex, uv);
    vec3 from = clamp(vec3(p0, p1, p2) / 255.0, 0.0, 1.0);
    vec3 to = clamp(vec3(p3, p4, p5) / 255.0, 0.0, 1.0);
    float tol = clamp(p6, 0.0, 1.0);
    float soft = max(clamp(p7, 0.0, 1.0), 0.0005);
    float d = distance(src.rgb, from) / 1.7320508;
    float hit = 1.0 - smoothstep(tol, tol + soft, d);
    vec4 res = vec4(mix(src.rgb, to, hit), src.a);
    float m = u_has_mask > 0.5 ? texture(u_mask, uv).r : 1.0;
    out_color = mix(src, res, m);
}
"#;
Expand description

Replace one colour with another: RGB distance to the source colour, faded out over Tolerance .. Tolerance + Softness (distance normalised so 1.0 is black-to-white).