diff --git a/crates/aep/src/export/fx_defs.rs b/crates/aep/src/export/fx_defs.rs index f91330b75..3656a9f09 100644 --- a/crates/aep/src/export/fx_defs.rs +++ b/crates/aep/src/export/fx_defs.rs @@ -728,7 +728,6 @@ mod tests { ("ec.obsolete.gaussianlegacy", "blurriness", 3463), ("ec.perspective.dropshadow", "softness", 3464), ("ec.blur.compound", "maximumBlur", 3465), - ("ec.blur.radial", "amount", 3467), ("ec.blur.ccradial", "amount", 3468), ("ec.time.pixelmotionblur", "shutterAngle", 3481), ("ec.time.pixelmotionblur", "shutterSamples", 3482), diff --git a/crates/effects/src/misc.rs b/crates/effects/src/misc.rs index a394b23db..6e709e739 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. @@ -1209,6 +1210,52 @@ 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 (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]); + 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). 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); + 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 84d9ac375..8a97388c9 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), (3460, "ec.blur.gaussian", "blurriness", 0.0, 30000.0), (3469, "ec.distort.turbulentdisplace", "amount", -10000.0, 10000.0), (3492, "ec.distort.ccpowerpin", "expandTop", -200.0, 1000.0), diff --git a/crates/gpu/src/fx_generate.rs b/crates/gpu/src/fx_generate.rs index 2dda38f45..8833e4d46 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_degrees(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..9c9e7ec34 100644 --- a/crates/raster/src/blur.rs +++ b/crates/raster/src/blur.rs @@ -300,24 +300,50 @@ 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_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). 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 { + 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_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 @@ -337,6 +363,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..58feead1a 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_degrees, + 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 f9fdd023c..cb49dc0dc 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; not yet measured against After Effects past Amount 200) | | 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-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-17 | minor | Fractal and Turbulent Noise: Sub Scaling takes After Effects' 10..10000 (slider and default unchanged), and above 100 each octave is larger than the last instead of being capped at 100; octave scales stay finite at Complexity 20 (CPU and GPU) |