Constant PIXELATE

Source
const PIXELATE: &str = r#"
void main() {
    vec2 uv = gl_FragCoord.xy / u_res;
    vec4 src = texture(tex, uv);
    float b = max(p0, 1.0) * max(u_scale, 0.01);
    vec4 res = src;
    if (b > 1.0) {
        vec2 q = (floor(gl_FragCoord.xy / b) + 0.5) * b;
        res = texture(tex, q / u_res);
    }
    float m = u_has_mask > 0.5 ? texture(u_mask, uv).r : 1.0;
    out_color = mix(src, res, m);
}
"#;
Expand description

Snap to a p0-project-px block grid and sample its centre.