Constant CROP

Source
const CROP: &str = r#"
void main() {
    vec2 uv = gl_FragCoord.xy / u_res;
    vec4 src = texture(tex, uv);
    vec2 q = uv * u_res;
    float x0 = clamp(p0, 0.0, 0.5) * u_res.x;
    float x1 = u_res.x - clamp(p1, 0.0, 0.5) * u_res.x;
    float y0 = clamp(p2, 0.0, 0.5) * u_res.y;
    float y1 = u_res.y - clamp(p3, 0.0, 0.5) * u_res.y;
    float d = min(min(q.x - x0, x1 - q.x), min(q.y - y0, y1 - q.y));
    float fe = clamp(p4, 0.0, 0.5) * min(u_res.x, u_res.y);
    float a = d <= 0.0 ? 0.0 : (fe > 0.0 ? min(d / fe, 1.0) : 1.0);
    vec4 res = vec4(src.rgb, src.a * a);
    float m = u_has_mask > 0.5 ? texture(u_mask, uv).r : 1.0;
    out_color = mix(src, res, m);
}
"#;
Expand description

Left/Right/Top/Bottom fractions cut away (alpha 0) with a p4 feather.