mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-19 00:17:13 +00:00
Merge pull request #3814 from arnav-hiwarkar/fix/3460-gaussian-blur-range
Gaussian Blur: Blurriness takes After Effects' range 0..30000 (#3460)
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -756,7 +756,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),
|
||||
],
|
||||
@@ -1036,6 +1036,25 @@ mod tests {
|
||||
assert_ne!(row(2.0), row(2.4));
|
||||
}
|
||||
|
||||
/// #3460: Blurriness goes up to After Effects' 30000. There the padding stays within the
|
||||
/// effect pixel budget, every pixel stays finite, and Repeat Edge Pixels still repeats the
|
||||
/// layer's edges: a layer white on the left and black on the right blurs to an even grey.
|
||||
#[test]
|
||||
fn gaussian_blur_at_the_highest_blurriness_is_bounded() {
|
||||
for repeat in [false, true] {
|
||||
let out = run_fx("ec.blur.gaussian", &[("blurriness", num(30000.0)), ("repeatEdge", Value::Bool(repeat))], edge(), 0.0, EffectEnv::default());
|
||||
let (w, h) = (out.img.width, out.img.height);
|
||||
assert!(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]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -60,6 +60,7 @@ const ROWS: &[(u32, &str, &str, f64, f64)] = &[
|
||||
(3471, "ec.distort.transform", "scaleHeight", -30000.0, 30000.0),
|
||||
(3471, "ec.distort.transform", "scaleWidth", -30000.0, 30000.0),
|
||||
(3470, "ec.distort.turbulentdisplace", "evolutionOptions/randomSeed", 0.0, 100000.0),
|
||||
(3460, "ec.blur.gaussian", "blurriness", 0.0, 30000.0),
|
||||
(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),
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -760,6 +760,35 @@ fn box_blur_horizontal_rows_match_cpu_beyond_256() {
|
||||
}
|
||||
}
|
||||
|
||||
/// #3460: a box radius far past the image (Gaussian Blur's at Blurriness 30000 is about 15000 px)
|
||||
/// starts each running sum as the CPU does, the pixels inside once and the repeated edges
|
||||
/// counted, so the GPU matches it along rows and columns, with and without repeated edges.
|
||||
#[test]
|
||||
fn box_passes_with_a_radius_far_past_the_image_match_cpu() {
|
||||
let Some(g) = gpu() else { return };
|
||||
let img = pattern(5, 96, 40);
|
||||
let up = g.ctx.upload_image(&img).expect("upload");
|
||||
let tol = tolerance(BitDepth::Bpc32);
|
||||
for repeat in [true, false] {
|
||||
let mut e = crate::context::Enc::new(&g.ctx);
|
||||
let r = [15_000usize; 3];
|
||||
let out = crate::effects::box_passes(&mut e, &up, &r, &r, repeat);
|
||||
let got = e.download(&out).expect("download");
|
||||
let want = effectcraft_raster::box_blur(&img, 15_000, 15_000, 3, repeat);
|
||||
assert_eq!((got.width, got.height), (want.width, want.height));
|
||||
let d = diff(&want, &got, tol);
|
||||
assert_eq!(d.over, 0, "repeat {repeat}: max {} at {:?} on {}", d.max, d.worst, g.ctx.name);
|
||||
}
|
||||
}
|
||||
|
||||
/// #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).
|
||||
|
||||
@@ -64,6 +64,7 @@ the GPU is performance, not parity.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-17 | minor | Gaussian Blur: Blurriness takes After Effects' recorded valid range 0..30000 (was 0..3000; default and 0..50 slider unchanged). Padding stays within the effect pixel budget at the top of the range (CPU and GPU), and Roto Brush analyses 0.24 saved below a Gaussian Blur still match (#3460) |
|
||||
| 2026-11-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) |
|
||||
|
||||
Reference in New Issue
Block a user