motionlab/effects/halftone.metal
0xrsydn a20d3310db Go native-only: remove the Python POC, move the Swift app to the top level
Adds --check (compile every effect without camera or window), EFFECTS.md
(the contract for writing effects) and AGENTS.md. The POC stays available
at the 'poc' tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 20:33:18 +07:00

18 lines
779 B
Metal

// Halftone dots sized by brightness; dots turn hot orange wherever something moves.
// order 70
// slider cell 4.0 40.0 12.0
// slider heat 0.0 20.0 8.0
float4 effect(float2 uv, Inputs in) {
float2 grid = in.resolution / in.p.cell;
float2 centre = (floor(uv * grid) + 0.5) / grid;
float3 c = in.image.sample(in.smp, centre).rgb;
float luma = dot(c, float3(0.299, 0.587, 0.114));
float radius = 0.5 * sqrt(luma);
float dist = length(fract(uv * grid) - 0.5);
float mask = 1.0 - smoothstep(radius - 0.05, radius + 0.05, dist);
float moved = length(in.camera.sample(in.smp, centre).rgb - in.last.sample(in.smp, centre).rgb);
float3 hot = mix(c, float3(1.0, 0.35, 0.1), clamp(moved * in.p.heat, 0.0, 1.0));
return float4(hot * mask, 1.0);
}