pub const PIXELATE_EFFECT: &str = "fn effect(uv: vec2f, _src: vec4f) -> vec4f {\n let aspect = resolution().x / resolution().y;\n if params.shape == 0u {\n let cells = vec2f(max(params.blocks, 2.0), max(params.blocks / aspect, 2.0));\n return sample_src((floor(uv * cells) + vec2f(0.5)) / cells);\n }\n // Pointy-top hexagons `1 / blocks` of the output wide, rounded to the nearest center in cube\n // coordinates; positions in output heights.\n let size = aspect / max(params.blocks, 2.0) / 1.7320508;\n let p = (uv - 0.5) * vec2f(aspect, 1.0) / size;\n let q = vec2f(p.x * 0.57735027 - p.y / 3.0, p.y * 0.66666667);\n let cube = vec3f(q.x, q.y, -q.x - q.y);\n var r = round(cube);\n let d = abs(r - cube);\n if d.x > d.y && d.x > d.z {\n r.x = -r.y - r.z;\n } else if d.y > d.z {\n r.y = -r.x - r.z;\n }\n let center = vec2f(1.7320508 * r.x + 0.8660254 * r.y, 1.5 * r.y) * size;\n return sample_src(center / vec2f(aspect, 1.0) + 0.5);\n}\n";Expand description
Built-in pixelation body.