Luma Key: Key Out Brighter and Darker cut hard at Threshold, as After Effects

After Effects' Luma Key removes everything darker (or brighter) than Threshold
and ignores Tolerance for those two key types; Tolerance only sets the band of
Key Out Similar / Dissimilar. EffectCraft ramped the matte over Tolerance, so
case 719 (a 50 % grey, Key Out Darker, Threshold 140, Tolerance 20) kept about
80 % of the layer where AE keys it out completely.

Measured in AE 2026 on a vertical grey ramp (cases 812-814): Darker keys up to
level 139.9 and keeps 140.1 (EffectCraft now the same row); Similar keys levels
120.3-160.0; with Edge Thin 1 / Edge Feather 2.5 the matte rises over rows
591-596 (EffectCraft within 0.2 of AE's alpha there). CPU and GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vangel76
2026-10-19 16:15:02 +02:00
co-authored by Claude Opus 5.5
parent dc9f15ada1
commit 39bd0efac2
3 changed files with 65 additions and 49 deletions
+4 -14
View File
@@ -199,23 +199,13 @@ fn fxk_point(@builtin(global_invocation_id) gid: vec3<u32>) {
let thr = f0.x;
let tol = f0.y;
var m: f32;
// As effects::keying::luma_key: Brighter / Darker cut hard at the threshold
// (Tolerance only shapes Similar / Dissimilar), as After Effects.
switch u0.y {
case 0u: {
if (tol > 0.0) {
m = clamp((thr + tol - l) / tol, 0.0, 1.0);
} else {
m = select(1.0, 0.0, l > thr);
}
}
case 0u: { m = select(1.0, 0.0, l > thr); }
case 2u: { m = select(1.0, 0.0, abs(l - thr) <= tol); }
case 3u: { m = select(0.0, 1.0, abs(l - thr) <= tol); }
default: {
if (tol > 0.0) {
m = clamp((l - (thr - tol)) / tol, 0.0, 1.0);
} else {
m = select(1.0, 0.0, l < thr);
}
}
default: { m = select(1.0, 0.0, l < thr); }
}
o = vec4<f32>(m);
}