Merge upstream main into fix/3460-gaussian-blur-range

Keeps the Gaussian Blur (#3460) and Turbulent Displace (#3469) rows in
the engine range test and the effects parity log.
This commit is contained in:
arnav-hiwarkar
2026-11-17 17:57:21 +05:30
7 changed files with 105 additions and 10 deletions
-1
View File
@@ -731,7 +731,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),
+92 -5
View File
@@ -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<f64> {
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);
@@ -110,6 +123,11 @@ 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 (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));
let n = |u: f64, v: f64, s: u32| {
let s = seed.wrapping_add(s);
@@ -156,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(lx + 0.5, lx + lw - 0.5), sy.clamp(ly + 0.5, ly + lh - 0.5)));
return Some((sx.max(lock.0).min(lock.1), sy.max(lock.2).min(lock.3)));
}
Some((sx, sy))
});
@@ -736,7 +754,7 @@ pub fn specs() -> Vec<EffectSpec> {
"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 +1028,75 @@ 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));
}
/// #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);
}
}
/// #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();
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));
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: &params, 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}");
}
}
}
#[test]
fn griddler_default_is_identity() {
let img = test_img(32, 24);
+1 -1
View File
@@ -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;
+1
View File
@@ -61,6 +61,7 @@ const ROWS: &[(u32, &str, &str, f64, f64)] = &[
(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),
(3469, "ec.distort.turbulentdisplace", "amount", -10000.0, 10000.0),
(3492, "ec.distort.ccpowerpin", "expandTop", -200.0, 1000.0),
(3492, "ec.distort.ccpowerpin", "expandLeft", -200.0, 1000.0),
(3492, "ec.distort.ccpowerpin", "expandRight", -200.0, 1000.0),
+2 -3
View File
@@ -172,10 +172,9 @@ fn cc_lens(e: &mut Enc, ctx: &EffectCtx, b: GBuf) -> Option<GBuf> {
}
fn turbulent(e: &mut Enc, ctx: &EffectCtx, mut b: GBuf) -> Option<GBuf> {
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 {
+8
View File
@@ -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] {
+1
View File
@@ -65,6 +65,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-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) |
| 2026-11-17 | minor | CC Power Pin: Expansion (Top, Left, Right, Bottom) takes After Effects' minimum of −200 % (hard range −200..1000; defaults and sliders unchanged). When two opposite sides add up to less than −100 % the source rectangle flips (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) |