Constant BLOB_TRACK

Source
const BLOB_TRACK: &str = r#"
uniform vec3 u_blob;
void main() {
    vec2 uv = gl_FragCoord.xy / u_res;
    vec4 src = texture(tex, uv);
    vec4 res = src;
    if (p4 >= 0.5) {
        float d = distance(src.rgb, clamp(vec3(p0, p1, p2) / 255.0, 0.0, 1.0));
        float tol = clamp(p3, 0.0, 1.0) * 1.2;
        float hit = 1.0 - smoothstep(tol, tol + 0.05, d);
        res = vec4(mix(src.rgb, vec3(1.0, 0.25, 0.25), hit * 0.5), src.a);
        if (u_blob.z > 0.0) {
            vec2 dxy = abs(uv - u_blob.xy) * u_res;
            float lw = max(1.0, u_scale);
            float arm = 16.0 * max(u_scale, 0.25);
            float cross_ = ((dxy.y <= lw && dxy.x <= arm) || (dxy.x <= lw && dxy.y <= arm)) ? 1.0 : 0.0;
            res = vec4(mix(res.rgb, vec3(1.0, 1.0, 0.2), cross_), max(res.a, cross_));
        }
    }
    float m = u_has_mask > 0.5 ? texture(u_mask, uv).r : 1.0;
    out_color = mix(src, res, m);
}
"#;
Expand description

Overlay for the colour tracker: tints everything within Tolerance of the target and draws a crosshair at the centroid.

Extra uniform gpu.rs must bind: vec3 u_blob = (cx, cy, area) from engine::effects::track, cx/cy in 0..1 layer coordinates and area <= 0 when nothing was found (then only the mask shows).