From a8ed8ca7749643887394363789b269ea47f78a07 Mon Sep 17 00:00:00 2001 From: jayzed80 Date: Sat, 31 Oct 2026 09:45:18 +0000 Subject: [PATCH 01/20] fix(effects): parse_cube rejects a hostile LUT_3D_SIZE before cubing it --- crates/effects/src/utility.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/effects/src/utility.rs b/crates/effects/src/utility.rs index e41b42e99..17f0a243b 100644 --- a/crates/effects/src/utility.rs +++ b/crates/effects/src/utility.rs @@ -202,9 +202,12 @@ pub fn parse_cube(text: &str) -> Option { _ => rows.push(three(&mut it)?), } } + if lut.n3 > 256 { + return None; + } let need1 = lut.n1; let need3 = lut.n3 * lut.n3 * lut.n3; - if (lut.n1 == 0 && lut.n3 == 0) || lut.n1 == 1 || lut.n3 == 1 || rows.len() != need1 + need3 || lut.n3 > 256 { + if (lut.n1 == 0 && lut.n3 == 0) || lut.n1 == 1 || lut.n3 == 1 || Some(rows.len()) != need1.checked_add(need3) { return None; } lut.d1 = rows[..need1].to_vec(); @@ -464,6 +467,10 @@ mod tests { fn bad_cube_is_passthrough() { assert!(parse_cube("LUT_3D_SIZE 2\n0 0 0\n1 1 1\n").is_none()); assert!(parse_cube("LUT_3D_SIZE 2\n0 0 zz\n").is_none()); + // A hostile size must be rejected, not overflow `n3^3` or `n1 + n3^3`. + assert!(parse_cube("LUT_3D_SIZE 4294967296\n0 0 0\n").is_none()); + assert!(parse_cube(&format!("LUT_3D_SIZE {}\n0 0 0\n", usize::MAX)).is_none()); + assert!(parse_cube(&format!("LUT_1D_SIZE {}\nLUT_3D_SIZE 2\n0 0 0\n", usize::MAX)).is_none()); let img = test_img(); let out = run("ec.utility.applylut", &[("lut", Value::Str("LUT_3D_SIZE 3\n0 0 0\n".into()))], img.clone()); assert_eq!(out.img, img); From bad3e7c2320d5f8aa8608d3dc725ed301b3ed366 Mon Sep 17 00:00:00 2001 From: jayzed80 Date: Sat, 31 Oct 2026 09:45:18 +0000 Subject: [PATCH 02/20] fix(effects): parse_cube rejects a hostile LUT_3D_SIZE before cubing it Co-Authored-By: Claude Sonnet 5.5 --- crates/effects/src/utility.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/effects/src/utility.rs b/crates/effects/src/utility.rs index e87c6d3ff..b38ded8db 100644 --- a/crates/effects/src/utility.rs +++ b/crates/effects/src/utility.rs @@ -215,9 +215,12 @@ pub fn parse_cube(text: &str) -> Option { _ => rows.push(three(&mut it)?), } } + if lut.n3 > 256 { + return None; + } let need1 = lut.n1; let need3 = lut.n3 * lut.n3 * lut.n3; - if (lut.n1 == 0 && lut.n3 == 0) || lut.n1 == 1 || lut.n3 == 1 || rows.len() != need1 + need3 || lut.n3 > 256 { + if (lut.n1 == 0 && lut.n3 == 0) || lut.n1 == 1 || lut.n3 == 1 || Some(rows.len()) != need1.checked_add(need3) { return None; } lut.d1 = rows[..need1].to_vec(); @@ -477,6 +480,10 @@ mod tests { fn bad_cube_is_passthrough() { assert!(parse_cube("LUT_3D_SIZE 2\n0 0 0\n1 1 1\n").is_none()); assert!(parse_cube("LUT_3D_SIZE 2\n0 0 zz\n").is_none()); + // A hostile size must be rejected, not overflow `n3^3` or `n1 + n3^3`. + assert!(parse_cube("LUT_3D_SIZE 4294967296\n0 0 0\n").is_none()); + assert!(parse_cube(&format!("LUT_3D_SIZE {}\n0 0 0\n", usize::MAX)).is_none()); + assert!(parse_cube(&format!("LUT_1D_SIZE {}\nLUT_3D_SIZE 2\n0 0 0\n", usize::MAX)).is_none()); let img = test_img(); let out = run("ec.utility.applylut", &[("lut", Value::Str("LUT_3D_SIZE 3\n0 0 0\n".into()))], img.clone()); assert_eq!(out.img, img); From 1dc70637bd562d921f9eee8db5ed22633a76a253 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:05:29 +0530 Subject: [PATCH 03/20] #3466: Sharpen Amount takes After Effects' 0..4000 range The hard range was 0..500, so prop.set and the value editors clamped values After Effects accepts (its recorded valid range is 0..4000; the 0..100 slider and the default are unchanged). The engine range test now covers both ends through prop.set, undo/redo, save/reopen and projects saved with the old range, and the recorded-range guard no longer lists Sharpen as narrower. --- crates/aep/src/export/fx_defs.rs | 1 - crates/effects/src/misc.rs | 15 ++++++++++++++- crates/engine/src/tests/effect_ranges.rs | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/aep/src/export/fx_defs.rs b/crates/aep/src/export/fx_defs.rs index 338e00fc5..3c0c3a357 100644 --- a/crates/aep/src/export/fx_defs.rs +++ b/crates/aep/src/export/fx_defs.rs @@ -729,7 +729,6 @@ mod tests { ("ec.obsolete.gaussianlegacy", "blurriness", 3463), ("ec.perspective.dropshadow", "softness", 3464), ("ec.blur.compound", "maximumBlur", 3465), - ("ec.blur.sharpen", "amount", 3466), ("ec.blur.radial", "amount", 3467), ("ec.blur.ccradial", "amount", 3468), ("ec.distort.turbulentdisplace", "amount", 3469), diff --git a/crates/effects/src/misc.rs b/crates/effects/src/misc.rs index 9c7131657..13167a3ba 100644 --- a/crates/effects/src/misc.rs +++ b/crates/effects/src/misc.rs @@ -794,7 +794,7 @@ pub fn specs() -> Vec { ], radial, ), - spec("ec.blur.sharpen", "Sharpen", "Blur & Sharpen", vec![p("amount", "Sharpen Amount", num(0.0), slider(0.0, 500.0, 0.0, 100.0, 0))], sharpen), + spec("ec.blur.sharpen", "Sharpen", "Blur & Sharpen", vec![p("amount", "Sharpen Amount", num(0.0), slider(0.0, 4000.0, 0.0, 100.0, 0))], sharpen), spec( "ec.blur.unsharp", "Unsharp Mask", @@ -1036,6 +1036,19 @@ mod tests { assert_ne!(row(2.0), row(2.4)); } + /// #3466: Sharpen Amount takes After Effects' valid range, 0..4000, and keeps its 0..100 + /// slider. `prop.set` and the value editors clamp to the hard range. + #[test] + fn sharpen_amount_takes_the_after_effects_range() { + let spec = crate::find("ec.blur.sharpen").unwrap(); + let ui = &spec.params.iter().find(|p| p.id == "amount").unwrap().ui; + assert!( + matches!(ui, ParamUi::Slider { min, max, slider_min, slider_max, .. } + if *min == 0.0 && *max == 4000.0 && *slider_min == 0.0 && *slider_max == 100.0), + "{ui:?}" + ); + } + #[test] fn fractional_box_blur_radius_is_continuous() { let row = |v| blurred_row("ec.blur.fastbox", "radius", v); diff --git a/crates/engine/src/tests/effect_ranges.rs b/crates/engine/src/tests/effect_ranges.rs index 7deaaa911..f2ad2112e 100644 --- a/crates/engine/src/tests/effect_ranges.rs +++ b/crates/engine/src/tests/effect_ranges.rs @@ -60,6 +60,7 @@ const ROWS: &[(u32, &str, &str, f64, f64)] = &[ (3471, "ec.distort.transform", "scaleHeight", -30000.0, 30000.0), (3471, "ec.distort.transform", "scaleWidth", -30000.0, 30000.0), (3470, "ec.distort.turbulentdisplace", "evolutionOptions/randomSeed", 0.0, 100000.0), + (3466, "ec.blur.sharpen", "amount", 0.0, 4000.0), ]; fn path(effect: &str, param: &str) -> String { From 1a4697de31ac2fc49174a92ffe0cf7fac78b40a2 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:05:37 +0530 Subject: [PATCH 04/20] #3466: test Sharpen's render at Amount 4000 At the top of the new range the CPU render stays linear in Amount (colour moves Amount / 50 of its difference from the blur) and finite on 32 bpc over-range input, and the GPU matches the CPU at 8 and 32 bpc. --- crates/effects/src/misc.rs | 30 ++++++++++++++++++++++++++++++ crates/gpu/src/tests/fx_noise.rs | 2 ++ 2 files changed, 32 insertions(+) diff --git a/crates/effects/src/misc.rs b/crates/effects/src/misc.rs index 13167a3ba..351460de7 100644 --- a/crates/effects/src/misc.rs +++ b/crates/effects/src/misc.rs @@ -1049,6 +1049,36 @@ mod tests { ); } + /// #3466: at the new top of the range the render stays linear in Amount and finite on 32 bpc + /// over-range input: colour moves away from the blur by Amount / 50 of the difference + /// (2000 → 4000 doubles it), never below 0, and alpha is untouched. + #[test] + fn sharpen_is_linear_and_finite_up_to_amount_4000() { + let mut img = edge(); + for y in 0..8 { + for x in 0..20 { + img.set(x, y, [1000.0, 1000.0, 1000.0, 1.0]); + } + } + let sharpen = |a: f64| run_fx("ec.blur.sharpen", &[("amount", num(a))], img.clone(), 0.0, EffectEnv::default()).img; + let (half, top) = (sharpen(2000.0), sharpen(4000.0)); + for y in 0..8 { + for x in 0..40 { + let (i, h, t) = (img.get(x, y), half.get(x, y), top.get(x, y)); + assert_eq!(t[3], i[3], "alpha at {x}"); + for c in 0..3 { + assert!(t[c].is_finite() && t[c] >= 0.0, "({x}, {y}): {t:?}"); + if t[c] > 0.0 && h[c] > 0.0 { + let (dh, dt) = (h[c] - i[c], t[c] - i[c]); + assert!((dt - 2.0 * dh).abs() <= 1e-3 * dt.abs().max(1.0), "({x}, {y}): {dh} {dt}"); + } + } + } + } + // The bright side of the edge moves 80 × its difference from the blur: far past 10 × the input. + assert!(top.get(19, 4)[0] > 1000.0 * 10.0, "{:?}", top.get(19, 4)); + } + #[test] fn fractional_box_blur_radius_is_continuous() { let row = |v| blurred_row("ec.blur.fastbox", "radius", v); diff --git a/crates/gpu/src/tests/fx_noise.rs b/crates/gpu/src/tests/fx_noise.rs index 006128c73..5e31e7e84 100644 --- a/crates/gpu/src/tests/fx_noise.rs +++ b/crates/gpu/src/tests/fx_noise.rs @@ -75,6 +75,8 @@ fn edge_preserving_blurs() { fn sharpen_and_unsharp_mask() { effect_case("ec.blur.sharpen", &[("amount", n(60.0))]); effect_case("ec.blur.sharpen", &[("amount", n(250.0))]); + // #3466: the top of After Effects' range (80 × the difference from the blur). + effect_case("ec.blur.sharpen", &[("amount", n(4000.0))]); effect_case("ec.blur.unsharp", &[("amount", n(120.0)), ("radius", n(4.0))]); effect_case("ec.blur.unsharp", &[("amount", n(80.0)), ("radius", n(2.5)), ("threshold", n(12.0))]); } From 6c5d0b51ec482339c4b2739e508a386ff7044bb0 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:05:37 +0530 Subject: [PATCH 05/20] #3466: note Sharpen's Amount range in the parity history --- docs/effects-parity.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/effects-parity.md b/docs/effects-parity.md index b07c624f8..d9bcfcedf 100644 --- a/docs/effects-parity.md +++ b/docs/effects-parity.md @@ -64,6 +64,7 @@ the GPU is performance, not parity. | Date | Change | Summary | |---|---|---| +| 2026-11-17 | minor | Sharpen: Amount takes After Effects' recorded valid range, 0..4000 (was 0..500; default and the 0..100 slider unchanged). Sharpen stays linear in Amount and finite up to 4000, CPU and GPU agree there | | 2026-11-12 | minor | Parameters take After Effects' recorded valid ranges (hard range; defaults and sliders unchanged): Levels (Individual Controls) levels −10000..10000 and Gamma from 0; 4-Color Gradient Blend to 10000 and Jitter to 500 %; Change Color Hue Transform ±1800°; Noise HLS (and Auto) amounts to 1000 % and Grain Size from 0; Grid Border to 2000; Venetian Blinds Width 1..32000 and Feather to 32000; Radial Wipe Feather to 32000; Scatter Amount to 1000; Beam thicknesses to 4000; Transform Scale ±30000 %; Turbulent Displace Random Seed to 100000. A test checks every mapped parameter's range against the recorded table (CPU and GPU) | | 2026-10-19 | minor | Glow (original colours): bright pass per channel, 8 × (value − threshold + 0.061), measured against After Effects 2026 (CPU and GPU) | | 2026-10-19 | minor | Glow (colour channels): the glow covers the layer's blurred alpha, blur σ = 0.384 × radius, measured against After Effects 2026 renders (CPU and GPU) | From 4b4d2730863d958b2d6f4d87f5f7b89009c44d7a Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:06:36 +0530 Subject: [PATCH 06/20] #3460: legacy Roto Brush keys hash Gaussian Blur's 0.24 Blurriness range Roto Brush Input Keys saved by 0.22-0.24 hashed each effect above the brush through its derived Debug text, UI hints included. Opening a project replaces an instance's hints with the current spec's, so widening a range would stop those keys matching and drop the frozen matte. The legacy text now puts back the slider range 0.24 shipped for parameters listed in SLIDERS_0_24, starting with Gaussian Blur's Blurriness. --- .../engine/src/analysis/frames_key/legacy.rs | 31 +++++++++++++++++-- crates/engine/src/tests/analysis_signature.rs | 15 ++++++++- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/analysis/frames_key/legacy.rs b/crates/engine/src/analysis/frames_key/legacy.rs index 882c82d80..4b1b090a5 100644 --- a/crates/engine/src/analysis/frames_key/legacy.rs +++ b/crates/engine/src/analysis/frames_key/legacy.rs @@ -2,7 +2,7 @@ //! keyed with them. They hash derived `Debug` text, so `tests::analysis_signature` pins keys //! those releases saved: if a type change alters this text, write that part out here. -use effectcraft_project::{Footage, ItemId, ItemKind, Layer, LayerSource, Project, Uid}; +use effectcraft_project::{Footage, GroupKind, ItemId, ItemKind, Layer, LayerSource, ParamUi, Project, PropGroup, Uid}; use super::fnv; @@ -41,12 +41,39 @@ pub(crate) fn input_key_of(mut s: String, layer: &Layer, uid: Uid) -> String { if g.uid == uid { break; } - s.push_str(&format!("{g:?}")); + s.push_str(&effect_text(g)); } } format!("{:016x}", fnv(&s)) } +/// The slider ranges 0.22–0.24 gave effect parameters whose range has changed since, as +/// (effect, parameter path, [min, max, slider min, slider max], decimals). Those releases hashed +/// each effect's UI hints into the Roto Brush Input Key, and opening a project replaces an +/// instance's hints with the current ones, so [`effect_text`] puts these back. A range change +/// above a Roto Brush would otherwise drop the analysis such a key kept: add a row with it. +#[rustfmt::skip] +const SLIDERS_0_24: &[(&str, &str, [f64; 4], u8)] = &[ + ("ec.blur.gaussian", "blurriness", [0.0, 3000.0, 0.0, 50.0], 1), +]; + +/// An effect instance as 0.22–0.24 wrote it into a Roto Brush Input Key: its derived `Debug`, +/// with the [`SLIDERS_0_24`] ranges in place of today's. +pub(crate) fn effect_text(g: &PropGroup) -> String { + let GroupKind::Effect { effect } = &g.kind else { return format!("{g:?}") }; + let mut rows = SLIDERS_0_24.iter().filter(|r| r.0 == effect).peekable(); + if rows.peek().is_none() { + return format!("{g:?}"); + } + let mut g = g.clone(); + for &(_, path, [min, max, slider_min, slider_max], decimals) in rows { + if let Some(p) = g.prop_mut(path).filter(|p| matches!(p.ui, ParamUi::Slider { .. })) { + p.ui = ParamUi::Slider { min, max, slider_min, slider_max, decimals }; + } + } + format!("{g:?}") +} + /// A footage item as 0.23–0.24 wrote it into a signature (without `placed_page` before 0.23), /// with `missing` in place of the item's. pub(crate) fn footage_text(f: &Footage, missing: bool, placed_page: bool) -> String { diff --git a/crates/engine/src/tests/analysis_signature.rs b/crates/engine/src/tests/analysis_signature.rs index 045e279de..a4ab86264 100644 --- a/crates/engine/src/tests/analysis_signature.rs +++ b/crates/engine/src/tests/analysis_signature.rs @@ -5,7 +5,7 @@ use effectcraft_effects::camera_tracker::{TRACKS, TRACKS_KEY}; use effectcraft_effects::roto::{FROZEN, INPUT_KEY}; use effectcraft_effects::warp_stab::{ANALYSIS, ANALYSIS_KEY}; use effectcraft_keyframe::Value; -use effectcraft_project::{ItemId, LayerId, Project}; +use effectcraft_project::{GroupKind, ItemId, LayerId, ParamUi, Project}; use serde_json::json; use crate::Session; @@ -93,6 +93,19 @@ fn analyses_saved_by_0_24_survive_edits_that_keep_their_frames() { assert_eq!(saved(&s), before); } +/// 0.24 hashed each effect's UI hints into the Roto Brush's key, and opening a project takes the +/// current ones: the legacy text puts back Gaussian Blur's 0.24 Blurriness range (#3460). +#[test] +fn legacy_roto_keys_hash_the_0_24_blurriness_range() { + let s = open(ANALYSED_0_24); + let layer = s.project.comp(COMP).unwrap().layer(CLIP).unwrap(); + let is_blur = |kind: &GroupKind| matches!(kind, GroupKind::Effect { effect } if effect == "ec.blur.gaussian"); + let blur = layer.effects().and_then(|fx| fx.groups().find(|g| is_blur(&g.kind))).expect("the fixture has a Gaussian Blur above the Roto Brush"); + let mut as_0_24 = blur.clone(); + as_0_24.get_mut("blurriness").unwrap().ui = ParamUi::Slider { min: 0.0, max: 3000.0, slider_min: 0.0, slider_max: 50.0, decimals: 1 }; + assert_eq!(crate::analysis::frames_key::legacy::effect_text(blur), format!("{as_0_24:?}")); +} + /// The text keys are made from today, written field by field (#3536). It changes only when this /// test is changed with it: a new field of a type it writes doesn't compile until it is decided /// in `analysis::frames_key`, and renaming a field or variant doesn't change it. From 8d603d9db8bd1b97a6effb0d793f33cc7d6f3c24 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:06:36 +0530 Subject: [PATCH 07/20] #3460: GPU box passes count repeated edge pixels instead of visiting them Each box-pass thread started its running sum by reading all 2r+1 pixels of its window, even past the end of the line. At Gaussian Blur's Blurriness 30000 the radius is about 15000 px, so most of those reads were the same edge pixel or zero. Sum the pixels inside the line once and add the repeated edges times their count, as the CPU pass does. Apple M5 (Metal), 4096 x 4096, three passes per axis, repeated edges: r = 15000 went from about 185 ms to 75 ms; r = 1500 is unchanged (80 ms). --- crates/gpu/src/shaders/kernels.wgsl | 18 +++++++++++++++++- crates/gpu/src/tests.rs | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/crates/gpu/src/shaders/kernels.wgsl b/crates/gpu/src/shaders/kernels.wgsl index a123b70ca..2f52b3b48 100644 --- a/crates/gpu/src/shaders/kernels.wgsl +++ b/crates/gpu/src/shaders/kernels.wgsl @@ -289,9 +289,25 @@ fn box_pass(gid: vec3, horizontal: bool) { } let norm = 1.0 / f32(2 * r + 1); var acc = vec4(0.0); - for (var i = b0 - r; i <= b0 + r; i++) { + // The starting window, as the CPU sums it: the pixels inside the line once each, and the + // repeated edge pixels counted rather than visited (a radius far past the line, such as + // Gaussian Blur's at Blurriness 30000, would otherwise loop over it once per pixel). + let lo = b0 - r; + let hi = b0 + r; + for (var i = max(lo, 0); i <= min(hi, n - 1); i++) { acc += line_get(horizontal, line, i, n, repeat); } + if (repeat) { + let before = f32(max(-lo, 0)); + let after = f32(max(hi - (n - 1), 0)); + // A zero count adds nothing (0 * NaN would be NaN). + if (before > 0.0) { + acc += line_get(horizontal, line, 0, n, repeat) * before; + } + if (after > 0.0) { + acc += line_get(horizontal, line, n - 1, n, repeat) * after; + } + } let b1 = min(b0 + block, n); for (var i = b0; i < b1; i++) { if (horizontal) { diff --git a/crates/gpu/src/tests.rs b/crates/gpu/src/tests.rs index 1d2782262..23e67d722 100644 --- a/crates/gpu/src/tests.rs +++ b/crates/gpu/src/tests.rs @@ -760,6 +760,27 @@ fn box_blur_horizontal_rows_match_cpu_beyond_256() { } } +/// #3460: a box radius far past the image (Gaussian Blur's at Blurriness 30000 is about 15000 px) +/// starts each running sum as the CPU does, the pixels inside once and the repeated edges +/// counted, so the GPU matches it along rows and columns, with and without repeated edges. +#[test] +fn box_passes_with_a_radius_far_past_the_image_match_cpu() { + let Some(g) = gpu() else { return }; + let img = pattern(5, 96, 40); + let up = g.ctx.upload_image(&img).expect("upload"); + let tol = tolerance(BitDepth::Bpc32); + for repeat in [true, false] { + let mut e = crate::context::Enc::new(&g.ctx); + let r = [15_000usize; 3]; + let out = crate::effects::box_passes(&mut e, &up, &r, &r, repeat); + let got = e.download(&out).expect("download"); + let want = effectcraft_raster::box_blur(&img, 15_000, 15_000, 3, repeat); + assert_eq!((got.width, got.height), (want.width, want.height)); + let d = diff(&want, &got, tol); + assert_eq!(d.over, 0, "repeat {repeat}: max {} at {:?} on {}", d.max, d.worst, g.ctx.name); + } +} + #[test] fn gpu_effects_match_cpu() { // Sigma 3 px and up and even radii, so the half-scale pass stays on the GPU too (#1939). From ef7dd7f3d181a66e43fb532e041d55a1b6d762da Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:06:36 +0530 Subject: [PATCH 08/20] #3460: Gaussian Blur: Blurriness takes After Effects' range 0..30000 After Effects records Blurriness as valid from 0 to 30000; the hard range was 0..3000, so prop.set and the value editors clamped 4000 to 3000. The default (0) and the 0..50 slider stay as they were. Padding stays within the effect pixel budget at the new maximum, on the CPU and the GPU. Tests: the engine round trip (prop.set, undo/redo, save/reopen, older projects) gets a row, the aep guard drops its known-narrower row, and the CPU and GPU render at 30000 is checked bounded, finite and matching. --- crates/aep/src/export/fx_defs.rs | 1 - crates/effects/src/misc.rs | 21 ++++++++++++++++++++- crates/engine/src/tests/effect_ranges.rs | 1 + crates/gpu/src/tests.rs | 8 ++++++++ docs/effects-parity.md | 1 + 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/crates/aep/src/export/fx_defs.rs b/crates/aep/src/export/fx_defs.rs index 338e00fc5..ee24879c6 100644 --- a/crates/aep/src/export/fx_defs.rs +++ b/crates/aep/src/export/fx_defs.rs @@ -720,7 +720,6 @@ mod tests { /// issue is fixed; the test fails on a row that is no longer needed. #[rustfmt::skip] const KNOWN_NARROWER: &[(&str, &str, u32)] = &[ - ("ec.blur.gaussian", "blurriness", 3460), ("ec.blur.fastbox", "radius", 3461), ("ec.blur.channel", "redBlurriness", 3462), ("ec.blur.channel", "greenBlurriness", 3462), diff --git a/crates/effects/src/misc.rs b/crates/effects/src/misc.rs index 9c7131657..11a273888 100644 --- a/crates/effects/src/misc.rs +++ b/crates/effects/src/misc.rs @@ -756,7 +756,7 @@ pub fn specs() -> Vec { "Gaussian Blur", "Blur & Sharpen", vec![ - p("blurriness", "Blurriness", num(0.0), slider(0.0, 3000.0, 0.0, 50.0, 1)), + p("blurriness", "Blurriness", num(0.0), slider(0.0, 30000.0, 0.0, 50.0, 1)), p("dimensions", "Blur Dimensions", Value::Enum(0), dims()), p("repeatEdge", "Repeat Edge Pixels", Value::Bool(false), ParamUi::Checkbox), ], @@ -1036,6 +1036,25 @@ mod tests { assert_ne!(row(2.0), row(2.4)); } + /// #3460: Blurriness goes up to After Effects' 30000. There the padding stays within the + /// effect pixel budget, every pixel stays finite, and Repeat Edge Pixels still repeats the + /// layer's edges: a layer white on the left and black on the right blurs to an even grey. + #[test] + fn gaussian_blur_at_the_highest_blurriness_is_bounded() { + for repeat in [false, true] { + let out = run_fx("ec.blur.gaussian", &[("blurriness", num(30000.0)), ("repeatEdge", Value::Bool(repeat))], edge(), 0.0, EffectEnv::default()); + let (w, h) = (out.img.width, out.img.height); + assert!(u64::from(w) * u64::from(h) <= 16_777_216, "repeat {repeat}: {w} x {h}"); + assert!(out.img.data.iter().flatten().all(|v| v.is_finite()), "repeat {repeat}"); + if repeat { + assert_eq!((w, h), (40, 8)); + for p in &out.img.data { + assert!(p[..3].iter().all(|v| (v - 0.5).abs() < 0.01) && (p[3] - 1.0).abs() < 1e-4, "{p:?}"); + } + } + } + } + #[test] fn fractional_box_blur_radius_is_continuous() { let row = |v| blurred_row("ec.blur.fastbox", "radius", v); diff --git a/crates/engine/src/tests/effect_ranges.rs b/crates/engine/src/tests/effect_ranges.rs index 7deaaa911..49721e136 100644 --- a/crates/engine/src/tests/effect_ranges.rs +++ b/crates/engine/src/tests/effect_ranges.rs @@ -60,6 +60,7 @@ const ROWS: &[(u32, &str, &str, f64, f64)] = &[ (3471, "ec.distort.transform", "scaleHeight", -30000.0, 30000.0), (3471, "ec.distort.transform", "scaleWidth", -30000.0, 30000.0), (3470, "ec.distort.turbulentdisplace", "evolutionOptions/randomSeed", 0.0, 100000.0), + (3460, "ec.blur.gaussian", "blurriness", 0.0, 30000.0), ]; fn path(effect: &str, param: &str) -> String { diff --git a/crates/gpu/src/tests.rs b/crates/gpu/src/tests.rs index 23e67d722..d08276504 100644 --- a/crates/gpu/src/tests.rs +++ b/crates/gpu/src/tests.rs @@ -781,6 +781,14 @@ fn box_passes_with_a_radius_far_past_the_image_match_cpu() { } } +/// #3460: Gaussian Blur's highest Blurriness, 30000, renders the same on the GPU as on the CPU, +/// with the padding cut to the effect pixel budget and with Repeat Edge Pixels. +#[test] +fn gaussian_blur_at_the_highest_blurriness_matches_cpu() { + effect_case("ec.blur.gaussian", &[("blurriness", n(30000.0))]); + effect_case("ec.blur.gaussian", &[("blurriness", n(30000.0)), ("repeatEdge", Value::Bool(true))]); +} + #[test] fn gpu_effects_match_cpu() { // Sigma 3 px and up and even radii, so the half-scale pass stays on the GPU too (#1939). diff --git a/docs/effects-parity.md b/docs/effects-parity.md index b07c624f8..6675bc131 100644 --- a/docs/effects-parity.md +++ b/docs/effects-parity.md @@ -64,6 +64,7 @@ the GPU is performance, not parity. | Date | Change | Summary | |---|---|---| +| 2026-11-17 | minor | Gaussian Blur: Blurriness takes After Effects' recorded valid range 0..30000 (was 0..3000; default and 0..50 slider unchanged). Padding stays within the effect pixel budget at the top of the range (CPU and GPU), and Roto Brush analyses 0.24 saved below a Gaussian Blur still match (#3460) | | 2026-11-12 | minor | Parameters take After Effects' recorded valid ranges (hard range; defaults and sliders unchanged): Levels (Individual Controls) levels −10000..10000 and Gamma from 0; 4-Color Gradient Blend to 10000 and Jitter to 500 %; Change Color Hue Transform ±1800°; Noise HLS (and Auto) amounts to 1000 % and Grain Size from 0; Grid Border to 2000; Venetian Blinds Width 1..32000 and Feather to 32000; Radial Wipe Feather to 32000; Scatter Amount to 1000; Beam thicknesses to 4000; Transform Scale ±30000 %; Turbulent Displace Random Seed to 100000. A test checks every mapped parameter's range against the recorded table (CPU and GPU) | | 2026-10-19 | minor | Glow (original colours): bright pass per channel, 8 × (value − threshold + 0.061), measured against After Effects 2026 (CPU and GPU) | | 2026-10-19 | minor | Glow (colour channels): the glow covers the layer's blurred alpha, blur σ = 0.384 × radius, measured against After Effects 2026 renders (CPU and GPU) | From d918aa6e13bf6a89e81d974f20a85826540ece54 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:09:29 +0530 Subject: [PATCH 09/20] #3467: Radial Blur Amount takes After Effects' range 0..1000 After Effects records 0..1000 for Radial Blur's Amount (slider 0..100); EffectCraft's hard range stopped at 100, so prop.set and the value editors clamped 200 to 100. The hard maximum is now 1000; the slider range and default are unchanged. The engine range test covers prop.set at both ends, undo and redo, save and reopen, and a project saved with the old range. The parameter leaves the .aep range guard's list of known narrower ranges. --- crates/aep/src/export/fx_defs.rs | 1 - crates/effects/src/misc.rs | 27 +++++++++++++++++++++++- crates/engine/src/tests/effect_ranges.rs | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/crates/aep/src/export/fx_defs.rs b/crates/aep/src/export/fx_defs.rs index 338e00fc5..fb83eed8a 100644 --- a/crates/aep/src/export/fx_defs.rs +++ b/crates/aep/src/export/fx_defs.rs @@ -730,7 +730,6 @@ mod tests { ("ec.perspective.dropshadow", "softness", 3464), ("ec.blur.compound", "maximumBlur", 3465), ("ec.blur.sharpen", "amount", 3466), - ("ec.blur.radial", "amount", 3467), ("ec.blur.ccradial", "amount", 3468), ("ec.distort.turbulentdisplace", "amount", 3469), ("ec.time.pixelmotionblur", "shutterAngle", 3481), diff --git a/crates/effects/src/misc.rs b/crates/effects/src/misc.rs index 9c7131657..168dd6110 100644 --- a/crates/effects/src/misc.rs +++ b/crates/effects/src/misc.rs @@ -786,7 +786,8 @@ pub fn specs() -> Vec { "Radial Blur", "Blur & Sharpen", vec![ - p("amount", "Amount", num(10.0), slider(0.0, 100.0, 0.0, 100.0, 1)), + // After Effects accepts 0..1000; its slider shows 0..100 (#3467). + p("amount", "Amount", num(10.0), slider(0.0, 1000.0, 0.0, 100.0, 1)), p("center", "Center", Value::Vec2([0.5, 0.5]), ParamUi::Point), p("type", "Type", Value::Enum(0), popup(&["Spin", "Zoom"])), // Our blur is always fully anti-aliased; the choice is kept for compatibility. @@ -1147,6 +1148,30 @@ mod tests { } } + /// Spin and Zoom at both ends of Amount (0..1000) and both Antialiasing settings give finite + /// colours over an opaque layer and keep it opaque (#3467). + #[test] + fn radial_blur_is_finite_across_the_amount_range() { + let mut img = effectcraft_raster::Image::new(48, 40); + img.rows_mut().for_each(|(y, row)| { + for (x, px) in row.iter_mut().enumerate() { + *px = [x as f32 / 47.0, y as f32 / 39.0, 0.5, 1.0]; + } + }); + for ty in 0..2 { + for aa in 0..2 { + for amount in [0.0, 100.0, 200.0, 1000.0] { + let vals = [("amount", num(amount)), ("type", Value::Enum(ty)), ("center", Value::Vec2([10.0, 30.0])), ("antialiasing", Value::Enum(aa))]; + let o = run_fx("ec.blur.radial", &vals, img.clone(), 0.0, EffectEnv::default()); + assert_eq!((o.img.width, o.img.height), (48, 40)); + for p in &o.img.data { + assert!(p.iter().all(|v| v.is_finite()) && (p[3] - 1.0).abs() < 1e-5, "type {ty} aa {aa} amount {amount}: {p:?}"); + } + } + } + } + } + /// After Effects 2026, Venetian Blinds Completion 40, Direction 30, Width 50, Feather 5 on /// an opaque 480 × 270 layer: alpha (0..255) along row y = 135. The transparent band starts /// at the layer centre's phase, both edges are Gaussian (σ = Feather / 2). diff --git a/crates/engine/src/tests/effect_ranges.rs b/crates/engine/src/tests/effect_ranges.rs index 7deaaa911..6cc457888 100644 --- a/crates/engine/src/tests/effect_ranges.rs +++ b/crates/engine/src/tests/effect_ranges.rs @@ -60,6 +60,7 @@ const ROWS: &[(u32, &str, &str, f64, f64)] = &[ (3471, "ec.distort.transform", "scaleHeight", -30000.0, 30000.0), (3471, "ec.distort.transform", "scaleWidth", -30000.0, 30000.0), (3470, "ec.distort.turbulentdisplace", "evolutionOptions/randomSeed", 0.0, 100000.0), + (3467, "ec.blur.radial", "amount", 0.0, 1000.0), ]; fn path(effect: &str, param: &str) -> String { From f98c3e9ba2da86ced94a34f7c9bf1a1fe7489d33 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:09:38 +0530 Subject: [PATCH 10/20] #3467: Radial Blur Zoom past 200 stays on its side of the centre MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Zoom spreads its 32 samples over scales 1 ± Amount / 200 about the centre. Past Amount 200, which the range now allows, that reaches below 0 and samples the layer mirrored through the centre: at 1000 a layer white on the left and black on the right turned the right half 35 % grey. raster::radial_blur_zoom_scale keeps the old scales up to 200 exactly and spreads the samples evenly from the centre to 1 + Amount / 200 beyond. The CPU and GPU paths both take their samples from it. Work per pixel stays at 32 samples at any Amount. --- crates/effects/src/misc.rs | 20 +++++++++++ crates/gpu/src/fx_generate.rs | 8 ++--- crates/gpu/src/tests/fx_generate.rs | 3 ++ crates/raster/src/blur.rs | 53 ++++++++++++++++++++++++++--- crates/raster/src/lib.rs | 5 ++- docs/effects-parity.md | 1 + 6 files changed, 81 insertions(+), 9 deletions(-) diff --git a/crates/effects/src/misc.rs b/crates/effects/src/misc.rs index 168dd6110..ea196fc11 100644 --- a/crates/effects/src/misc.rs +++ b/crates/effects/src/misc.rs @@ -1148,6 +1148,26 @@ mod tests { } } + /// Amount takes After Effects' valid range up to 1000 (#3467), Zoom 1000 a spread of 10. + /// Zoom samples along the ray from the centre through the pixel, never past the centre: on a + /// layer white left of the centre and black right of it, the right half stays black (scales + /// below 0 sampled the white half mirrored through the centre). Both Antialiasing settings. + #[test] + fn radial_blur_zoom_at_the_largest_amount_stays_on_its_side_of_the_centre() { + let mut img = effectcraft_raster::Image::filled(64, 32, [0.0, 0.0, 0.0, 1.0]); + img.rows_mut().for_each(|(_, row)| row.iter_mut().take(32).for_each(|px| *px = [1.0, 1.0, 1.0, 1.0])); + for aa in 0..2 { + let vals = [("amount", num(1000.0)), ("type", Value::Enum(1)), ("center", Value::Vec2([32.5, 16.5])), ("antialiasing", Value::Enum(aa))]; + let o = run_fx("ec.blur.radial", &vals, img.clone(), 0.0, EffectEnv::default()); + for y in 0..32 { + for x in 33..64 { + let p = o.img.get(x, y); + assert!(p[0].abs() < 1e-5 && (p[3] - 1.0).abs() < 1e-5, "aa {aa} ({x}, {y}): {p:?}"); + } + } + } + } + /// Spin and Zoom at both ends of Amount (0..1000) and both Antialiasing settings give finite /// colours over an opaque layer and keep it opaque (#3467). #[test] diff --git a/crates/gpu/src/fx_generate.rs b/crates/gpu/src/fx_generate.rs index 2dda38f45..6e9594f60 100644 --- a/crates/gpu/src/fx_generate.rs +++ b/crates/gpu/src/fx_generate.rs @@ -100,14 +100,14 @@ fn radial_blur(e: &mut Enc, ctx: &EffectCtx, b: GBuf) -> Option { if amount.abs() < 1e-6 { return Some(b); } - let n = 32usize; + // The CPU's samples (`raster::radial_blur`). + let n = effectcraft_raster::RADIAL_BLUR_SAMPLES; let mut data = Vec::with_capacity(2 * n); for i in 0..n { - let t = i as f64 / (n - 1) as f64 - 0.5; if zoom { - data.push((1.0 + t * amount) as f32); + data.push(effectcraft_raster::radial_blur_zoom_scale(i, amount) as f32); } else { - let (s, c) = (t * amount).to_radians().sin_cos(); + let (s, c) = effectcraft_raster::radial_blur_spin_angle(i, amount).to_radians().sin_cos(); data.extend([s as f32, c as f32]); } } diff --git a/crates/gpu/src/tests/fx_generate.rs b/crates/gpu/src/tests/fx_generate.rs index f8482b5ab..02ec75b11 100644 --- a/crates/gpu/src/tests/fx_generate.rs +++ b/crates/gpu/src/tests/fx_generate.rs @@ -24,6 +24,9 @@ fn radial_blur() { effect_case("ec.blur.radial", &[("amount", n(12.0))]); effect_case("ec.blur.radial", &[("amount", n(30.0)), ("type", e(1)), ("center", pt(20.3, 14.7))]); effect_case("ec.blur.radial", &[("amount", n(-45.0)), ("center", pt(50.0, 30.0))]); + // Amount's largest value, 1000 (#3467): Spin over ±500°, Zoom from the centre outwards. + effect_case("ec.blur.radial", &[("amount", n(1000.0)), ("center", pt(20.3, 14.7))]); + effect_case("ec.blur.radial", &[("amount", n(1000.0)), ("type", e(1)), ("center", pt(20.3, 14.7)), ("antialiasing", e(1))]); } #[test] diff --git a/crates/raster/src/blur.rs b/crates/raster/src/blur.rs index 76e51f865..751e0f5d0 100644 --- a/crates/raster/src/blur.rs +++ b/crates/raster/src/blur.rs @@ -300,24 +300,49 @@ pub fn directional_blur(img: &Image, angle_deg: f64, length: f64) -> Image { out } +/// Samples [`radial_blur`] averages per pixel at every amount, so the work per pixel stays the +/// same up to Radial Blur's largest Amount (1000). The GPU path takes the same count. +pub const RADIAL_BLUR_SAMPLES: usize = 32; + +/// Where sample `i` of [`RADIAL_BLUR_SAMPLES`] lies in the blur's spread, from −0.5 to 0.5. +fn radial_blur_t(i: usize) -> f64 { + i as f64 / (RADIAL_BLUR_SAMPLES - 1) as f64 - 0.5 +} + +/// Spin sample `i`'s rotation in degrees for a spin of `amount` degrees. +pub fn radial_blur_spin_angle(i: usize, amount: f64) -> f64 { + radial_blur_t(i) * amount +} + +/// Zoom sample `i`'s scale about the centre for a zoom of `amount` (a fraction of the distance +/// to the centre): evenly over `1 ± amount / 2`. Past a spread of 2 (Radial Blur's Amount 200) +/// that would reach below 0 and sample the point mirrored through the centre, so the samples +/// spread evenly from the centre (0) to `1 + amount / 2` instead (#3467). +pub fn radial_blur_zoom_scale(i: usize, amount: f64) -> f64 { + let t = radial_blur_t(i); + if amount.abs() <= 2.0 { + return 1.0 + t * amount; + } + (t + 0.5) * (1.0 + amount.abs() / 2.0) +} + /// Radial blur around `center`: `spin` (degrees) or zoom (`amount` as a fraction of distance). pub fn radial_blur(img: &Image, center: (f64, f64), amount: f64, zoom: bool) -> Image { if amount.abs() < 1e-6 { return img.clone(); } - let n = 32usize; + let n = RADIAL_BLUR_SAMPLES; let mut out = Image::new(img.width, img.height); out.rows_mut().for_each(|(y, row)| { for (x, px) in row.iter_mut().enumerate() { let (vx, vy) = (x as f64 + 0.5 - center.0, y as f64 + 0.5 - center.1); let mut acc = [0.0f32; 4]; for i in 0..n { - let t = i as f64 / (n - 1) as f64 - 0.5; let (sx, sy) = if zoom { - let k = 1.0 + t * amount; + let k = radial_blur_zoom_scale(i, amount); (center.0 + vx * k, center.1 + vy * k) } else { - let (s, c) = (t * amount).to_radians().sin_cos(); + let (s, c) = radial_blur_spin_angle(i, amount).to_radians().sin_cos(); (center.0 + vx * c - vy * s, center.1 + vx * s + vy * c) }; // Samples outside the image repeat its edge: After Effects' Radial Blur keeps a @@ -337,6 +362,26 @@ pub fn radial_blur(img: &Image, center: (f64, f64), amount: f64, zoom: bool) -> mod tests { use super::*; + /// Zoom spreads up to 2 keep `1 ± spread / 2` exactly as before (#3467); wider ones run + /// from the centre (scale 0) out to `1 + spread / 2`, evenly and never below 0. + #[test] + fn radial_blur_zoom_scales_never_cross_the_centre() { + let n = RADIAL_BLUR_SAMPLES; + for amount in [0.2, 1.0, 2.0, -1.5] { + for i in 0..n { + let t = i as f64 / (n - 1) as f64 - 0.5; + assert_eq!(radial_blur_zoom_scale(i, amount), 1.0 + t * amount, "amount {amount} sample {i}"); + } + } + for amount in [2.5, 10.0, -10.0] { + let k: Vec = (0..n).map(|i| radial_blur_zoom_scale(i, amount)).collect(); + assert_eq!(k[0], 0.0, "amount {amount}"); + assert!((k[n - 1] - (1.0 + amount.abs() / 2.0)).abs() < 1e-12, "amount {amount}: {k:?}"); + let step = k[n - 1] / (n - 1) as f64; + assert!(k.windows(2).all(|w| (w[1] - w[0] - step).abs() < 1e-12), "amount {amount}: {k:?}"); + } + } + /// The sampled Gaussian pass as it was (one pixel at a time, bounds-checked taps): the /// row-wise passes must match it to the bit. fn gauss_pass_per_pixel(img: &Image, sigma: f64, vertical: bool, repeat: bool) -> Image { diff --git a/crates/raster/src/lib.rs b/crates/raster/src/lib.rs index e18a24c63..852065db4 100644 --- a/crates/raster/src/lib.rs +++ b/crates/raster/src/lib.rs @@ -17,7 +17,10 @@ pub mod yuv; use effectcraft_color::{BlendMode, blend_pixel}; use rayon::prelude::*; -pub use blur::{box_blur, directional_blur, gaussian_blur, gaussian_blur_exact, gaussian_is_exact, radial_blur}; +pub use blur::{ + RADIAL_BLUR_SAMPLES, box_blur, directional_blur, gaussian_blur, gaussian_blur_exact, gaussian_is_exact, radial_blur, radial_blur_spin_angle, + radial_blur_zoom_scale, +}; pub use channels3d::AuxChannels; pub use warp::{Sampling, WarpOpts, accumulate_warp, composite_warp, composite_warp_changed, composite_warp_reference, resample}; diff --git a/docs/effects-parity.md b/docs/effects-parity.md index b07c624f8..9d6ca232f 100644 --- a/docs/effects-parity.md +++ b/docs/effects-parity.md @@ -64,6 +64,7 @@ the GPU is performance, not parity. | Date | Change | Summary | |---|---|---| +| 2026-11-17 | minor | Radial Blur: Amount takes After Effects' valid range 0..1000 (slider and default unchanged); Zoom past 200 spreads its samples from the centre outwards instead of sampling the layer mirrored through the centre (CPU and GPU) | | 2026-11-12 | minor | Parameters take After Effects' recorded valid ranges (hard range; defaults and sliders unchanged): Levels (Individual Controls) levels −10000..10000 and Gamma from 0; 4-Color Gradient Blend to 10000 and Jitter to 500 %; Change Color Hue Transform ±1800°; Noise HLS (and Auto) amounts to 1000 % and Grain Size from 0; Grid Border to 2000; Venetian Blinds Width 1..32000 and Feather to 32000; Radial Wipe Feather to 32000; Scatter Amount to 1000; Beam thicknesses to 4000; Transform Scale ±30000 %; Turbulent Displace Random Seed to 100000. A test checks every mapped parameter's range against the recorded table (CPU and GPU) | | 2026-10-19 | minor | Glow (original colours): bright pass per channel, 8 × (value − threshold + 0.061), measured against After Effects 2026 (CPU and GPU) | | 2026-10-19 | minor | Glow (colour channels): the glow covers the layer's blurred alpha, blur σ = 0.384 × radius, measured against After Effects 2026 renders (CPU and GPU) | From 2e17ed1d832a49e2f01beb7c510114561f92fa05 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:12:25 +0530 Subject: [PATCH 11/20] #3469: Turbulent Displace Amount takes After Effects' valid range The hard range was -1000..1000, so prop.set and the Effect Controls and Timeline editors clamped Amount values After Effects accepts. The recorded ADBE Turbulent Displace definition allows -10000..10000 (plain units, no conversion). The default and the -200..200 slider are unchanged. The .aep range guard no longer lists the parameter as narrower, and the engine range test covers both ends through prop.set, undo/redo, save and reopen, and projects saved with the old range. --- crates/aep/src/export/fx_defs.rs | 1 - crates/effects/src/distort2.rs | 12 +++++++++++- crates/engine/src/tests/effect_ranges.rs | 1 + docs/effects-parity.md | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/aep/src/export/fx_defs.rs b/crates/aep/src/export/fx_defs.rs index 338e00fc5..527ef62f8 100644 --- a/crates/aep/src/export/fx_defs.rs +++ b/crates/aep/src/export/fx_defs.rs @@ -732,7 +732,6 @@ mod tests { ("ec.blur.sharpen", "amount", 3466), ("ec.blur.radial", "amount", 3467), ("ec.blur.ccradial", "amount", 3468), - ("ec.distort.turbulentdisplace", "amount", 3469), ("ec.time.pixelmotionblur", "shutterAngle", 3481), ("ec.time.pixelmotionblur", "shutterSamples", 3482), ("ec.noise.fractal", "subSettings/subInfluence", 3485), diff --git a/crates/effects/src/distort2.rs b/crates/effects/src/distort2.rs index 611cb6dcf..4d0e5d7ec 100644 --- a/crates/effects/src/distort2.rs +++ b/crates/effects/src/distort2.rs @@ -736,7 +736,7 @@ pub fn specs() -> Vec { "Turbulent Displace", vec![ p("displacement", "Displacement", Value::Enum(0), popup(&TURBULENT_KINDS)), - p("amount", "Amount", num(50.0), slider(-1000.0, 1000.0, -200.0, 200.0, 1)), + p("amount", "Amount", num(50.0), slider(-10000.0, 10000.0, -200.0, 200.0, 1)), p("size", "Size", num(100.0), slider(2.0, 4000.0, 2.0, 400.0, 1)), p("offset", "Offset (Turbulence)", pt(0.5, 0.5), ParamUi::Point), p("complexity", "Complexity", num(1.0), slider(1.0, 10.0, 1.0, 10.0, 1)), @@ -1010,6 +1010,16 @@ mod tests { assert!(max_diff(&run("ec.distort.turbulentdisplace", &[], img.clone()).img, &img) > 1e-3); } + /// #3469: Amount's hard range is After Effects' recorded valid range, -10000..10000; the + /// slider keeps its -200..200 scrub range. + #[test] + fn turbulent_displace_amount_takes_the_after_effects_range() { + let spec = crate::find("ec.distort.turbulentdisplace").unwrap(); + let amount = spec.params.iter().find(|p| p.id == "amount").unwrap(); + let ParamUi::Slider { min, max, slider_min, slider_max, .. } = amount.ui else { panic!("{:?}", amount.ui) }; + assert_eq!((min, max, slider_min, slider_max), (-10000.0, 10000.0, -200.0, 200.0)); + } + #[test] fn griddler_default_is_identity() { let img = test_img(32, 24); diff --git a/crates/engine/src/tests/effect_ranges.rs b/crates/engine/src/tests/effect_ranges.rs index 7deaaa911..5436d4f32 100644 --- a/crates/engine/src/tests/effect_ranges.rs +++ b/crates/engine/src/tests/effect_ranges.rs @@ -60,6 +60,7 @@ const ROWS: &[(u32, &str, &str, f64, f64)] = &[ (3471, "ec.distort.transform", "scaleHeight", -30000.0, 30000.0), (3471, "ec.distort.transform", "scaleWidth", -30000.0, 30000.0), (3470, "ec.distort.turbulentdisplace", "evolutionOptions/randomSeed", 0.0, 100000.0), + (3469, "ec.distort.turbulentdisplace", "amount", -10000.0, 10000.0), ]; fn path(effect: &str, param: &str) -> String { diff --git a/docs/effects-parity.md b/docs/effects-parity.md index b07c624f8..f2c827432 100644 --- a/docs/effects-parity.md +++ b/docs/effects-parity.md @@ -64,6 +64,7 @@ the GPU is performance, not parity. | Date | Change | Summary | |---|---|---| +| 2026-11-17 | minor | Turbulent Displace: Amount takes After Effects' recorded valid range, −10000..10000 (default and the −200..200 slider unchanged) | | 2026-11-12 | minor | Parameters take After Effects' recorded valid ranges (hard range; defaults and sliders unchanged): Levels (Individual Controls) levels −10000..10000 and Gamma from 0; 4-Color Gradient Blend to 10000 and Jitter to 500 %; Change Color Hue Transform ±1800°; Noise HLS (and Auto) amounts to 1000 % and Grain Size from 0; Grid Border to 2000; Venetian Blinds Width 1..32000 and Feather to 32000; Radial Wipe Feather to 32000; Scatter Amount to 1000; Beam thicknesses to 4000; Transform Scale ±30000 %; Turbulent Displace Random Seed to 100000. A test checks every mapped parameter's range against the recorded table (CPU and GPU) | | 2026-10-19 | minor | Glow (original colours): bright pass per channel, 8 × (value − threshold + 0.061), measured against After Effects 2026 (CPU and GPU) | | 2026-10-19 | minor | Glow (colour channels): the glow covers the layer's blurred alpha, blur σ = 0.384 × radius, measured against After Effects 2026 renders (CPU and GPU) | From 040fe61b84ad59548cc1bf876c6260443b88b2b7 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:13:10 +0530 Subject: [PATCH 12/20] #3469: Turbulent Displace stays finite at any Amount Expressions are not clamped to the hard range. Padding computed amount.abs().ceil() as u32 + 1, which overflowed (a panic in debug builds) from about 4.3e9 on both the CPU and GPU paths, a NaN Amount filled the layer with NaN, and an infinite one sent infinite coordinates to the samplers' integer pixel positions. turbulent_amount_px, shared by both paths, skips a zero or NaN Amount and bounds the rest to 2^24 px. Values inside the hard range are unchanged. Tests cover both ends of the range with every displacement kind, pinning and Resize Layer (finite, padding within budget), Amounts past it, and CPU/GPU agreement at -10000, 10000 and infinity. --- crates/effects/src/distort2.rs | 59 ++++++++++++++++++++++++++++-- crates/effects/src/lib.rs | 2 +- crates/gpu/src/fx_distort.rs | 5 +-- crates/gpu/src/tests/fx_distort.rs | 8 ++++ docs/effects-parity.md | 2 +- 5 files changed, 68 insertions(+), 8 deletions(-) diff --git a/crates/effects/src/distort2.rs b/crates/effects/src/distort2.rs index 4d0e5d7ec..ed04c3493 100644 --- a/crates/effects/src/distort2.rs +++ b/crates/effects/src/distort2.rs @@ -85,11 +85,24 @@ const TURBULENT_PINNING: [&str; 15] = [ "Pin Bottom Locked", ]; +/// The largest Amount, in buffer pixels, Turbulent Displace displaces by: 2^24, exact in f32. +/// Only an expression gets past the -10000..10000 hard range. At this bound nearly every sample +/// already lands far outside any buffer, and the padding and the CPU and GPU samplers' integer +/// pixel positions (the gradient kinds move up to 2.5 × Amount) stay in range. +const TURBULENT_MAX_AMOUNT_PX: f64 = 16_777_216.0; + +/// Turbulent Displace's Amount at `scale`, in buffer pixels, bounded to +/// ±[`TURBULENT_MAX_AMOUNT_PX`]; `None` when nothing moves (zero, or not a number). Shared with +/// the GPU path. +pub fn turbulent_amount_px(ctx: &EffectCtx, scale: f64) -> Option { + let amount = ctx.params.f("amount") * scale; + (amount.abs() >= 1e-9).then(|| amount.clamp(-TURBULENT_MAX_AMOUNT_PX, TURBULENT_MAX_AMOUNT_PX)) +} + fn turbulent_displace(ctx: &EffectCtx, mut b: Buf) -> Buf { - let amount = ctx.params.f("amount") * b.scale; - if amount.abs() < 1e-9 { + let Some(amount) = turbulent_amount_px(ctx, b.scale) else { return b; - } + }; // TURBULENT_KINDS order: the "Smoother" variants (3, 4, 5) use a gentler octave falloff. let kind = ctx.params.e("displacement"); let size = (ctx.params.f("size") * b.scale).max(1.0); @@ -1020,6 +1033,46 @@ mod tests { assert_eq!((min, max, slider_min, slider_max), (-10000.0, 10000.0, -200.0, 200.0)); } + /// #3469: at either end of Amount's range, with every displacement kind, resized or not and + /// pinned or not, the output stays finite, in its alpha range and within the padding budget. + #[test] + fn turbulent_displace_extreme_amounts_stay_finite_and_bounded() { + let img = test_img(32, 24); + // Resize Layer grows the buffer to the padding budget (16 Mpx here), so it runs with two + // kinds; the rest stay layer-sized. + let cases = (0..9).flat_map(|kind| [(kind, 0, 0.0), (kind, 1, 0.0), (kind, 8, 0.0)]).chain([(0, 3, 1.0), (4, 14, 1.0)]); + for amount in [-10000.0, 10000.0] { + for (kind, pin, resize) in cases.clone() { + let set = [("amount", num(amount)), ("displacement", Value::Enum(kind)), ("pinning", Value::Enum(pin)), ("resizeLayer", num(resize))]; + let o = run("ec.distort.turbulentdisplace", &set, img.clone()); + let what = format!("amount {amount} kind {kind} pinning {pin} resize {resize}"); + assert!(o.img.data.iter().all(|p| p.iter().all(|v| v.is_finite()) && (0.0..=1.0 + 1e-5).contains(&p[3])), "{what}"); + let area = u64::from(o.img.width) * u64::from(o.img.height); + assert!(area <= 16_777_216, "{what}: {}x{}", o.img.width, o.img.height); + } + } + } + + /// #3469: an Amount past the hard range, which only an expression produces, renders without + /// overflowing the padding or the sampler's pixel positions and stays finite (a plain, a + /// gradient and the cross kind; unpinned, pinned and locked); one that is not a number leaves + /// the layer as it is. + #[test] + fn turbulent_displace_unbounded_amounts_do_not_crash() { + let img = test_img(32, 24); + let cases = [0, 1, 8].into_iter().flat_map(|kind| [(kind, 0, 0.0), (kind, 1, 0.0), (kind, 11, 0.0)]).chain([(0, 1, 1.0)]); + for amount in [1e12, -1e300, f64::MAX, f64::INFINITY, f64::NEG_INFINITY] { + for (kind, pin, resize) in cases.clone() { + let set = [("amount", num(amount)), ("displacement", Value::Enum(kind)), ("pinning", Value::Enum(pin)), ("resizeLayer", num(resize))]; + let o = run("ec.distort.turbulentdisplace", &set, img.clone()); + assert!(o.img.data.iter().all(|p| p.iter().all(|v| v.is_finite())), "{amount} kind {kind} pinning {pin} resize {resize}"); + } + } + for resize in [0.0, 1.0] { + assert_eq!(run("ec.distort.turbulentdisplace", &[("amount", num(f64::NAN)), ("resizeLayer", num(resize))], img.clone()).img, img); + } + } + #[test] fn griddler_default_is_identity() { let img = test_img(32, 24); diff --git a/crates/effects/src/lib.rs b/crates/effects/src/lib.rs index 5da2035ac..1e1003e7e 100644 --- a/crates/effects/src/lib.rs +++ b/crates/effects/src/lib.rs @@ -84,7 +84,7 @@ pub use color_fx::{COLORAMA_PRESETS, ColoramaPalette}; pub use color2::{Curve, auto_correct_settings, color_link_mode, color_link_sample, equalize_tables, luma_clip_points, shadow_highlight_amounts}; pub use color3::OffsetCurve; pub use distort::{transform_grow, transform_matrix_px, transform_shutter}; -pub use distort2::{MAGNIFY_MODES, bezier_grid, parse_mesh}; +pub use distort2::{MAGNIFY_MODES, bezier_grid, parse_mesh, turbulent_amount_px}; pub use distort3::{RESHAPE_POINTS, ReshapeSetup, SmearSetup, cc_smear_pad, reshape_setup, smear_setup, warp_inverse_map}; pub use distort4::liquify_mesh; use effectcraft_keyframe::Value; diff --git a/crates/gpu/src/fx_distort.rs b/crates/gpu/src/fx_distort.rs index 510f91e8c..cc25d3106 100644 --- a/crates/gpu/src/fx_distort.rs +++ b/crates/gpu/src/fx_distort.rs @@ -172,10 +172,9 @@ fn cc_lens(e: &mut Enc, ctx: &EffectCtx, b: GBuf) -> Option { } fn turbulent(e: &mut Enc, ctx: &EffectCtx, mut b: GBuf) -> Option { - let amount = ctx.params.f("amount") * b.scale; - if amount.abs() < 1e-9 { + let Some(amount) = effectcraft_effects::turbulent_amount_px(ctx, b.scale) else { return Some(b); - } + }; let kind = ctx.params.e("displacement"); let size = (ctx.params.f("size") * b.scale).max(1.0); if ctx.params.b("resizeLayer") && !ctx.adjustment { diff --git a/crates/gpu/src/tests/fx_distort.rs b/crates/gpu/src/tests/fx_distort.rs index 6fc18f3c9..e5e3ceca9 100644 --- a/crates/gpu/src/tests/fx_distort.rs +++ b/crates/gpu/src/tests/fx_distort.rs @@ -57,6 +57,14 @@ fn turbulent_displace_and_cc_lens() { ], ); effect_case("ec.distort.turbulentdisplace", &[("displacement", e(8)), ("size", n(15.0)), ("pinning", e(6))]); + // #3469: both ends of After Effects' Amount range, resized and pinned, and an expression's + // Amount past it. + effect_case("ec.distort.turbulentdisplace", &[("size", n(30.0)), ("amount", n(10000.0))]); + effect_case( + "ec.distort.turbulentdisplace", + &[("displacement", e(1)), ("size", n(25.0)), ("amount", n(-10000.0)), ("pinning", e(1)), ("resizeLayer", on())], + ); + effect_case("ec.distort.turbulentdisplace", &[("displacement", e(7)), ("amount", n(f64::INFINITY)), ("pinning", e(2))]); // #943: Evolution moves the pattern at a constant rate on both paths, including steps of a // few degrees and angles past a whole revolution, where an eased evolution axis diverges. for evolution in [10.0, 37.0, 400.0, 725.5] { diff --git a/docs/effects-parity.md b/docs/effects-parity.md index f2c827432..c438eedbb 100644 --- a/docs/effects-parity.md +++ b/docs/effects-parity.md @@ -64,7 +64,7 @@ the GPU is performance, not parity. | Date | Change | Summary | |---|---|---| -| 2026-11-17 | minor | Turbulent Displace: Amount takes After Effects' recorded valid range, −10000..10000 (default and the −200..200 slider unchanged) | +| 2026-11-17 | minor | Turbulent Displace: Amount takes After Effects' recorded valid range, −10000..10000 (default and the −200..200 slider unchanged). Past it (an expression's value) the displacement is bounded to 2^24 px and a NaN Amount leaves the layer unchanged, so padding and sampling stay finite (CPU and GPU) | | 2026-11-12 | minor | Parameters take After Effects' recorded valid ranges (hard range; defaults and sliders unchanged): Levels (Individual Controls) levels −10000..10000 and Gamma from 0; 4-Color Gradient Blend to 10000 and Jitter to 500 %; Change Color Hue Transform ±1800°; Noise HLS (and Auto) amounts to 1000 % and Grain Size from 0; Grid Border to 2000; Venetian Blinds Width 1..32000 and Feather to 32000; Radial Wipe Feather to 32000; Scatter Amount to 1000; Beam thicknesses to 4000; Transform Scale ±30000 %; Turbulent Displace Random Seed to 100000. A test checks every mapped parameter's range against the recorded table (CPU and GPU) | | 2026-10-19 | minor | Glow (original colours): bright pass per channel, 8 × (value − threshold + 0.061), measured against After Effects 2026 (CPU and GPU) | | 2026-10-19 | minor | Glow (colour channels): the glow covers the layer's blurred alpha, blur σ = 0.384 × radius, measured against After Effects 2026 renders (CPU and GPU) | From 4cf774134000e34f837f54584465161736da210d Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:14:01 +0530 Subject: [PATCH 13/20] #3469: Turbulent Displace locked pinning on a sub-pixel layer Locked pinning clamped samples to lx + 0.5 .. lx + lw - 0.5. On a layer under a buffer pixel across (a 1-pixel layer at half resolution) the bounds cross and f64::clamp panics. They now meet at the layer's centre there and are unchanged otherwise. --- crates/effects/src/distort2.rs | 21 ++++++++++++++++++++- docs/effects-parity.md | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/effects/src/distort2.rs b/crates/effects/src/distort2.rs index ed04c3493..8ca2f2d72 100644 --- a/crates/effects/src/distort2.rs +++ b/crates/effects/src/distort2.rs @@ -123,6 +123,10 @@ fn turbulent_displace(ctx: &EffectCtx, mut b: Buf) -> Buf { let falloff = if (3..=5).contains(&kind) { 0.3 } else { 0.5 }; let (lx, ly, lw, lh) = layer_rect(ctx, &b); let edge = (lw.min(lh) * if locked { 0.25 } else { 0.1 }).max(1.0); + // Locked: samples stay between the outermost pixel centres, or at the centre of a layer under + // a pixel across (half resolution), whose bounds would otherwise cross. + let (ix, iy) = (0.5f64.min(lw * 0.5), 0.5f64.min(lh * 0.5)); + let lock = (lx + ix, lx + lw - ix, ly + iy, ly + lh - iy); let seed = (ctx.seed ^ 0x7d15).wrapping_add((ctx.params.f("evolutionOptions/randomSeed") as i64 as u32).wrapping_mul(0x9e37_79b9)); let n = |u: f64, v: f64, s: u32| { let s = seed.wrapping_add(s); @@ -169,7 +173,7 @@ fn turbulent_displace(ctx: &EffectCtx, mut b: Buf) -> Buf { }; let (sx, sy) = (x + dx * k, y + dy * k); if locked { - return Some((sx.clamp(lx + 0.5, lx + lw - 0.5), sy.clamp(ly + 0.5, ly + lh - 0.5))); + return Some((sx.clamp(lock.0, lock.1), sy.clamp(lock.2, lock.3))); } Some((sx, sy)) }); @@ -1073,6 +1077,21 @@ mod tests { } } + /// #3469: a locked pinning on a layer under a buffer pixel across (a 1-pixel layer at half + /// resolution) keeps samples inside it without inverted clamp bounds, at any Amount. + #[test] + fn turbulent_displace_locked_pinning_on_a_subpixel_layer_does_not_crash() { + let spec = crate::find("ec.distort.turbulentdisplace").unwrap(); + for amount in [-10000.0, 50.0, 10000.0] { + let mut params = Params { values: spec.params.iter().map(|p| (p.id.to_string(), p.default.clone())).collect() }; + params.values.insert("amount".into(), num(amount)); + params.values.insert("pinning".into(), Value::Enum(8)); + let ctx = EffectCtx { params: ¶ms, time: 0.5, layer_size: [1.0, 1.0], seed: 3, adjustment: false, env: Default::default() }; + let o = crate::apply(spec, &ctx, Buf { img: test_img(1, 1), offset: [0.0, 0.0], scale: 0.5 }); + assert!(o.img.data.iter().all(|p| p.iter().all(|v| v.is_finite())), "{amount}"); + } + } + #[test] fn griddler_default_is_identity() { let img = test_img(32, 24); diff --git a/docs/effects-parity.md b/docs/effects-parity.md index c438eedbb..d109da598 100644 --- a/docs/effects-parity.md +++ b/docs/effects-parity.md @@ -64,7 +64,7 @@ the GPU is performance, not parity. | Date | Change | Summary | |---|---|---| -| 2026-11-17 | minor | Turbulent Displace: Amount takes After Effects' recorded valid range, −10000..10000 (default and the −200..200 slider unchanged). Past it (an expression's value) the displacement is bounded to 2^24 px and a NaN Amount leaves the layer unchanged, so padding and sampling stay finite (CPU and GPU) | +| 2026-11-17 | minor | Turbulent Displace: Amount takes After Effects' recorded valid range, −10000..10000 (default and the −200..200 slider unchanged). Past it (an expression's value) the displacement is bounded to 2^24 px and a NaN Amount leaves the layer unchanged, so padding and sampling stay finite (CPU and GPU). Locked pinning on a layer under a pixel across no longer crashes | | 2026-11-12 | minor | Parameters take After Effects' recorded valid ranges (hard range; defaults and sliders unchanged): Levels (Individual Controls) levels −10000..10000 and Gamma from 0; 4-Color Gradient Blend to 10000 and Jitter to 500 %; Change Color Hue Transform ±1800°; Noise HLS (and Auto) amounts to 1000 % and Grain Size from 0; Grid Border to 2000; Venetian Blinds Width 1..32000 and Feather to 32000; Radial Wipe Feather to 32000; Scatter Amount to 1000; Beam thicknesses to 4000; Transform Scale ±30000 %; Turbulent Displace Random Seed to 100000. A test checks every mapped parameter's range against the recorded table (CPU and GPU) | | 2026-10-19 | minor | Glow (original colours): bright pass per channel, 8 × (value − threshold + 0.061), measured against After Effects 2026 (CPU and GPU) | | 2026-10-19 | minor | Glow (colour channels): the glow covers the layer's blurred alpha, blur σ = 0.384 × radius, measured against After Effects 2026 renders (CPU and GPU) | From 300fc48f1ed525cea854d329f003f2abef4699d3 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:14:33 +0530 Subject: [PATCH 14/20] #3466: test Sharpen Amount clamps just outside 0..4000 prop.set of 4001 and -1 stores 4000 and 0, and undo/redo around the clamped set restore the values. --- crates/engine/src/tests/effect_ranges.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/engine/src/tests/effect_ranges.rs b/crates/engine/src/tests/effect_ranges.rs index f2ad2112e..b1c93ccb5 100644 --- a/crates/engine/src/tests/effect_ranges.rs +++ b/crates/engine/src/tests/effect_ranges.rs @@ -162,6 +162,23 @@ fn projects_saved_with_the_narrower_ranges_open_with_the_new_ones() { } } +/// #3466: Sharpen Amount clamps just outside After Effects' 0..4000, and an undo after a +/// clamped set restores the value from before it. +#[test] +fn sharpen_amount_clamps_outside_the_after_effects_range() { + let (mut s, l, _) = session(); + let (e, p) = ("ec.blur.sharpen", "amount"); + for (v, want) in [(4001.0, 4000.0), (-1.0, 0.0)] { + set(&mut s, l, e, p, 1000.0); + assert_eq!(set(&mut s, l, e, p, v), json!(want), "{v}: prop.set reply"); + assert_eq!(read(&mut s, l, e, p), want, "{v}"); + assert!(s.undo()); + assert_eq!(read(&mut s, l, e, p), 1000.0, "{v}: undo"); + assert!(s.redo()); + assert_eq!(read(&mut s, l, e, p), want, "{v}: redo"); + } +} + /// The property at `path` (`group/param`) in an effect instance. fn prop_mut<'a>(g: &'a mut PropGroup, path: &str) -> Option<&'a mut effectcraft_project::Property> { match path.split_once('/') { From d5e74c880fd779fef635a01993eafaed70f7b0b6 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:15:51 +0530 Subject: [PATCH 15/20] #3467: Radial Blur docs say the wide Zoom shape is unmeasured The spin helper's name gives its unit (degrees), the zoom helper's doc uses |amount| as the code does, and the parity row and tests say what is and is not checked against After Effects. --- crates/effects/src/misc.rs | 6 ++++-- crates/gpu/src/fx_generate.rs | 2 +- crates/raster/src/blur.rs | 7 ++++--- crates/raster/src/lib.rs | 2 +- docs/effects-parity.md | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/crates/effects/src/misc.rs b/crates/effects/src/misc.rs index ea196fc11..69a30505a 100644 --- a/crates/effects/src/misc.rs +++ b/crates/effects/src/misc.rs @@ -1151,7 +1151,8 @@ mod tests { /// Amount takes After Effects' valid range up to 1000 (#3467), Zoom 1000 a spread of 10. /// Zoom samples along the ray from the centre through the pixel, never past the centre: on a /// layer white left of the centre and black right of it, the right half stays black (scales - /// below 0 sampled the white half mirrored through the centre). Both Antialiasing settings. + /// below 0 sampled the white half mirrored through the centre). Both Antialiasing settings (the + /// renderer does not read it yet; the test keeps both covered). #[test] fn radial_blur_zoom_at_the_largest_amount_stays_on_its_side_of_the_centre() { let mut img = effectcraft_raster::Image::filled(64, 32, [0.0, 0.0, 0.0, 1.0]); @@ -1169,7 +1170,8 @@ mod tests { } /// Spin and Zoom at both ends of Amount (0..1000) and both Antialiasing settings give finite - /// colours over an opaque layer and keep it opaque (#3467). + /// colours over an opaque layer and keep it opaque (#3467). It guards the newly accepted + /// values; it passed before the Zoom fix too. #[test] fn radial_blur_is_finite_across_the_amount_range() { let mut img = effectcraft_raster::Image::new(48, 40); diff --git a/crates/gpu/src/fx_generate.rs b/crates/gpu/src/fx_generate.rs index 6e9594f60..8833e4d46 100644 --- a/crates/gpu/src/fx_generate.rs +++ b/crates/gpu/src/fx_generate.rs @@ -107,7 +107,7 @@ fn radial_blur(e: &mut Enc, ctx: &EffectCtx, b: GBuf) -> Option { if zoom { data.push(effectcraft_raster::radial_blur_zoom_scale(i, amount) as f32); } else { - let (s, c) = effectcraft_raster::radial_blur_spin_angle(i, amount).to_radians().sin_cos(); + let (s, c) = effectcraft_raster::radial_blur_spin_degrees(i, amount).to_radians().sin_cos(); data.extend([s as f32, c as f32]); } } diff --git a/crates/raster/src/blur.rs b/crates/raster/src/blur.rs index 751e0f5d0..9c9e7ec34 100644 --- a/crates/raster/src/blur.rs +++ b/crates/raster/src/blur.rs @@ -310,14 +310,15 @@ fn radial_blur_t(i: usize) -> f64 { } /// Spin sample `i`'s rotation in degrees for a spin of `amount` degrees. -pub fn radial_blur_spin_angle(i: usize, amount: f64) -> f64 { +pub fn radial_blur_spin_degrees(i: usize, amount: f64) -> f64 { radial_blur_t(i) * amount } /// Zoom sample `i`'s scale about the centre for a zoom of `amount` (a fraction of the distance /// to the centre): evenly over `1 ± amount / 2`. Past a spread of 2 (Radial Blur's Amount 200) /// that would reach below 0 and sample the point mirrored through the centre, so the samples -/// spread evenly from the centre (0) to `1 + amount / 2` instead (#3467). +/// spread evenly from the centre (0) to `1 + |amount| / 2` instead (#3467). That wider shape is +/// EffectCraft's; After Effects has not been measured past Amount 200. pub fn radial_blur_zoom_scale(i: usize, amount: f64) -> f64 { let t = radial_blur_t(i); if amount.abs() <= 2.0 { @@ -342,7 +343,7 @@ pub fn radial_blur(img: &Image, center: (f64, f64), amount: f64, zoom: bool) -> let k = radial_blur_zoom_scale(i, amount); (center.0 + vx * k, center.1 + vy * k) } else { - let (s, c) = radial_blur_spin_angle(i, amount).to_radians().sin_cos(); + let (s, c) = radial_blur_spin_degrees(i, amount).to_radians().sin_cos(); (center.0 + vx * c - vy * s, center.1 + vx * s + vy * c) }; // Samples outside the image repeat its edge: After Effects' Radial Blur keeps a diff --git a/crates/raster/src/lib.rs b/crates/raster/src/lib.rs index 852065db4..58feead1a 100644 --- a/crates/raster/src/lib.rs +++ b/crates/raster/src/lib.rs @@ -18,7 +18,7 @@ use effectcraft_color::{BlendMode, blend_pixel}; use rayon::prelude::*; pub use blur::{ - RADIAL_BLUR_SAMPLES, box_blur, directional_blur, gaussian_blur, gaussian_blur_exact, gaussian_is_exact, radial_blur, radial_blur_spin_angle, + RADIAL_BLUR_SAMPLES, box_blur, directional_blur, gaussian_blur, gaussian_blur_exact, gaussian_is_exact, radial_blur, radial_blur_spin_degrees, radial_blur_zoom_scale, }; pub use channels3d::AuxChannels; diff --git a/docs/effects-parity.md b/docs/effects-parity.md index 9d6ca232f..1ef31c413 100644 --- a/docs/effects-parity.md +++ b/docs/effects-parity.md @@ -64,7 +64,7 @@ the GPU is performance, not parity. | Date | Change | Summary | |---|---|---| -| 2026-11-17 | minor | Radial Blur: Amount takes After Effects' valid range 0..1000 (slider and default unchanged); Zoom past 200 spreads its samples from the centre outwards instead of sampling the layer mirrored through the centre (CPU and GPU) | +| 2026-11-17 | minor | Radial Blur: Amount takes After Effects' valid range 0..1000 (slider and default unchanged); Zoom past 200 spreads its samples from the centre outwards instead of sampling the layer mirrored through the centre (CPU and GPU; not yet measured against After Effects past Amount 200) | | 2026-11-12 | minor | Parameters take After Effects' recorded valid ranges (hard range; defaults and sliders unchanged): Levels (Individual Controls) levels −10000..10000 and Gamma from 0; 4-Color Gradient Blend to 10000 and Jitter to 500 %; Change Color Hue Transform ±1800°; Noise HLS (and Auto) amounts to 1000 % and Grain Size from 0; Grid Border to 2000; Venetian Blinds Width 1..32000 and Feather to 32000; Radial Wipe Feather to 32000; Scatter Amount to 1000; Beam thicknesses to 4000; Transform Scale ±30000 %; Turbulent Displace Random Seed to 100000. A test checks every mapped parameter's range against the recorded table (CPU and GPU) | | 2026-10-19 | minor | Glow (original colours): bright pass per channel, 8 × (value − threshold + 0.061), measured against After Effects 2026 (CPU and GPU) | | 2026-10-19 | minor | Glow (colour channels): the glow covers the layer's blurred alpha, blur σ = 0.384 × radius, measured against After Effects 2026 renders (CPU and GPU) | From a62564b567befbf3d0f9410cfb553454d5d610b0 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:19:44 +0530 Subject: [PATCH 16/20] #3469: locked pinning clamps without f64::clamp The sub-pixel bounds lx + ix and lx + lw - ix round separately, so at third resolution they can still cross by an ulp and f64::clamp panics; a NaN layer size panicked too. max/min equals clamp whenever the bounds are ordered and cannot panic. The test now covers half and third resolution at fractional offsets and a NaN layer size. The parity note says Amount, not the displacement, is bounded to 2^24 px. --- crates/effects/src/distort2.rs | 19 ++++++++++++------- docs/effects-parity.md | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/effects/src/distort2.rs b/crates/effects/src/distort2.rs index 8ca2f2d72..24ffa3ab6 100644 --- a/crates/effects/src/distort2.rs +++ b/crates/effects/src/distort2.rs @@ -124,7 +124,8 @@ fn turbulent_displace(ctx: &EffectCtx, mut b: Buf) -> Buf { let (lx, ly, lw, lh) = layer_rect(ctx, &b); let edge = (lw.min(lh) * if locked { 0.25 } else { 0.1 }).max(1.0); // Locked: samples stay between the outermost pixel centres, or at the centre of a layer under - // a pixel across (half resolution), whose bounds would otherwise cross. + // a pixel across (a reduced resolution). Its bounds may still differ by rounding, so the + // clamp is max/min, which `f64::clamp` would panic on. let (ix, iy) = (0.5f64.min(lw * 0.5), 0.5f64.min(lh * 0.5)); let lock = (lx + ix, lx + lw - ix, ly + iy, ly + lh - iy); let seed = (ctx.seed ^ 0x7d15).wrapping_add((ctx.params.f("evolutionOptions/randomSeed") as i64 as u32).wrapping_mul(0x9e37_79b9)); @@ -173,7 +174,7 @@ fn turbulent_displace(ctx: &EffectCtx, mut b: Buf) -> Buf { }; let (sx, sy) = (x + dx * k, y + dy * k); if locked { - return Some((sx.clamp(lock.0, lock.1), sy.clamp(lock.2, lock.3))); + return Some((sx.max(lock.0).min(lock.1), sy.max(lock.2).min(lock.3))); } Some((sx, sy)) }); @@ -1077,8 +1078,9 @@ mod tests { } } - /// #3469: a locked pinning on a layer under a buffer pixel across (a 1-pixel layer at half - /// resolution) keeps samples inside it without inverted clamp bounds, at any Amount. + /// #3469: a locked pinning on a layer under a buffer pixel across (a 1-pixel layer at half or + /// third resolution, anywhere in the buffer) keeps samples inside it without its rounded + /// bounds crossing, at any Amount. #[test] fn turbulent_displace_locked_pinning_on_a_subpixel_layer_does_not_crash() { let spec = crate::find("ec.distort.turbulentdisplace").unwrap(); @@ -1086,9 +1088,12 @@ mod tests { let mut params = Params { values: spec.params.iter().map(|p| (p.id.to_string(), p.default.clone())).collect() }; params.values.insert("amount".into(), num(amount)); params.values.insert("pinning".into(), Value::Enum(8)); - let ctx = EffectCtx { params: ¶ms, time: 0.5, layer_size: [1.0, 1.0], seed: 3, adjustment: false, env: Default::default() }; - let o = crate::apply(spec, &ctx, Buf { img: test_img(1, 1), offset: [0.0, 0.0], scale: 0.5 }); - assert!(o.img.data.iter().all(|p| p.iter().all(|v| v.is_finite())), "{amount}"); + for (size, scale, offset) in [(1.0, 0.5, 0.0), (1.0, 1.0 / 3.0, -8.0), (1.0, 1.0 / 3.0, 7.0), (0.9, 1.0, -8.0), (f64::NAN, 1.0, 0.0)] { + let ctx = EffectCtx { params: ¶ms, time: 0.5, layer_size: [size, size], seed: 3, adjustment: false, env: Default::default() }; + let o = crate::apply(spec, &ctx, Buf { img: test_img(2, 2), offset: [offset, offset], scale }); + // A layer size that is not a number only has to render without panicking. + assert!(size.is_nan() || o.img.data.iter().all(|p| p.iter().all(|v| v.is_finite())), "{amount} {size} {scale} {offset}"); + } } } diff --git a/docs/effects-parity.md b/docs/effects-parity.md index d109da598..870a1ca49 100644 --- a/docs/effects-parity.md +++ b/docs/effects-parity.md @@ -64,7 +64,7 @@ the GPU is performance, not parity. | Date | Change | Summary | |---|---|---| -| 2026-11-17 | minor | Turbulent Displace: Amount takes After Effects' recorded valid range, −10000..10000 (default and the −200..200 slider unchanged). Past it (an expression's value) the displacement is bounded to 2^24 px and a NaN Amount leaves the layer unchanged, so padding and sampling stay finite (CPU and GPU). Locked pinning on a layer under a pixel across no longer crashes | +| 2026-11-17 | minor | Turbulent Displace: Amount takes After Effects' recorded valid range, −10000..10000 (default and the −200..200 slider unchanged). Past it (an expression's value) Amount is bounded to 2^24 px and a NaN Amount leaves the layer unchanged, so padding and sampling stay finite (CPU and GPU). Locked pinning on a layer under a pixel across no longer crashes | | 2026-11-12 | minor | Parameters take After Effects' recorded valid ranges (hard range; defaults and sliders unchanged): Levels (Individual Controls) levels −10000..10000 and Gamma from 0; 4-Color Gradient Blend to 10000 and Jitter to 500 %; Change Color Hue Transform ±1800°; Noise HLS (and Auto) amounts to 1000 % and Grain Size from 0; Grid Border to 2000; Venetian Blinds Width 1..32000 and Feather to 32000; Radial Wipe Feather to 32000; Scatter Amount to 1000; Beam thicknesses to 4000; Transform Scale ±30000 %; Turbulent Displace Random Seed to 100000. A test checks every mapped parameter's range against the recorded table (CPU and GPU) | | 2026-10-19 | minor | Glow (original colours): bright pass per channel, 8 × (value − threshold + 0.061), measured against After Effects 2026 (CPU and GPU) | | 2026-10-19 | minor | Glow (colour channels): the glow covers the layer's blurred alpha, blur σ = 0.384 × radius, measured against After Effects 2026 renders (CPU and GPU) | From 969286ae7615bb4c1fc13ad7768b8f2a8074bace Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:52:08 +0530 Subject: [PATCH 17/20] #3460: review: name the open follow-up for SLIDERS_0_24, use the shared pixel budget in the test The table holds only Gaussian Blur's row; the ranges changed since 0.24.1 by other work are tracked in #3815. The 30000 render test checks the buffer against crate::pixel_budget instead of a copied constant. --- crates/effects/src/misc.rs | 2 +- crates/engine/src/analysis/frames_key/legacy.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/effects/src/misc.rs b/crates/effects/src/misc.rs index 11a273888..08c2c5a73 100644 --- a/crates/effects/src/misc.rs +++ b/crates/effects/src/misc.rs @@ -1044,7 +1044,7 @@ mod tests { for repeat in [false, true] { let out = run_fx("ec.blur.gaussian", &[("blurriness", num(30000.0)), ("repeatEdge", Value::Bool(repeat))], edge(), 0.0, EffectEnv::default()); let (w, h) = (out.img.width, out.img.height); - assert!(u64::from(w) * u64::from(h) <= 16_777_216, "repeat {repeat}: {w} x {h}"); + assert!(f64::from(w) * f64::from(h) <= crate::pixel_budget(40.0, 8.0), "repeat {repeat}: {w} x {h}"); assert!(out.img.data.iter().flatten().all(|v| v.is_finite()), "repeat {repeat}"); if repeat { assert_eq!((w, h), (40, 8)); diff --git a/crates/engine/src/analysis/frames_key/legacy.rs b/crates/engine/src/analysis/frames_key/legacy.rs index 4b1b090a5..f3403b309 100644 --- a/crates/engine/src/analysis/frames_key/legacy.rs +++ b/crates/engine/src/analysis/frames_key/legacy.rs @@ -47,11 +47,12 @@ pub(crate) fn input_key_of(mut s: String, layer: &Layer, uid: Uid) -> String { format!("{:016x}", fnv(&s)) } -/// The slider ranges 0.22–0.24 gave effect parameters whose range has changed since, as +/// Slider ranges as 0.22–0.24 gave them, for parameters whose range has changed since, as /// (effect, parameter path, [min, max, slider min, slider max], decimals). Those releases hashed /// each effect's UI hints into the Roto Brush Input Key, and opening a project replaces an /// instance's hints with the current ones, so [`effect_text`] puts these back. A range change /// above a Roto Brush would otherwise drop the analysis such a key kept: add a row with it. +/// Not every range changed since 0.24.1 has its row yet (#3815). #[rustfmt::skip] const SLIDERS_0_24: &[(&str, &str, [f64; 4], u8)] = &[ ("ec.blur.gaussian", "blurriness", [0.0, 3000.0, 0.0, 50.0], 1), From ae2d595d9df799e8e8ed4545e38385fb809bbeca Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 17:25:47 +0530 Subject: [PATCH 18/20] fix(effects): exercise the wrapped combined cube row count --- crates/effects/src/utility.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/effects/src/utility.rs b/crates/effects/src/utility.rs index b38ded8db..171b9cc8e 100644 --- a/crates/effects/src/utility.rs +++ b/crates/effects/src/utility.rs @@ -483,7 +483,7 @@ mod tests { // A hostile size must be rejected, not overflow `n3^3` or `n1 + n3^3`. assert!(parse_cube("LUT_3D_SIZE 4294967296\n0 0 0\n").is_none()); assert!(parse_cube(&format!("LUT_3D_SIZE {}\n0 0 0\n", usize::MAX)).is_none()); - assert!(parse_cube(&format!("LUT_1D_SIZE {}\nLUT_3D_SIZE 2\n0 0 0\n", usize::MAX)).is_none()); + assert!(parse_cube(&format!("LUT_1D_SIZE {}\nLUT_3D_SIZE 2\n{}", usize::MAX, "0 0 0\n".repeat(7))).is_none()); let img = test_img(); let out = run("ec.utility.applylut", &[("lut", Value::Str("LUT_3D_SIZE 3\n0 0 0\n".into()))], img.clone()); assert_eq!(out.img, img); From 1eb4f39808e7f3e2855e787d69ffad528b576b3b Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 17:27:22 +0530 Subject: [PATCH 19/20] fix(effects): bound cube data row collection --- crates/effects/src/utility.rs | 38 ++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/crates/effects/src/utility.rs b/crates/effects/src/utility.rs index 171b9cc8e..ff8ff208d 100644 --- a/crates/effects/src/utility.rs +++ b/crates/effects/src/utility.rs @@ -169,6 +169,10 @@ pub struct Lut { pub dmax: [f32; 3], } +// Cube LUT Specification 1.0 §§6–7 permits at most 65,536 1D rows and a 256³ +// lattice. Allow their sum for combined shaper + 3D files, regardless of header order. +const MAX_CUBE_ROWS: usize = 65_536 + 256 * 256 * 256; + /// Parse `.cube` text (TITLE, LUT_1D_SIZE, LUT_3D_SIZE, DOMAIN_MIN/MAX, data red-fastest). pub fn parse_cube(text: &str) -> Option { let mut lut = Lut { n1: 0, d1: vec![], n3: 0, d3: vec![], dmin: [0.0; 3], dmax: [1.0; 3] }; @@ -212,7 +216,14 @@ pub fn parse_cube(text: &str) -> Option { lut.dmax = [hi; 3]; } k if k.starts_with(|c: char| c.is_ascii_alphabetic()) => continue, - _ => rows.push(three(&mut it)?), + _ => { + if rows.len() == MAX_CUBE_ROWS { + return None; + } + let row = three(&mut it)?; + rows.try_reserve(1).ok()?; + rows.push(row); + } } } if lut.n3 > 256 { @@ -223,8 +234,8 @@ pub fn parse_cube(text: &str) -> Option { if (lut.n1 == 0 && lut.n3 == 0) || lut.n1 == 1 || lut.n3 == 1 || Some(rows.len()) != need1.checked_add(need3) { return None; } - lut.d1 = rows[..need1].to_vec(); - lut.d3 = rows[need1..].to_vec(); + lut.d1 = rows.get(..need1)?.to_vec(); + lut.d3 = rows.get(need1..)?.to_vec(); Some(lut) } @@ -491,6 +502,27 @@ mod tests { assert_eq!(out.img, img); } + #[test] + fn cube_accepts_maximum_1d_shaper_with_3d_table() { + let text = format!("LUT_1D_SIZE 65536\nLUT_3D_SIZE 2\n{}", "0 0 0\n".repeat(65_536 + 8)); + let lut = parse_cube(&text).unwrap(); + assert_eq!(lut.d1.len(), 65_536); + assert_eq!(lut.d3.len(), 8); + // Keep the parser's existing tolerance for headers following data. + let text = format!("{}LUT_1D_SIZE 2\nLUT_3D_SIZE 2\n", "0 0 0\n".repeat(10)); + let lut = parse_cube(&text).unwrap(); + assert_eq!(lut.d1, vec![[0.0; 3]; 2]); + assert_eq!(lut.d3, vec![[0.0; 3]; 8]); + } + + #[test] + fn cube_row_collection_is_bounded() { + // Beyond the largest 3D table plus the largest 1D shaper in Cube LUT 1.0. + let count = 256 * 256 * 256 + 65_536 + 1; + let text = format!("LUT_1D_SIZE {count}\n{}", "0 0 0\n".repeat(count)); + assert!(parse_cube(&text).is_none()); + } + #[test] fn one_d_lut_with_domain() { let lut = parse_cube("LUT_1D_SIZE 2\nDOMAIN_MIN 0 0 0\nDOMAIN_MAX 2 2 2\n1 1 1\n0 0 0\n").unwrap(); From 1654633bcf1819a1db4cba14e6f11b25c979cb37 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 17:33:35 +0530 Subject: [PATCH 20/20] fix(effects): test the cube row bound without a huge input --- crates/effects/src/utility.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/effects/src/utility.rs b/crates/effects/src/utility.rs index 72f07cde9..b99de477b 100644 --- a/crates/effects/src/utility.rs +++ b/crates/effects/src/utility.rs @@ -222,6 +222,10 @@ const MAX_CUBE_ROWS: usize = 65_536 + 256 * 256 * 256; /// Parse `.cube` text (TITLE, LUT_1D_SIZE, LUT_3D_SIZE, DOMAIN_MIN/MAX, data red-fastest). pub fn parse_cube(text: &str) -> Option { + parse_cube_limited(text, MAX_CUBE_ROWS) +} + +fn parse_cube_limited(text: &str, max_rows: usize) -> Option { let mut lut = Lut { n1: 0, d1: vec![], n3: 0, d3: vec![], dmin: [0.0; 3], dmax: [1.0; 3] }; let mut rows: Vec<[f32; 3]> = Vec::new(); let three = |it: &mut std::str::SplitWhitespace| -> Option<[f32; 3]> { @@ -264,10 +268,11 @@ pub fn parse_cube(text: &str) -> Option { } k if k.starts_with(|c: char| c.is_ascii_alphabetic()) => continue, _ => { - if rows.len() == MAX_CUBE_ROWS { + if rows.len() == max_rows { return None; } let row = three(&mut it)?; + // Make buffer growth fallible before push can allocate. rows.try_reserve(1).ok()?; rows.push(row); } @@ -719,10 +724,11 @@ mod tests { #[test] fn cube_row_collection_is_bounded() { - // Beyond the largest 3D table plus the largest 1D shaper in Cube LUT 1.0. - let count = 256 * 256 * 256 + 65_536 + 1; - let text = format!("LUT_1D_SIZE {count}\n{}", "0 0 0\n".repeat(count)); - assert!(parse_cube(&text).is_none()); + assert_eq!(MAX_CUBE_ROWS, 65_536 + 256 * 256 * 256); + let text = "LUT_1D_SIZE 2\n0 0 0\n1 1 1\n"; + let lut = parse_cube_limited(text, 2).unwrap(); + assert_eq!(lut.d1, vec![[0.0; 3], [1.0; 3]]); + assert!(parse_cube_limited("LUT_1D_SIZE 3\n0 0 0\n0.5 0.5 0.5\n1 1 1\n", 2).is_none()); } #[test]