motionlab/effects/kaleidoscope.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

13 lines
616 B
Metal

// Folds the picture into mirrored wedges around the centre.
// order 90
// slider segments 2.0 16.0 6.0
// slider spin -2.0 2.0 0.2
float4 effect(float2 uv, Inputs in) {
float2 shape = float2(in.resolution.x / in.resolution.y, 1.0);
float2 c = (uv - 0.5) * shape;
float wedge = 6.2832 / floor(in.p.segments);
float a = atan2(c.y, c.x) + in.time * in.p.spin;
a = abs(a - wedge * floor(a / wedge) - wedge * 0.5) - 1.5708; // fold into one mirrored wedge, pointing up
float2 from = float2(cos(a), sin(a)) * length(c) / shape + 0.5;
return float4(in.image.sample(in.smp, from).rgb, 1.0);
}