Constant LEVELS

Source
const LEVELS: &str = r#"
void main() {
    vec2 uv = gl_FragCoord.xy / u_res;
    vec4 src = texture(tex, uv);
    vec3 c = clamp((src.rgb - p0) / max(p1 - p0, 0.0001), 0.0, 1.0);
    c = pow(c, vec3(1.0 / max(p2, 0.01)));
    c = clamp(p3 + c * (p4 - p3), 0.0, 1.0);
    vec4 res = vec4(c, src.a);
    float m = u_has_mask > 0.5 ? texture(u_mask, uv).r : 1.0;
    out_color = mix(src, res, m);
}
"#;
Expand description

In black/white, gamma, out black/white (same convention as Color’s gamma: v^(1/g)).