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

20 lines
897 B
Metal

// Whatever moves lights up and the glow lingers. The heat is carried from frame to frame
// in the alpha channel of this effect's own previous output.
// order 50
// slider sensitivity 1.0 30.0 10.0
// slider linger 0.5 0.99 0.93
// slider dim 0.0 1.0 0.45
// slider hue 0.0 1.0 0.07
// hue 0..1 -> a fully saturated colour (0 red, 0.08 orange, 0.33 green, 0.66 blue)
static float3 hueColor(float h) {
return clamp(abs(fract(h + float3(0.0, 2.0 / 3.0, 1.0 / 3.0)) * 6.0 - 3.0) - 1.0, 0.0, 1.0);
}
float4 effect(float2 uv, Inputs in) {
float moved = length(in.camera.sample(in.smp, uv).rgb - in.last.sample(in.smp, uv).rgb);
float fresh = smoothstep(0.3, 1.0, moved * in.p.sensitivity);
float heat = max(in.prev.sample(in.smp, uv).a * in.p.linger, fresh);
float3 glow = hueColor(in.p.hue);
return float4(in.image.sample(in.smp, uv).rgb * in.p.dim + glow * heat, heat);
}