Merge remote-tracking branch 'upstream/main' into fix/3464-drop-shadow-softness-range

This commit is contained in:
arnav-hiwarkar
2026-11-17 20:54:02 +05:30
18 changed files with 440 additions and 33 deletions
-4
View File
@@ -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),
@@ -728,10 +727,7 @@ mod tests {
("ec.blur.channel", "alphaBlurriness", 3462),
("ec.obsolete.gaussianlegacy", "blurriness", 3463),
("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),
("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;
+112 -3
View File
@@ -781,7 +781,7 @@ pub fn specs() -> Vec<EffectSpec> {
"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),
],
@@ -811,7 +811,8 @@ pub fn specs() -> Vec<EffectSpec> {
"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.
@@ -819,7 +820,7 @@ pub fn specs() -> Vec<EffectSpec> {
],
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",
@@ -1127,6 +1128,68 @@ mod tests {
}
}
/// #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!(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));
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:?}");
}
}
}
}
/// #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:?}"
);
}
/// #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);
@@ -1238,6 +1301,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).
+49 -4
View File
@@ -216,8 +216,16 @@ 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<Lut> {
parse_cube_limited(text, MAX_CUBE_ROWS)
}
fn parse_cube_limited(text: &str, max_rows: usize) -> Option<Lut> {
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]> {
@@ -259,16 +267,27 @@ pub fn parse_cube(text: &str) -> Option<Lut> {
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_rows {
return None;
}
let row = three(&mut it)?;
// Make buffer growth fallible before push can allocate.
rows.try_reserve(1).ok()?;
rows.push(row);
}
}
}
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();
lut.d3 = rows[need1..].to_vec();
lut.d1 = rows.get(..need1)?.to_vec();
lut.d3 = rows.get(need1..)?.to_vec();
Some(lut)
}
@@ -571,6 +590,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\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);
@@ -686,6 +709,28 @@ mod tests {
std::fs::remove_dir_all(&dir).unwrap();
}
#[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() {
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]
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();
@@ -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,40 @@ 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))
}
/// 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),
];
/// 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 {
+14 -1
View File
@@ -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.
+21
View File
@@ -61,12 +61,16 @@ 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),
(3464, "ec.perspective.dropshadow", "softness", 0.0, 30000.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),
(3492, "ec.distort.ccpowerpin", "expandLeft", -200.0, 1000.0),
(3492, "ec.distort.ccpowerpin", "expandRight", -200.0, 1000.0),
(3492, "ec.distort.ccpowerpin", "expandBottom", -200.0, 1000.0),
(3486, "ec.noise.fractal", "subSettings/subScaling", 10.0, 10000.0),
(3486, "ec.noise.turbulent", "subSettings/subScaling", 10.0, 10000.0),
(3466, "ec.blur.sharpen", "amount", 0.0, 4000.0),
];
fn path(effect: &str, param: &str) -> String {
@@ -168,6 +172,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('/') {
+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 {
+4 -4
View File
@@ -100,14 +100,14 @@ fn radial_blur(e: &mut Enc, ctx: &EffectCtx, b: GBuf) -> Option<GBuf> {
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]);
}
}
+17 -1
View File
@@ -289,9 +289,25 @@ fn box_pass(gid: vec3<u32>, horizontal: bool) {
}
let norm = 1.0 / f32(2 * r + 1);
var acc = vec4<f32>(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) {
+29
View File
@@ -793,6 +793,35 @@ fn drop_shadow_large_softness_matches_cpu() {
}
}
/// #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);
}
}
/// #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).
+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] {
+3
View File
@@ -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]
+2
View File
@@ -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))]);
}
+50 -4
View File
@@ -435,24 +435,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
@@ -472,6 +498,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<f64> = (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 {
+2 -1
View File
@@ -18,7 +18,8 @@ use effectcraft_color::{BlendMode, blend_pixel};
use rayon::prelude::*;
pub use blur::{
box_blur, directional_blur, gaussian_blur, gaussian_blur_exact, gaussian_blur_unbounded, gaussian_blur_unbounded_at, gaussian_is_exact, radial_blur,
RADIAL_BLUR_SAMPLES, box_blur, directional_blur, gaussian_blur, gaussian_blur_exact, gaussian_blur_unbounded, gaussian_blur_unbounded_at,
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};
+4
View File
@@ -65,8 +65,12 @@ the GPU is performance, not parity.
| Date | Change | Summary |
|---|---|---|
| 2026-11-17 | minor | Drop Shadow: Softness takes After Effects' recorded valid range, 0..30000 (default and 0..250 slider unchanged). Where the padding budget cuts the margin, the shadow keeps its full blur (σ = Softness / 2) up to the buffer's edge, where it is cut; that case renders on the CPU |
| 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) |
| 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-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) |