From e83be3a08f38be21a7345e86ebdc132a44c87b98 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:05:40 +0530 Subject: [PATCH 1/7] #3486: Fractal Noise: lattice neighbours wrap past the i32 range At Sub Scaling 10 % and high Complexity an octave's lattice coordinates pass the i32 range. The cast saturates, and adding the neighbour offset overflowed (a panic in debug builds). Wrap it, as the GPU's i32 adds do. --- crates/effects/src/noise3.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/effects/src/noise3.rs b/crates/effects/src/noise3.rs index 49f200553..0533db03b 100644 --- a/crates/effects/src/noise3.rs +++ b/crates/effects/src/noise3.rs @@ -158,7 +158,8 @@ pub fn typed_noise(x: f32, y: f32, z: f32, seed: u32, noise_type: u32) -> f32 { let (ix, iy, iz) = (x0 as i32, y0 as i32, z0 as i32); let l = |a: f32, b: f32, t: f32| a + (b - a) * t; let slice = |dz: i32| -> f32 { - let c = |dx: i32, dy: i32| lattice(ix + dx, iy + dy, iz + dz, seed); + // Coordinates past the i32 range saturate; the neighbours wrap, as on the GPU (#3486). + let c = |dx: i32, dy: i32| lattice(ix.wrapping_add(dx), iy.wrapping_add(dy), iz.wrapping_add(dz), seed); match noise_type { 0 => c(0, 0), 1 => l(l(c(0, 0), c(1, 0), tx), l(c(0, 1), c(1, 1), tx), ty), @@ -483,6 +484,18 @@ mod tests { run_fx(id, vals, Image::filled(40, 24, [0.2, 0.4, 0.6, 1.0]), 0.0, EffectEnv::default()).img } + /// #3486: lattice coordinates past the i32 range (an octave's frequency at Sub Scaling 10 % and + /// high Complexity) saturate, and their neighbours wrap instead of overflowing. + #[test] + fn noise_past_the_i32_range_is_finite() { + for noise_type in [0, 1, 2, 3] { + for (x, y) in [(1e30, -1e30), (f32::MAX, f32::MIN), (3e9, 2.5e9)] { + let n = typed_noise(x, y, 1e12, 7, noise_type); + assert!(n.is_finite(), "type {noise_type} at ({x}, {y}): {n}"); + } + } + } + /// Evolution moves the noise at a constant rate: no ease in or out within a revolution. #[test] fn evolution_is_linear() { From 8f7896b28a269739b6b8405d246ab19406c74fa2 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:07:18 +0530 Subject: [PATCH 2/7] #3486: Fractal / Turbulent Noise: bound octave scales and scaled offsets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each octave's frequency and Perspective Offset depth are Sub Scaling to the power of the octave. Above 100 % (After Effects allows 10000) that reaches 100^±19 at Complexity 20, and Perspective Offset or Turbulence Factor times the offset overflowed to infinity and drew NaN. Both stay within 1e20 and its inverse and remain each other's inverse, so an octave's offset in lattice cells is unchanged; 10..100 never reaches the bound. The scaled offset stays within 1e36 px, past where the lattice index saturates. The CPU, fxn_fractal (from fractal_gpu) and pointwise paths share the bound; one octave_origin replaces the two copies of the origin code. --- crates/effects/src/lib.rs | 2 +- crates/effects/src/noise3.rs | 82 +++++++++++++++++++++-------- crates/gpu/src/effects.rs | 2 +- crates/gpu/src/shaders/kernels.wgsl | 7 ++- 4 files changed, 67 insertions(+), 26 deletions(-) diff --git a/crates/effects/src/lib.rs b/crates/effects/src/lib.rs index 5da2035ac..7f0f9cf51 100644 --- a/crates/effects/src/lib.rs +++ b/crates/effects/src/lib.rs @@ -112,7 +112,7 @@ pub use transition::{GridWipe, place_layer}; // effectcraft-gpu fx_noise. pub use keying2::{InnerOuterPlan, inner_outer_plan}; pub use noise::remove_grain_level; -pub use noise3::{FractalGpu, NOISE_CELL, fractal_gpu}; +pub use noise3::{FractalGpu, NOISE_CELL, OCTAVE_SCALE_MAX, fractal_gpu}; pub use stylize3::{BumpLight, HexTile, bump_layer_id}; pub use textfx::{TextLayer, text_layer}; pub use time_fx::{PixelMotion, TimewarpPlan, TwStep, pmb_plan, posterized_time, time_frames, timewarp_crop, timewarp_plan}; diff --git a/crates/effects/src/noise3.rs b/crates/effects/src/noise3.rs index 0533db03b..ae76d756a 100644 --- a/crates/effects/src/noise3.rs +++ b/crates/effects/src/noise3.rs @@ -65,6 +65,27 @@ pub const NOISE_SOFT_LINEAR: u32 = 2; /// correlation length), not 100 px. pub const NOISE_CELL: f64 = 2.0 / 3.0; +/// Bound on an octave's frequency and on its Perspective Offset depth (and their inverses). +/// Unbounded, at Sub Scaling 10000 and Complexity 20 they would reach 100^±19, and Perspective +/// Offset or Turbulence Factor multiplying the offset by the depth overflowed to infinity (NaN +/// noise, #3486). Sub Scaling 10..100 never reaches the bound (10^19 at most). Both stay each +/// other's inverse inside it, so an octave's offset in lattice cells is unchanged; an octave this +/// far out is a constant (or sub-pixel noise) across any layer either way. +pub const OCTAVE_SCALE_MAX: f32 = 1e20; + +/// Bound on an octave's scaled Offset Turbulence in pixels, so a huge offset times the depth stays +/// finite. Times a frequency of at least 1 / [`OCTAVE_SCALE_MAX`], over cells of at most about +/// 6700 px (Scale 10000 %), it is still over 10^12 lattice cells, past where the lattice index +/// saturates (2^31), so the output is the same. +const OCTAVE_OFFSET_MAX: f32 = 1e36; + +/// The next octave's (frequency, depth) from this one's, for a Sub Scaling ratio `s`. +#[inline] +fn next_octave(f: f32, depth: f32, s: f32) -> (f32, f32) { + let lo = 1.0 / OCTAVE_SCALE_MAX; + ((f / s).clamp(lo, OCTAVE_SCALE_MAX), (depth * s).clamp(lo, OCTAVE_SCALE_MAX)) +} + fn spec(id: &'static str, name: &'static str, params: Vec, render: crate::RenderFn) -> EffectSpec { EffectSpec { id, name, category: "Noise & Grain", params, render, gpu: false, float: true } } @@ -275,6 +296,23 @@ impl Fractal { } } + /// Octave `of`'s origin in pixels, at Perspective Offset `depth`: Perspective Offset moves finer + /// (farther) layers less; turbulence makes them drift faster. The scaled offset stays within + /// ±[`OCTAVE_OFFSET_MAX`] (#3486). + #[inline] + fn octave_origin(&self, of: f32, depth: f32) -> [f32; 2] { + let k = if self.perspective { depth } else { 1.0 } * (1.0 + self.turbulence * of); + let mut org = self.origin; + if k != 1.0 { + let d = |i: usize| ((self.origin[i] - self.center[i]) * k).clamp(-OCTAVE_OFFSET_MAX, OCTAVE_OFFSET_MAX); + org = [self.center[0] + d(0), self.center[1] + d(1)]; + } + if !self.center_subscale { + org = [org[0] + self.sub_offset[0] * of, org[1] + self.sub_offset[1] * of]; + } + org + } + /// Raw fractal value (before contrast / overflow) at pixel centre (x, y). pub(crate) fn raw(&self, x: f32, y: f32) -> f32 { let n_oct = self.octaves.ceil() as usize; @@ -285,16 +323,7 @@ impl Fractal { for o in 0..n_oct { let w = if o + 1 == n_oct && frac > 0.0 { frac } else { 1.0 }; let of = o as f32; - // This layer's origin: Perspective Offset moves finer (farther) layers less; - // turbulence makes them drift faster. - let k = if self.perspective { depth } else { 1.0 } * (1.0 + self.turbulence * of); - let mut org = self.origin; - if k != 1.0 { - org = [self.center[0] + (self.origin[0] - self.center[0]) * k, self.center[1] + (self.origin[1] - self.center[1]) * k]; - } - if !self.center_subscale { - org = [org[0] + self.sub_offset[0] * of, org[1] + self.sub_offset[1] * of]; - } + let org = self.octave_origin(of, depth); let (dx, dy) = (x - org[0], y - org[1]); let (mut u, mut v) = ((dx * cr + dy * sr) / self.size[0], (-dx * sr + dy * cr) / self.size[1]); if self.sub_rotation != 0.0 { @@ -324,8 +353,7 @@ impl Fractal { sum += n * amp * w; norm += amp * w; amp *= self.influence; - f /= self.sub_scaling; - depth *= self.sub_scaling; + (f, depth) = next_octave(f, depth, self.sub_scaling); } if self.kind == 7 { best } else { sum / norm.max(1e-6) } } @@ -377,22 +405,14 @@ pub fn fractal_gpu(ctx: &EffectCtx, offset: [f64; 2], scale: f64, turbulent: boo for o in 0..n_oct { let w = if o + 1 == n_oct && frac > 0.0 { frac } else { 1.0 }; let of = o as f32; - let k = if fr.perspective { depth } else { 1.0 } * (1.0 + fr.turbulence * of); - let mut org = fr.origin; - if k != 1.0 { - org = [fr.center[0] + (fr.origin[0] - fr.center[0]) * k, fr.center[1] + (fr.origin[1] - fr.center[1]) * k]; - } - if !fr.center_subscale { - org = [org[0] + fr.sub_offset[0] * of, org[1] + fr.sub_offset[1] * of]; - } + let org = fr.octave_origin(of, depth); let (s, c) = (fr.sub_rotation * of).sin_cos(); let evo = fr.evolution * (1.0 + fr.turbulence * of); let dk = if fr.kind == 6 { 0.5 + of * 0.35 } else { 1.0 }; octaves.push([org[0], org[1], s, c, f, amp, w, evo, of * 7.31, dk]); norm += amp * w; amp *= fr.influence; - f /= fr.sub_scaling; - depth *= fr.sub_scaling; + (f, depth) = next_octave(f, depth, fr.sub_scaling); } let cycle = fr.cycle.map(|c| { let t = fr.evolution.rem_euclid(c); @@ -496,6 +516,24 @@ mod tests { } } + /// #3486: octave frequency and depth stay each other's inverse and finite at 20 octaves of + /// either end of Sub Scaling, and are unchanged inside the old 10..100 range. + #[test] + fn octave_scales_stay_finite_and_inverse() { + for s in [0.1f32, 0.56, 1.0, 2.0, 100.0] { + let (mut f, mut depth, (mut f0, mut d0)) = (1.0f32, 1.0f32, (1.0f32, 1.0f32)); + for _ in 0..19 { + (f, depth) = next_octave(f, depth, s); + (f0, d0) = (f0 / s, d0 * s); + assert!(f.is_finite() && depth.is_finite() && f > 0.0 && depth > 0.0, "{s}: {f} {depth}"); + assert!((f * depth - 1.0).abs() < 1e-3, "{s}: {f} × {depth}"); + if s <= 1.0 { + assert_eq!((f, depth), (f0, d0), "{s}"); + } + } + } + } + /// Evolution moves the noise at a constant rate: no ease in or out within a revolution. #[test] fn evolution_is_linear() { diff --git a/crates/gpu/src/effects.rs b/crates/gpu/src/effects.rs index fd5a97c38..5f204d1c4 100644 --- a/crates/gpu/src/effects.rs +++ b/crates/gpu/src/effects.rs @@ -608,7 +608,7 @@ fn pointwise(e: &mut Enc, id: &str, ctx: &EffectCtx, b: GBuf) -> Option { (f("opacity") as f32 / 100.0).clamp(0.0, 1.0), (sh * effectcraft_effects::NOISE_CELL * b.scale).max(1.0) as f32, ]; - p.f[3] = [(f("subSettings/subInfluence") as f32 / 100.0).clamp(0.0, 1.0), 1.0 / sub as f32, 0.0, 0.0]; + p.f[3] = [(f("subSettings/subInfluence") as f32 / 100.0).clamp(0.0, 1.0), 1.0 / sub as f32, effectcraft_effects::OCTAVE_SCALE_MAX, 0.0]; } _ => return None, } diff --git a/crates/gpu/src/shaders/kernels.wgsl b/crates/gpu/src/shaders/kernels.wgsl index a123b70ca..e038a9ee8 100644 --- a/crates/gpu/src/shaders/kernels.wgsl +++ b/crates/gpu/src/shaders/kernels.wgsl @@ -618,7 +618,8 @@ fn straight(px: vec4) -> vec3 { // 9 Gradient Ramp f[0] = (sx, sy, ex, ey); f[1] = start colour; f[2] = end colour; // f[3] = (len2, scatter, blend); u[0] = (_, radial, seed) // 10 Fractal Noise f[0] = (contrast, brightness, scale x, frac); f[1] = (ox, oy, sr, cr); -// f[2] = (evo, blend, opacity, scale y); f[3] = (sub influence, 1 / sub scaling); +// f[2] = (evo, blend, opacity, scale y); f[3] = (sub influence, 1 / sub scaling, +// OCTAVE_SCALE_MAX); // u[0] = (_, kind, n_oct, seed); u[1] = (invert, overflow, normal blend) @compute @workgroup_size(16, 16) fn pointwise(@builtin(global_invocation_id) gid: vec3) { @@ -856,6 +857,7 @@ fn pointwise(@builtin(global_invocation_id) gid: vec3) { let scale_y = P.f[2].w; let infl = P.f[3].x; let fmul = P.f[3].y; + let fmax = P.f[3].z; let frac = P.f[0].w; let ox = P.f[1].x; let oy = P.f[1].y; @@ -888,7 +890,8 @@ fn pointwise(@builtin(global_invocation_id) gid: vec3) { sum += n * amp * w; norm += amp * w; amp *= infl; - f *= fmul; + // noise3::next_octave: the frequency stays within OCTAVE_SCALE_MAX (#3486). + f = clamp(f * fmul, 1.0 / fmax, fmax); } var val = sum / max(norm, 1e-6); val = (val - 0.5) * contrast + 0.5 + brightness; From ec1294a1d28f38574d0d44b480aa8846c8114b7d Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:10:16 +0530 Subject: [PATCH 3/7] #3486: Fractal Noise: Sub Scaling takes After Effects' 10..10000 After Effects records Sub Scaling's valid range as 10..10000 (slider 25..100), but the hard range stopped at 100, so prop.set and the value editors clamped 200 to 100. The CPU renderer and the GPU pointwise path also capped the ratio at 1, so a value above 100 rendered as 100 even once stored. Widen the hard range for Fractal and Turbulent Noise (they share the parameter; slider and default unchanged) and take the ratio from one sub_scaling_ratio (0.1..100) on the CPU and both GPU paths. Above 100 each octave is larger than the last. Tests: the range and that 200 and 10000 render differently from 100; finite output at both ends with Complexity 20, Perspective Offset, Turbulence Factor 10 and a huge offset; CPU/GPU parity at 200 and 10000 on the pointwise and fxn_fractal paths; prop.set, undo/redo and save/reopen keep 10 and 10000 (engine range table). The .aep range guard no longer lists the parameter. --- crates/aep/src/export/fx_defs.rs | 1 - crates/effects/src/lib.rs | 2 +- crates/effects/src/noise3.rs | 57 ++++++++++++++++++++++-- crates/engine/src/tests/effect_ranges.rs | 2 + crates/gpu/src/effects.rs | 2 +- crates/gpu/src/tests/fx_noise.rs | 18 ++++++++ docs/effects-parity.md | 1 + 7 files changed, 77 insertions(+), 6 deletions(-) diff --git a/crates/aep/src/export/fx_defs.rs b/crates/aep/src/export/fx_defs.rs index 338e00fc5..fa2047739 100644 --- a/crates/aep/src/export/fx_defs.rs +++ b/crates/aep/src/export/fx_defs.rs @@ -736,7 +736,6 @@ mod tests { ("ec.time.pixelmotionblur", "shutterAngle", 3481), ("ec.time.pixelmotionblur", "shutterSamples", 3482), ("ec.noise.fractal", "subSettings/subInfluence", 3485), - ("ec.noise.fractal", "subSettings/subScaling", 3486), ("ec.distort.ccpowerpin", "expandTop", 3492), ("ec.distort.ccpowerpin", "expandLeft", 3492), ("ec.distort.ccpowerpin", "expandRight", 3492), diff --git a/crates/effects/src/lib.rs b/crates/effects/src/lib.rs index 7f0f9cf51..155755dea 100644 --- a/crates/effects/src/lib.rs +++ b/crates/effects/src/lib.rs @@ -112,7 +112,7 @@ pub use transition::{GridWipe, place_layer}; // effectcraft-gpu fx_noise. pub use keying2::{InnerOuterPlan, inner_outer_plan}; pub use noise::remove_grain_level; -pub use noise3::{FractalGpu, NOISE_CELL, OCTAVE_SCALE_MAX, fractal_gpu}; +pub use noise3::{FractalGpu, NOISE_CELL, OCTAVE_SCALE_MAX, fractal_gpu, sub_scaling_ratio}; pub use stylize3::{BumpLight, HexTile, bump_layer_id}; pub use textfx::{TextLayer, text_layer}; pub use time_fx::{PixelMotion, TimewarpPlan, TwStep, pmb_plan, posterized_time, time_frames, timewarp_crop, timewarp_plan}; diff --git a/crates/effects/src/noise3.rs b/crates/effects/src/noise3.rs index ae76d756a..c12ebaa1c 100644 --- a/crates/effects/src/noise3.rs +++ b/crates/effects/src/noise3.rs @@ -65,6 +65,12 @@ pub const NOISE_SOFT_LINEAR: u32 = 2; /// correlation length), not 100 px. pub const NOISE_CELL: f64 = 2.0 / 3.0; +/// Sub Scaling (percent, After Effects' valid 10..10000) as the size ratio of each octave to the +/// one before it. Above 1 each octave is larger than the last. +pub fn sub_scaling_ratio(percent: f64) -> f64 { + (percent / 100.0).clamp(0.1, 100.0) +} + /// Bound on an octave's frequency and on its Perspective Offset depth (and their inverses). /// Unbounded, at Sub Scaling 10000 and Complexity 20 they would reach 100^±19, and Perspective /// Offset or Turbulence Factor multiplying the offset by the depth overflowed to infinity (NaN @@ -109,7 +115,7 @@ fn params(turbulent: bool) -> Vec { p("transform/perspectiveOffset", "Perspective Offset", Value::Bool(false), ParamUi::Checkbox), p("complexity", "Complexity", num(6.0), slider(1.0, 20.0, 1.0, 10.0, 1)), p("subSettings/subInfluence", "Sub Influence (%)", num(70.0), slider(0.0, 100.0, 25.0, 100.0, 1)), - p("subSettings/subScaling", "Sub Scaling", num(56.0), slider(10.0, 100.0, 25.0, 100.0, 1)), + p("subSettings/subScaling", "Sub Scaling", num(56.0), slider(10.0, 10000.0, 25.0, 100.0, 1)), ]; if !turbulent { v.extend([ @@ -217,7 +223,8 @@ pub(crate) struct Fractal { pub perspective: bool, pub octaves: f32, pub influence: f32, - /// Sub Scaling as a fraction (each layer is this much smaller). + /// Sub Scaling as a size ratio ([`sub_scaling_ratio`]: each octave is this much the size of the + /// one before). pub sub_scaling: f32, pub sub_rotation: f32, /// Sub Offset in pixels. @@ -269,7 +276,7 @@ impl Fractal { perspective: pr.b("transform/perspectiveOffset"), octaves: pr.f("complexity").clamp(1.0, 20.0) as f32, influence: (pr.f("subSettings/subInfluence") as f32 / 100.0).clamp(0.0, 1.0), - sub_scaling: (pr.f("subSettings/subScaling") as f32 / 100.0).clamp(0.1, 1.0), + sub_scaling: sub_scaling_ratio(pr.f("subSettings/subScaling")) as f32, sub_rotation: (pr.f("subSettings/subRotation") as f32).to_radians(), sub_offset: [(so[0] * b.scale) as f32, (so[1] * b.scale) as f32], center_subscale: pr.b("subSettings/centerSubscale"), @@ -709,6 +716,50 @@ mod tests { assert_ne!(t0, t1); } + /// #3486: Sub Scaling takes After Effects' 10..10000 for both effects (the slider still shows + /// 25..100), and the renderer uses values above 100 instead of capping them there. + #[test] + fn sub_scaling_takes_the_after_effects_range() { + for id in ["ec.noise.fractal", "ec.noise.turbulent"] { + let ui = &crate::find(id).unwrap().params.iter().find(|p| p.id == "subSettings/subScaling").unwrap().ui; + assert!( + matches!(ui, ParamUi::Slider { min, max, slider_min, slider_max, .. } + if *min == 10.0 && *max == 10000.0 && *slider_min == 25.0 && *slider_max == 100.0), + "{id}: {ui:?}" + ); + let at = |v: f64| run(id, &[("subSettings/subScaling", num(v))]); + assert_ne!(at(100.0), at(200.0), "{id}: 200 renders as 100"); + assert_ne!(at(200.0), at(10000.0), "{id}: 10000 renders as 200"); + } + } + + /// #3486: above 100 %, each octave is larger than the last, so its scale grows as Sub + /// Scaling^octave (100^19 at Complexity 20). Perspective Offset and Turbulence Factor multiply + /// the offset by that, which overflowed to infinity and drew NaN, also for a huge offset. At + /// 10 % the lattice coordinates pass the i32 range, whose neighbour index overflowed. + #[test] + fn extreme_sub_scaling_stays_finite() { + for id in ["ec.noise.fractal", "ec.noise.turbulent"] { + for sub in [10.0, 100.0, 9999.0, 10000.0] { + for (perspective, offset) in [(false, [-3000.0, 2500.0]), (true, [-3000.0, 2500.0]), (true, [1e17, -1e17])] { + let mut vals = vec![ + ("subSettings/subScaling", num(sub)), + ("complexity", num(20.0)), + ("transform/perspectiveOffset", Value::Bool(perspective)), + ("transform/offset", Value::Vec2(offset)), + ("evolution", num(200.0)), + ("blendingMode", Value::Enum(BLEND_NONE)), + ]; + if id == "ec.noise.turbulent" { + vals.push(("evolutionOptions/turbulenceFactor", num(10.0))); + } + let img = run(id, &vals); + assert!(img.data.iter().flatten().all(|c| c.is_finite()), "{id} sub {sub} perspective {perspective} offset {offset:?}: non-finite output"); + } + } + } + } + /// Turbulent Basic Fractal Noise drawn alone at `w` × `h`. fn turbulent_basic(w: u32, h: u32, vals: &[(&str, Value)]) -> Image { let mut all = vec![("fractalType", Value::Enum(2)), ("blendingMode", Value::Enum(BLEND_NONE))]; diff --git a/crates/engine/src/tests/effect_ranges.rs b/crates/engine/src/tests/effect_ranges.rs index 7deaaa911..9a5789506 100644 --- a/crates/engine/src/tests/effect_ranges.rs +++ b/crates/engine/src/tests/effect_ranges.rs @@ -60,6 +60,8 @@ 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), + (3486, "ec.noise.fractal", "subSettings/subScaling", 10.0, 10000.0), + (3486, "ec.noise.turbulent", "subSettings/subScaling", 10.0, 10000.0), ]; fn path(effect: &str, param: &str) -> String { diff --git a/crates/gpu/src/effects.rs b/crates/gpu/src/effects.rs index 5f204d1c4..4f85c6193 100644 --- a/crates/gpu/src/effects.rs +++ b/crates/gpu/src/effects.rs @@ -592,7 +592,7 @@ fn pointwise(e: &mut Enc, id: &str, ctx: &EffectCtx, b: GBuf) -> Option { let (ox, oy) = b.to_px(pr.v2("transform/offset")); let s = f("transform/scale"); let (sw, sh) = if pr.b("transform/uniformScaling") { (s, s) } else { (f("transform/scaleWidth"), f("transform/scaleHeight")) }; - let sub = (f("subSettings/subScaling") / 100.0).clamp(0.1, 1.0); + let sub = effectcraft_effects::sub_scaling_ratio(f("subSettings/subScaling")); p.u[0] = [10, kind, octaves.ceil() as u32, f("evolutionOptions/seed") as u32 ^ 0x51ed]; p.u[1] = [pr.b("invert") as u32, pr.e("overflow"), mode, 0]; p.f[0] = [ diff --git a/crates/gpu/src/tests/fx_noise.rs b/crates/gpu/src/tests/fx_noise.rs index 006128c73..1bfdd9e56 100644 --- a/crates/gpu/src/tests/fx_noise.rs +++ b/crates/gpu/src/tests/fx_noise.rs @@ -136,6 +136,24 @@ fn turbulent_noise() { effect_case("ec.noise.turbulent", &[("fractalType", e(7)), ("noiseType", e(0)), ("transform/perspectiveOffset", on()), ("opacity", n(70.0))]); } +/// #3486: Sub Scaling above 100 % on both GPU paths (the `pointwise` kernel for the plain +/// settings, `fxn_fractal` for Perspective Offset and Turbulent Noise), up to After Effects' +/// 10000 at the highest Complexity. +#[test] +fn fractal_noise_sub_scaling_above_100() { + for sub in [200.0, 10000.0] { + effect_case("ec.noise.fractal", &[("subSettings/subScaling", n(sub)), ("complexity", n(20.0))]); + effect_case( + "ec.noise.fractal", + &[("subSettings/subScaling", n(sub)), ("complexity", n(20.0)), ("transform/perspectiveOffset", on()), ("evolution", n(90.0))], + ); + effect_case( + "ec.noise.turbulent", + &[("subSettings/subScaling", n(sub)), ("complexity", n(20.0)), ("evolution", n(120.0)), ("evolutionOptions/turbulenceFactor", n(10.0))], + ); + } +} + #[test] fn fractal_noise_other_modes() { effect_case("ec.noise.fractal", &[("noiseType", e(3)), ("fractalType", e(4)), ("blendingMode", e(3))]); diff --git a/docs/effects-parity.md b/docs/effects-parity.md index b07c624f8..e8962cfac 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 | 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-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 9b47fcf92fd895092919eaa78bde480288662684 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:10:22 +0530 Subject: [PATCH 4/7] #3585: Up and Down select the previous and next effect in Effect Controls With an effect header selected in a focused, on-screen Effect Controls, plain Down / Up now select the next / previous effect in the stacking order (After Effects), going on from the lowest / highest selected one and stopping at the last / first without nudging the layer. It is a selection change only: no undo step, no document or time change. The arrows reuse the Left / Right collapse path and now act on the layer the panel shows, so a locked panel's effects answer to them too. Modified arrows, hidden panels, text fields, menus, dialogs, viewer text editing and parameter-only selections keep their existing behaviour. --- crates/ui-egui/src/menus/shortcuts.rs | 2 +- crates/ui-egui/src/panels/effect_controls.rs | 2 +- .../src/panels/effect_controls/panel.rs | 53 ++++-- crates/ui-egui/tests/it/ui_effect_controls.rs | 162 ++++++++++++++++++ 4 files changed, 198 insertions(+), 21 deletions(-) diff --git a/crates/ui-egui/src/menus/shortcuts.rs b/crates/ui-egui/src/menus/shortcuts.rs index a573a2f6d..ff48f4d45 100644 --- a/crates/ui-egui/src/menus/shortcuts.rs +++ b/crates/ui-egui/src/menus/shortcuts.rs @@ -403,7 +403,7 @@ fn handle_shortcuts_impl(app: &mut EffectcraftApp, ctx: &egui::Context, tab_only if app.dialog.is_some() { continue; } - if !mods.any() && crate::panels::effect_controls::handle_disclosure_key(app, key) { + if !mods.any() && crate::panels::effect_controls::handle_arrow_key(app, key) { ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, key)); continue; } diff --git a/crates/ui-egui/src/panels/effect_controls.rs b/crates/ui-egui/src/panels/effect_controls.rs index 4c297f9e6..0b2ee437b 100644 --- a/crates/ui-egui/src/panels/effect_controls.rs +++ b/crates/ui-egui/src/panels/effect_controls.rs @@ -43,7 +43,7 @@ mod viewer; pub use common::{choose_files_after_apply, reveal_applied, set_lock}; pub(crate) use common::{gesture_key, scope_lock, shown_layer_id}; -pub(crate) use panel::handle_disclosure_key; +pub(crate) use panel::handle_arrow_key; pub use panel::{show, start_rename}; pub(crate) use rows::toggle_pick; pub use viewer::viewer_hook; diff --git a/crates/ui-egui/src/panels/effect_controls/panel.rs b/crates/ui-egui/src/panels/effect_controls/panel.rs index ac11bc7a2..5c06dec61 100644 --- a/crates/ui-egui/src/panels/effect_controls/panel.rs +++ b/crates/ui-egui/src/panels/effect_controls/panel.rs @@ -1,39 +1,54 @@ -use super::common::{Actions, PARAM_NAME_X, ROW, effect_active, prune_lock, shown_layer}; +use super::common::{Actions, PARAM_NAME_X, ROW, effect_active, prune_lock, shown_layer, shown_layer_id}; use super::editors::{curves_editor, editor_height, histogram_only, levels_editor, object_matte_editor, roto_editor, warp_editor}; use super::rows::{FxScope, group_rows, toggle_closed}; use super::{Align2, Color32, EffectcraftApp, EvalCtx, GroupKind, Icon, Layer, PropGroup, Rect, Sense, Stroke, Tokens, json, pos2, vec2, widgets}; use crate::dock::{PanelKind, WorkspaceExt as _}; -/// Plain Right / Left Arrow expand / collapse the selected effects, as in After Effects, before -/// the arrows' layer nudge runs. Only while Effect Controls has the focus and is on screen: the -/// front tab of its frame, drawn last frame (a maximized frame hides every other frame and every -/// floating window), not behind Home. With no effect header selected the arrows still nudge. -pub(crate) fn handle_disclosure_key(app: &mut EffectcraftApp, key: egui::Key) -> bool { +/// Plain arrows in Effect Controls, as in After Effects, before their layer nudge runs: Right / +/// Left expand / collapse the selected effects, and Down / Up select the next / previous effect +/// in the stacking order, from the lowest / highest selected one, stopping at the last / first. +/// Only while Effect Controls has the focus and is on screen: the front tab of its frame, drawn +/// last frame (a maximized frame hides every other frame and every floating window), not behind +/// Home. Only the effect headers selected on the layer the panel shows (the locked one when it is +/// locked) count: with none the arrows still nudge. +pub(crate) fn handle_arrow_key(app: &mut EffectcraftApp, key: egui::Key) -> bool { + use egui::Key::{ArrowDown, ArrowLeft, ArrowRight, ArrowUp}; let panel = PanelKind::EffectControls; if app.ui.focused != panel || app.ui.start_screen || app.session.state.text_edit.is_some() || !app.ui.dock.is_visible(panel) || !app.dock_rects.iter().any(|(p, _)| *p == panel) - || !matches!(key, egui::Key::ArrowLeft | egui::Key::ArrowRight) + || !matches!(key, ArrowLeft | ArrowRight | ArrowUp | ArrowDown) { return false; } - let Some(comp) = app.session.active_comp() else { return false }; - let Some(layer) = app.session.state.selected_layers.first().and_then(|id| comp.layer(*id)) else { return false }; - let Some(effects) = layer.effects() else { return false }; - let mut handled = false; - for g in effects.groups() { - if matches!(&g.kind, GroupKind::Effect { .. }) && app.session.state.selected_props.contains(&(layer.id, g.uid)) { - if key == egui::Key::ArrowLeft { - app.ui.fx_closed.insert(g.uid); - } else { - app.ui.fx_closed.remove(&g.uid); + let Some(layer_id) = shown_layer_id(app) else { return false }; + let Some(effects) = app.session.active_comp().and_then(|c| c.layer(layer_id)).and_then(|l| l.effects()) else { return false }; + let headers: Vec = effects.groups().filter(|g| matches!(&g.kind, GroupKind::Effect { .. })).map(|g| g.uid).collect(); + let selected = &app.session.state.selected_props; + let picked: Vec = headers.iter().enumerate().filter(|(_, u)| selected.contains(&(layer_id, **u))).map(|(i, _)| i).collect(); + let (Some(&top), Some(&bottom)) = (picked.first(), picked.last()) else { return false }; + match key { + ArrowUp | ArrowDown => { + // Clamped at the ends, where the key still doesn't nudge the layer. + let to = if key == ArrowUp { top.saturating_sub(1) } else { bottom.saturating_add(1).min(headers.len().saturating_sub(1)) }; + if let Some(&uid) = headers.get(to) { + // A selection, as a click on the header makes it: no undo step. + app.session.state.selected_props = vec![(layer_id, uid)]; + } + } + _ => { + for uid in picked.iter().filter_map(|i| headers.get(*i)) { + if key == ArrowLeft { + app.ui.fx_closed.insert(*uid); + } else { + app.ui.fx_closed.remove(uid); + } } - handled = true; } } - handled + true } // --------------------------------------------------------------------------------------------- diff --git a/crates/ui-egui/tests/it/ui_effect_controls.rs b/crates/ui-egui/tests/it/ui_effect_controls.rs index bfeea16aa..88f705f89 100644 --- a/crates/ui-egui/tests/it/ui_effect_controls.rs +++ b/crates/ui-egui/tests/it/ui_effect_controls.rs @@ -264,6 +264,168 @@ fn effect_header_arrows_leave_viewer_text_editing_alone() { assert_eq!(h.state().ui.fx_closed.iter().copied().collect::>(), vec![fx], "with the edit over, Left collapses the effect"); } +/// The x and y of `lid`'s Position, which the arrows' layer nudge moves. +fn position(h: &Harness<'_, EffectcraftApp>, lid: LayerId) -> [f64; 2] { + let p = layer(&h.state().session, lid.0).props.prop("transform/position").unwrap().value.as_vec3(); + [p[0], p[1]] +} + +/// #3585: plain Down / Up select the next / previous effect, a collapsed one too, and stop at the +/// last / first one without nudging the layer. Only the selection changes: not the document, the +/// time, the history or what is open. +#[test] +fn effect_header_down_and_up_select_the_next_and_previous_effect() { + let (mut h, lid, [(first, _), (second, _), (third, _)]) = header_arrow_harness(); + let at = rect_of(&h, &format!("effectControls.effect.{first}.name")).center(); + click(&mut h, at); + assert_eq!(h.state().session.state.selected_props, vec![(lid, first)]); + h.state_mut().ui.fx_closed.insert(second); + let project = serde_json::to_value(&h.state().session.project).unwrap(); + let time = h.state().session.time(); + let history = (h.state().session.history.undo.len(), h.state().session.history.redo.len()); + let closed = h.state().ui.fx_closed.clone(); + let (down, up) = (egui::Key::ArrowDown, egui::Key::ArrowUp); + for (key, want) in [(down, second), (down, third), (down, third), (up, second), (up, first), (up, first)] { + header_arrow_key(&mut h, key, egui::Modifiers::NONE); + assert_eq!(h.state().session.state.selected_props, vec![(lid, want)], "{key:?}"); + assert_eq!(serde_json::to_value(&h.state().session.project).unwrap(), project, "{key:?}: the layer is not nudged"); + assert_eq!(h.state().session.time(), time, "{key:?}"); + assert_eq!((h.state().session.history.undo.len(), h.state().session.history.redo.len()), history, "{key:?}: no undo step"); + assert_eq!(h.state().ui.fx_closed, closed, "{key:?}: nothing opens or closes"); + assert_eq!(h.state().ui.focused, PanelKind::EffectControls); + } +} + +/// #3585: with several effects selected, Down goes on from the lowest one and Up from the highest, +/// leaving one effect selected. Headers of other layers, stale ids and parameters don't count. +#[test] +fn effect_header_down_and_up_go_on_from_the_ends_of_a_multiple_selection() { + let (mut h, lid, [(first, _), (second, prop), (third, _)]) = header_arrow_harness(); + for (picked, key, want) in [ + (vec![(lid, second), (lid, first)], egui::Key::ArrowDown, third), + (vec![(lid, third), (lid, second)], egui::Key::ArrowUp, first), + (vec![(lid, first), (lid, third)], egui::Key::ArrowDown, third), + (vec![(lid, first), (lid, third)], egui::Key::ArrowUp, first), + (vec![(LayerId(0), first), (lid, u64::MAX), (lid, prop), (lid, second)], egui::Key::ArrowDown, third), + ] { + h.state_mut().session.state.selected_props = picked.clone(); + header_arrow_key(&mut h, key, egui::Modifiers::NONE); + assert_eq!(h.state().session.state.selected_props, vec![(lid, want)], "{picked:?} {key:?}"); + } + // A shift-click range, picked from the third effect up to the first, as a user would. + let at = rect_of(&h, &format!("effectControls.effect.{third}.name")).center(); + click(&mut h, at); + let at = rect_of(&h, &format!("effectControls.effect.{first}.name")).center(); + h.event(egui::Event::ModifiersChanged(egui::Modifiers::SHIFT)); + click(&mut h, at); + h.event(egui::Event::ModifiersChanged(Default::default())); + h.step(); + assert_eq!(h.state().session.state.selected_props.len(), 3, "the range is selected"); + header_arrow_key(&mut h, egui::Key::ArrowUp, egui::Modifiers::NONE); + assert_eq!(h.state().session.state.selected_props, vec![(lid, first)]); +} + +/// #3585: without an effect header selected on the panel's layer, or with the panel or the +/// keyboard elsewhere, plain Up / Down keep nudging the layer (or go to whoever owns the keys), +/// and the effect selection stays. +#[test] +fn effect_header_down_and_up_leave_the_nudge_and_other_keyboard_owners_alone() { + let (mut h, lid, [(first, _), (second, prop), _]) = header_arrow_harness(); + // A parameter, a stale header and another layer's header: the layer moves down, then up. + let picked = vec![(lid, prop), (lid, u64::MAX), (LayerId(0), first)]; + h.state_mut().session.state.selected_props = picked.clone(); + let y = position(&h, lid)[1]; + header_arrow_key(&mut h, egui::Key::ArrowDown, egui::Modifiers::NONE); + // (One pixel at the viewer's magnification.) + let step = position(&h, lid)[1] - y; + assert!(step > 0.0, "Down still nudges the layer"); + header_arrow_key(&mut h, egui::Key::ArrowUp, egui::Modifiers::NONE); + assert!((position(&h, lid)[1] - y).abs() < 1e-6, "Up still nudges the layer"); + assert_eq!(h.state().session.state.selected_props, picked); + + // With an effect selected: Shift nudges ten pixels, Cmd/Ctrl keeps its own meaning. + h.state_mut().session.state.selected_props = vec![(lid, second)]; + header_arrow_key(&mut h, egui::Key::ArrowDown, egui::Modifiers::SHIFT); + assert!((position(&h, lid)[1] - (y + 10.0 * step)).abs() < 1e-6, "Shift+Down nudges ten pixels"); + header_arrow_key(&mut h, egui::Key::ArrowUp, egui::Modifiers::SHIFT); + assert!((position(&h, lid)[1] - y).abs() < 1e-6); + header_arrow_key(&mut h, egui::Key::ArrowDown, egui::Modifiers::COMMAND); + assert_eq!(h.state().session.state.selected_props, vec![(lid, second)], "Cmd/Ctrl+Down keeps the effect selection"); + + // Another panel, a dialog, the context menu and the rename field own the arrows. + let stays = |h: &mut Harness<'_, EffectcraftApp>, why: &str| { + for key in [egui::Key::ArrowDown, egui::Key::ArrowUp] { + header_arrow_key(h, key, egui::Modifiers::NONE); + assert_eq!(h.state().session.state.selected_props, vec![(lid, second)], "{why}: {key:?}"); + } + }; + h.state_mut().ui.focused = PanelKind::Composition; + stays(&mut h, "another panel"); + h.state_mut().ui.focused = PanelKind::EffectControls; + h.state_mut().dialog = Some(effectcraft_ui_egui::Dialog::About); + stays(&mut h, "a dialog"); + h.state_mut().dialog = None; + h.run_steps(3); + let at = rect_of(&h, &format!("effectControls.effect.{second}.name")).center(); + h.event(egui::Event::PointerMoved(at)); + for pressed in [true, false] { + h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Secondary, pressed, modifiers: egui::Modifiers::NONE }); + h.step(); + } + h.run_steps(2); + assert!(egui::Popup::is_any_open(&h.ctx), "the effect context menu is open"); + stays(&mut h, "the context menu"); + header_arrow_key(&mut h, egui::Key::Escape, egui::Modifiers::NONE); + h.run_steps(3); + double_click(&mut h, at); + h.run_steps(3); + assert!(h.state().auto.find(&format!("effectControls.effect.{second}.nameEdit")).is_some(), "the rename field is open"); + stays(&mut h, "the rename field"); + assert!(h.state().auto.find(&format!("effectControls.effect.{second}.nameEdit")).is_some()); +} + +/// #3585: a hidden Effect Controls (closed, under a maximized frame, behind Home) with the focus +/// left on it doesn't take Up / Down: they nudge the layer. +#[test] +fn effect_header_down_and_up_ignore_a_hidden_panel() { + for hidden in ["closed", "maximized", "home"] { + let (mut h, lid, [(fx, _), _, _]) = header_arrow_harness(); + h.state_mut().session.state.selected_props = vec![(lid, fx)]; + match hidden { + "closed" => h.state_mut().close_panel(PanelKind::EffectControls), + "maximized" => h.state_mut().toggle_maximize(PanelKind::Composition), + _ => h.state_mut().ui.start_screen = true, + } + h.run_steps(2); + assert_eq!(h.state().ui.focused, PanelKind::EffectControls, "{hidden}: stale focus is preserved"); + let y = position(&h, lid)[1]; + header_arrow_key(&mut h, egui::Key::ArrowDown, egui::Modifiers::NONE); + assert_eq!(h.state().session.state.selected_props, vec![(lid, fx)], "{hidden}"); + assert!(position(&h, lid)[1] > y, "{hidden}: Down still nudges the layer"); + } +} + +/// #3585: locked to a layer that isn't selected, Effect Controls' arrows act on the effects it +/// shows: Down / Up select among them and Left / Right close and open them. +#[test] +fn effect_header_arrows_act_on_the_locked_layer() { + let (mut h, lid, [(first, _), (second, _), _]) = header_arrow_harness(); + let comp = h.state().session.active_comp_id().unwrap().0; + let other = h.state_mut().session.execute("layer.newSolid", json!({"name": "Other", "color": "#202020"})).unwrap()["layer"].as_u64().unwrap(); + h.state_mut().ui.effect_controls_lock = Some(effectcraft_ui_egui::state::EffectControlsLock { comp, layer: lid.0 }); + h.state_mut().session.state.selected_layers = vec![LayerId(other)]; + h.state_mut().session.state.selected_props = vec![(lid, first)]; + h.state_mut().ui.focused = PanelKind::EffectControls; + h.run_steps(3); + assert!(shows_effect(&h, first), "the locked panel shows the first layer"); + header_arrow_key(&mut h, egui::Key::ArrowDown, egui::Modifiers::NONE); + assert_eq!(h.state().session.state.selected_props, vec![(lid, second)]); + header_arrow_key(&mut h, egui::Key::ArrowLeft, egui::Modifiers::NONE); + assert_eq!(h.state().ui.fx_closed.iter().copied().collect::>(), vec![second], "Left closes the locked layer's effect"); + header_arrow_key(&mut h, egui::Key::ArrowRight, egui::Modifiers::NONE); + assert!(h.state().ui.fx_closed.is_empty()); +} + #[test] fn effect_controls_widgets_register_automation_ids() { let (app, x) = app(); From 4d318a5347bd2608870ea2dcd2e91183b319e100 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:11:18 +0530 Subject: [PATCH 5/7] #3585: scroll the effect Up / Down picks into view Effect Controls scrolls its list so the header Down / Up selected is in view, as a long effect stack would otherwise move the selection off screen. The key handler leaves the effect to reveal for the panel's next pass, which knows where the header is laid out. --- crates/ui-egui/src/menus/shortcuts.rs | 2 +- .../src/panels/effect_controls/panel.rs | 25 +++++++++++++- crates/ui-egui/tests/it/ui_effect_controls.rs | 34 +++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/menus/shortcuts.rs b/crates/ui-egui/src/menus/shortcuts.rs index ff48f4d45..eaca5568a 100644 --- a/crates/ui-egui/src/menus/shortcuts.rs +++ b/crates/ui-egui/src/menus/shortcuts.rs @@ -403,7 +403,7 @@ fn handle_shortcuts_impl(app: &mut EffectcraftApp, ctx: &egui::Context, tab_only if app.dialog.is_some() { continue; } - if !mods.any() && crate::panels::effect_controls::handle_arrow_key(app, key) { + if !mods.any() && crate::panels::effect_controls::handle_arrow_key(app, ctx, key) { ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, key)); continue; } diff --git a/crates/ui-egui/src/panels/effect_controls/panel.rs b/crates/ui-egui/src/panels/effect_controls/panel.rs index 5c06dec61..f89a6eac0 100644 --- a/crates/ui-egui/src/panels/effect_controls/panel.rs +++ b/crates/ui-egui/src/panels/effect_controls/panel.rs @@ -11,7 +11,7 @@ use crate::dock::{PanelKind, WorkspaceExt as _}; /// last frame (a maximized frame hides every other frame and every floating window), not behind /// Home. Only the effect headers selected on the layer the panel shows (the locked one when it is /// locked) count: with none the arrows still nudge. -pub(crate) fn handle_arrow_key(app: &mut EffectcraftApp, key: egui::Key) -> bool { +pub(crate) fn handle_arrow_key(app: &mut EffectcraftApp, ctx: &egui::Context, key: egui::Key) -> bool { use egui::Key::{ArrowDown, ArrowLeft, ArrowRight, ArrowUp}; let panel = PanelKind::EffectControls; if app.ui.focused != panel @@ -36,6 +36,7 @@ pub(crate) fn handle_arrow_key(app: &mut EffectcraftApp, key: egui::Key) -> bool if let Some(&uid) = headers.get(to) { // A selection, as a click on the header makes it: no undo step. app.session.state.selected_props = vec![(layer_id, uid)]; + reveal_effect(ctx, uid); } } _ => { @@ -51,6 +52,17 @@ pub(crate) fn handle_arrow_key(app: &mut EffectcraftApp, key: egui::Key) -> bool true } +/// The effect header the next Effect Controls pass scrolls into view. +fn reveal_id() -> egui::Id { + egui::Id::unique("ec-reveal") +} + +/// Scroll Effect Controls so effect `uid`'s header is in view, once it has been laid out. +fn reveal_effect(ctx: &egui::Context, uid: u64) { + ctx.data_mut(|d| d.insert_temp(reveal_id(), uid)); + ctx.request_repaint(); +} + // --------------------------------------------------------------------------------------------- /// Open the rename field on effect `uid` (Enter with the effect selected). It takes the keyboard, @@ -449,7 +461,18 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) { actions.extend(crate::menus::menu_contents(app, ui, "Effect")); }); let content_h = y + scroll.offset - body.min.y; + let offset = scroll.offset; scroll.end(ui, &mut app.auto, "effectControls.scroll", content_h, &t); + // Up / Down picked an effect: bring its header into view from the next pass (after `end`, + // which stores this pass's offset). + if let Some(uid) = ctx.data_mut(|d| d.remove_temp::(reveal_id())) + && let Some(&(_, top)) = tops.iter().find(|(u, _)| *u == uid) + { + // (With the 4-point gap above the first header.) + let top = top - body.min.y + offset; + widgets::PanelScroll::reveal(&ctx, egui::Id::unique("ec-scroll"), top - 4.0, top + ROW + 2.0, body.height()); + ctx.request_repaint(); + } drop_payload(ui, rect, &p, &t, layer.id.0, &mut actions); if ui.input(|i| i.pointer.primary_down()) && actions.iter().any(|(id, _)| id == "prop.set") { app.ui.viewer.property_interacting = true; diff --git a/crates/ui-egui/tests/it/ui_effect_controls.rs b/crates/ui-egui/tests/it/ui_effect_controls.rs index 88f705f89..49de1f24c 100644 --- a/crates/ui-egui/tests/it/ui_effect_controls.rs +++ b/crates/ui-egui/tests/it/ui_effect_controls.rs @@ -426,6 +426,40 @@ fn effect_header_arrows_act_on_the_locked_layer() { assert!(h.state().ui.fx_closed.is_empty()); } +/// #3585: a long effect list scrolls so the effect Down / Up picks stays in view. +#[test] +fn effect_header_down_and_up_scroll_the_picked_effect_into_view() { + let mut s = Session::default(); + s.execute("comp.new", json!({"name": "Long", "width": 32, "height": 18, "frameRate": 30, "duration": 2})).unwrap(); + let lid = s.execute("layer.newSolid", json!({"name": "Controls", "color": "#40b080"})).unwrap()["layer"].as_u64().unwrap(); + let fx: Vec = + (0..16).map(|_| s.execute("effect.apply", json!({"layers": [lid], "effect": "Point Control"})).unwrap()["effects"][0].as_u64().unwrap()).collect(); + s.state.selected_props = vec![(LayerId(lid), fx[0])]; + let mut app = EffectcraftApp::new(s); + app.show_panel(PanelKind::EffectControls); + app.toggle_maximize(PanelKind::EffectControls); + app.ui.focused = PanelKind::EffectControls; + let mut h = Harness::builder().with_size(egui::vec2(800.0, 300.0)).with_step_dt(1.0 / 60.0).build_eframe(|_| app); + h.run_steps(4); + let panel = rect_of(&h, "panel.EffectControls"); + let last = fx[fx.len() - 1]; + assert!(!panel.contains_rect(rect_of(&h, &format!("effectControls.effect.{last}"))), "the last effect starts out of view"); + for _ in 1..fx.len() { + header_arrow_key(&mut h, egui::Key::ArrowDown, egui::Modifiers::NONE); + h.run_steps(2); + let (_, uid) = h.state().session.state.selected_props[0]; + assert!(panel.contains_rect(rect_of(&h, &format!("effectControls.effect.{uid}"))), "Down keeps effect {uid} in view"); + } + assert_eq!(h.state().session.state.selected_props, vec![(LayerId(lid), last)]); + for _ in 1..fx.len() { + header_arrow_key(&mut h, egui::Key::ArrowUp, egui::Modifiers::NONE); + h.run_steps(2); + let (_, uid) = h.state().session.state.selected_props[0]; + assert!(panel.contains_rect(rect_of(&h, &format!("effectControls.effect.{uid}"))), "Up keeps effect {uid} in view"); + } + assert_eq!(h.state().session.state.selected_props, vec![(LayerId(lid), fx[0])]); +} + #[test] fn effect_controls_widgets_register_automation_ids() { let (app, x) = app(); From 14d58661902f31a26b688a205a9a45fa34e28b03 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:17:48 +0530 Subject: [PATCH 6/7] #3585: say where the gap revealed above an effect header comes from --- crates/ui-egui/src/panels/effect_controls/panel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ui-egui/src/panels/effect_controls/panel.rs b/crates/ui-egui/src/panels/effect_controls/panel.rs index f89a6eac0..5ced41673 100644 --- a/crates/ui-egui/src/panels/effect_controls/panel.rs +++ b/crates/ui-egui/src/panels/effect_controls/panel.rs @@ -468,7 +468,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) { if let Some(uid) = ctx.data_mut(|d| d.remove_temp::(reveal_id())) && let Some(&(_, top)) = tops.iter().find(|(u, _)| *u == uid) { - // (With the 4-point gap above the first header.) + // (With the 4-point gap above it: the panel starts with one and every effect ends with one.) let top = top - body.min.y + offset; widgets::PanelScroll::reveal(&ctx, egui::Id::unique("ec-scroll"), top - 4.0, top + ROW + 2.0, body.height()); ctx.request_repaint(); From e60d6ac706ff3aa65c2b1529059b87f1077274f0 Mon Sep 17 00:00:00 2001 From: arnav-hiwarkar Date: Tue, 17 Nov 2026 16:22:07 +0530 Subject: [PATCH 7/7] #3486: review: the octave test checks the bound; clearer bound comment The octave test asserts both values stay within OCTAVE_SCALE_MAX (it passed with the bound removed). The comment names Perspective Offset as what multiplies the offset by the depth, and says why an octave at the bound has no detail. --- crates/effects/src/noise3.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/effects/src/noise3.rs b/crates/effects/src/noise3.rs index c12ebaa1c..ee0c8103c 100644 --- a/crates/effects/src/noise3.rs +++ b/crates/effects/src/noise3.rs @@ -73,10 +73,10 @@ pub fn sub_scaling_ratio(percent: f64) -> f64 { /// Bound on an octave's frequency and on its Perspective Offset depth (and their inverses). /// Unbounded, at Sub Scaling 10000 and Complexity 20 they would reach 100^±19, and Perspective -/// Offset or Turbulence Factor multiplying the offset by the depth overflowed to infinity (NaN -/// noise, #3486). Sub Scaling 10..100 never reaches the bound (10^19 at most). Both stay each -/// other's inverse inside it, so an octave's offset in lattice cells is unchanged; an octave this -/// far out is a constant (or sub-pixel noise) across any layer either way. +/// Offset multiplying the offset by the depth (and by Turbulence Factor's drift) overflowed to +/// infinity (NaN noise, #3486). Sub Scaling 10..100 never reaches the bound (10^19 at most). Both +/// stay each other's inverse inside it, so an octave's offset in lattice cells is unchanged; at a +/// frequency of 1e-20 an octave spans under 1e-12 cells of any layer, so it has no detail either way. pub const OCTAVE_SCALE_MAX: f32 = 1e20; /// Bound on an octave's scaled Offset Turbulence in pixels, so a huge offset times the depth stays @@ -532,7 +532,8 @@ mod tests { for _ in 0..19 { (f, depth) = next_octave(f, depth, s); (f0, d0) = (f0 / s, d0 * s); - assert!(f.is_finite() && depth.is_finite() && f > 0.0 && depth > 0.0, "{s}: {f} {depth}"); + let lo = 1.0 / OCTAVE_SCALE_MAX; + assert!((lo..=OCTAVE_SCALE_MAX).contains(&f) && (lo..=OCTAVE_SCALE_MAX).contains(&depth), "{s}: {f} {depth}"); assert!((f * depth - 1.0).abs() < 1e-3, "{s}: {f} × {depth}"); if s <= 1.0 { assert_eq!((f, depth), (f0, d0), "{s}");