M9.12: effect parameter fidelity – all categories

Align every effect's display name, category, parameter names, order,
twirl-down groups, popup options, units, defaults and ranges with the
public After Effects effect reference, and implement controls that were
ignored or missing where cheap. One commit because the categories share
the registry, migration tables and GPU kernels (only green states).

Infrastructure
- effects::migrate: saved instances are upgraded on project open
  (Session::replace_project → upgrade_effects): renamed ids
  (PARAM_ID_ALIASES), params moved into twirl-down groups, popup values
  remapped by label (POPUP_LABEL_ALIASES), refreshed names/UI hints,
  added params created with legacy_default values that keep old renders.
- flatten_params also keys nested props by match path (group/param), so
  effects declare grouped params with `group/param` ids; layer-source
  companions sit next to grouped layer params.
- lookup() resolves old effect names (EFFECT_NAME_ALIASES).
- Registry-wide test: unique ids/names, non-empty names, defaults in
  range, popup defaults within options, value kinds match UI.
- docs/effects.md generated from the registry (catalog.rs) with GPU /
  32-bpc badges and per-effect status; a test keeps it current.

Batches
- Blur & Sharpen, Channel, 3D Channel, Perspective, Text, Utility:
  Camera Lens Blur iris/highlight groups, Compound Blur layer, Camera-
  Shake Deblur method/strength, Invert full channel list (CPU HLS/YIQ),
  Set Channels/Set Matte layers, Channel Combiner targets, 3D Channel
  Extract clamp/invert.
- Color Correction: temporal smoothing + scene detect for Auto Color/
  Contrast/Levels and Shadow/Highlight, Brightness & Contrast legacy
  switch, Change to Color tolerance group, Leave Color, Photo Filter
  presets, Exposure channels, Levels clip popups, Colorama phase source,
  Color Link sample list, Lumetri groups (CPU + GPU kernels).
- Distort: Bulge, Displacement Map layer/behaviour, Magnify, Optics
  Compensation resize, Ripple conversion, Transform sampling, Turbulent
  Displace types/pinning/evolution, Wave Warp types/pinning, Twirl and
  Ripple radius fixes.
- Generate: 4-Color Gradient, Checkerboard, Grid, Circle size/feather/
  blending, Advanced Lightning types, Cell Pattern, Radio Waves, Fractal
  palettes, Scribble/Vegas names.
- Keying, Matte, Obsolete: Color Difference Key partials/views, Unmult
  controls, Key Light groups, Refine Soft/Hard Matte, Roto Brush groups,
  Mocha shape moved to Matte, Spill Suppressor accuracy, Basic/Path Text
  groups.
- Noise & Grain, Immersive Video, Audio, Time: Fractal/Turbulent Noise
  full control set (noise3.rs, GPU), grain look groups, Remove Grain,
  VR effects, Compressor/Gate/Distortion controls, Timewarp groups,
  VR Sphere to Plane name.
- Simulation: AE twirl-down groups for all simulations, Foam strength,
  Particle Playground barrel radius and mapper targets.
- Stylize, Transition: Glow looping/dimensions/alpha (CPU + GPU),
  Mosaic averaging, Cartoon groups, Roughen Edges evolution, Texturize
  layer, Gradient Wipe layer, Radial Wipe both, Card Wipe options.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-03 00:15:06 -04:00
co-authored by Claude Opus 5.5
parent 0631ef29dc
commit 355a6255a2
51 changed files with 6799 additions and 1737 deletions
+280 -68
View File
@@ -43,8 +43,39 @@ fn add_light(px: Px, l: [f32; 3], la: f32) -> Px {
// ---------------------------------------------------------------- Cell Pattern
/// Cell Pattern options. The HQ variants share the shaping of their standard counterparts
/// (we always render at full precision).
const CELL_PATTERNS: [&str; 12] = [
"Bubbles",
"Crystals",
"Plates",
"Static Plates",
"Crystallize",
"Pillow",
"Crystals HQ",
"Plates HQ",
"Static Plates HQ",
"Crystallize HQ",
"Mixed Crystals HQ",
"Tubular",
];
/// Shaping used for Cell Pattern option `i` (see [`cell_value`]).
fn pattern_kind(i: u32) -> u32 {
match i {
0..=5 => i,
6 => 1,
7 => 2,
8 => 3,
9 => 4,
10 => 6,
_ => 8,
}
}
/// Worley distances for point (u, v) in cell units: (F1, F2, hash of the nearest cell).
fn worley(u: f64, v: f64, disperse: f64, evo: f64, seed: u32) -> (f64, f64, f32) {
/// `tile` repeats the cell layout every (columns, rows) cells.
fn worley(u: f64, v: f64, disperse: f64, evo: f64, seed: u32, tile: Option<(i64, i64)>) -> (f64, f64, f32) {
let (cx, cy) = (u.floor() as i64, v.floor() as i64);
let mut f1 = f64::INFINITY;
let mut f2 = f64::INFINITY;
@@ -52,7 +83,11 @@ fn worley(u: f64, v: f64, disperse: f64, evo: f64, seed: u32) -> (f64, f64, f32)
for j in -1..=1 {
for i in -1..=1 {
let (gx, gy) = (cx + i, cy + j);
let (hx, hy) = (gx as i32 as u32, gy as i32 as u32);
let (tx, ty) = match tile {
Some((nx, ny)) => (gx.rem_euclid(nx), gy.rem_euclid(ny)),
None => (gx, gy),
};
let (hx, hy) = (tx as i32 as u32, ty as i32 as u32);
let h1 = hash1(hx, hy, seed) as f64;
let h2 = hash1(hx, hy, seed.wrapping_add(1)) as f64;
let h3 = hash1(hx, hy, seed.wrapping_add(2)) as f64;
@@ -83,7 +118,6 @@ fn cell_value(pattern: u32, f1: f64, f2: f64, id: f32) -> f32 {
4 => id, // Crystallize
5 => (1.0 - f1 * f1 * 2.0).clamp(0.0, 1.0), // Pillow
6 => id * (e * 3.0).clamp(0.0, 1.0), // Mixed Crystals
7 => smoothstep(0.35, 0.25, f1), // Dots
_ => 1.0 - ((e - 0.15).abs() * 5.0).clamp(0.0, 1.0), // Tubular
}
}
@@ -100,7 +134,7 @@ fn overflow(v: f32, mode: u32) -> f32 {
}
fn cell_pattern(ctx: &EffectCtx, mut b: Buf) -> Buf {
let pattern = ctx.params.e("cellPattern");
let pattern = pattern_kind(ctx.params.e("cellPattern"));
let invert = ctx.params.b("invert");
let contrast = ctx.params.f("contrast") as f32 / 100.0;
let ov = ctx.params.e("overflow");
@@ -108,12 +142,20 @@ fn cell_pattern(ctx: &EffectCtx, mut b: Buf) -> Buf {
let size = (ctx.params.f("size") * b.scale).max(1.0);
let off = b.to_px(ctx.params.v2("offset"));
// Static Plates keep their shades still while the cells move.
let evo = ctx.params.f("evolution") / 360.0;
let seed = (ctx.params.f("randomSeed") as i64 as u32).wrapping_mul(7919) ^ 0xce11;
let mut evo = ctx.params.f("evolution") / 360.0;
// Cycle Evolution loops the evolution every `cycle` revolutions.
if ctx.params.b("evolutionOptions/cycleEvolution") {
evo = evo.rem_euclid(ctx.params.f("evolutionOptions/cycle").round().max(1.0));
}
let seed = (ctx.params.f("evolutionOptions/randomSeed") as i64 as u32).wrapping_mul(7919) ^ 0xce11;
let tile = ctx
.params
.b("tilingOptions/enableTiling")
.then(|| (ctx.params.f("tilingOptions/cellsHorizontal").round().max(1.0) as i64, ctx.params.f("tilingOptions/cellsVertical").round().max(1.0) as i64));
map_xy(&mut b.img, |x, y, _| {
let u = (x as f64 + 0.5 - off.0) / size;
let v = (y as f64 + 0.5 - off.1) / size;
let (f1, f2, id) = worley(u, v, disperse, evo, seed);
let (f1, f2, id) = worley(u, v, disperse, evo, seed, tile);
let mut val = cell_value(pattern, f1, f2, id);
val = overflow((val - 0.5) * contrast + 0.5, ov);
if invert {
@@ -243,6 +285,10 @@ fn beam(ctx: &EffectCtx, mut b: Buf) -> Buf {
let inside = ctx.params.color("insideColor");
let outside = ctx.params.color("outsideColor");
let composite = ctx.params.b("compositeOnOriginal");
// 3D Perspective: thickness follows the beam's position between the two points (it
// grows / shrinks as it travels); off: the beam's own tail and head take the starting and
// ending thickness.
let persp = ctx.params.b("perspective3d");
let t0 = time * (1.0 - len);
let t1 = t0 + len;
let (dx, dy) = (e.0 - s.0, e.1 - s.1);
@@ -252,7 +298,8 @@ fn beam(ctx: &EffectCtx, mut b: Buf) -> Buf {
let tc = ((vx * dx + vy * dy) / l2).clamp(t0, t1);
let (qx, qy) = (s.0 + dx * tc, s.1 + dy * tc);
let dist = ((x as f64 + 0.5 - qx).powi(2) + (y as f64 + 0.5 - qy).powi(2)).sqrt();
let half = ((st + (et - st) * tc) * 0.5).max(0.25);
let tk = if persp || t1 - t0 < 1e-9 { tc } else { (tc - t0) / (t1 - t0) };
let half = ((st + (et - st) * tk) * 0.5).max(0.25);
let tt = (dist / half) as f32;
let a = if len <= 0.0 {
0.0
@@ -270,24 +317,62 @@ fn beam(ctx: &EffectCtx, mut b: Buf) -> Buf {
// ---------------------------------------------------------------- Radio Waves
/// Distance from `p` (relative to the wave centre) to a closed outline `pts`, measured along
/// the ray from the centre and corrected to the edge normal.
fn outline_dist(pts: &[(f64, f64)], dx: f64, dy: f64) -> f64 {
let r = (dx * dx + dy * dy).sqrt();
if r < 1e-9 {
return pts.iter().map(|p| (p.0 * p.0 + p.1 * p.1).sqrt()).fold(f64::INFINITY, f64::min);
}
let dir = (dx / r, dy / r);
let n = pts.len();
let mut best = f64::INFINITY;
for k in 0..n {
let p0 = pts[k];
let p1 = pts[(k + 1) % n];
let e = (p1.0 - p0.0, p1.1 - p0.1);
let den = dir.0 * e.1 - dir.1 * e.0;
if den.abs() < 1e-12 {
continue;
}
let t = (p0.0 * e.1 - p0.1 * e.0) / den;
// The ray must cross this edge between its endpoints.
let q = (dir.0 * t - p0.0, dir.1 * t - p0.1);
let el2 = (e.0 * e.0 + e.1 * e.1).max(1e-12);
let s = (q.0 * e.0 + q.1 * e.1) / el2;
if t <= 0.0 || !(-1e-9..=1.0 + 1e-9).contains(&s) {
continue;
}
let d = (r - t).abs() * den.abs() / el2.sqrt();
best = best.min(d);
}
best
}
fn radio_waves(ctx: &EffectCtx, mut b: Buf) -> Buf {
let c = b.to_px(ctx.params.v2("producerPoint"));
let sides = ctx.params.f("sides").round().clamp(3.0, 64.0);
let freq = ctx.params.f("frequency").max(0.01);
let vel = ctx.params.f("velocity") * b.scale;
let spin = ctx.params.f("spin").to_radians();
let life = ctx.params.f("lifespan").max(0.01);
let color = ctx.params.color("color");
let op = (ctx.params.f("opacity") / 100.0) as f32;
let fin = ctx.params.f("fadeInTime").max(0.0);
let fout = ctx.params.f("fadeOutTime").max(0.0);
let sw = ctx.params.f("startWidth") * b.scale;
let ew = ctx.params.f("endWidth") * b.scale;
let sides = ctx.params.f("polygon/sides").round().clamp(3.0, 64.0);
let star = ctx.params.b("polygon/star");
let depth = ctx.params.f("polygon/starDepth").clamp(-1.0, 1.0);
let freq = ctx.params.f("waveMotion/frequency").max(0.01);
let expansion = ctx.params.f("waveMotion/expansion") * b.scale;
let orient = ctx.params.f("waveMotion/orientation").to_radians();
// Direction: 0° = up, clockwise.
let dirn = ctx.params.f("waveMotion/direction").to_radians();
let vel = ctx.params.f("waveMotion/velocity") * b.scale;
let spin = ctx.params.f("waveMotion/spin").to_radians();
let life = ctx.params.f("waveMotion/lifespan").max(0.01);
let color = ctx.params.color("waveStroke/color");
let op = (ctx.params.f("waveStroke/opacity") / 100.0) as f32;
let fin = ctx.params.f("waveStroke/fadeInTime").max(0.0);
let fout = ctx.params.f("waveStroke/fadeOutTime").max(0.0);
let sw = ctx.params.f("waveStroke/startWidth") * b.scale;
let ew = ctx.params.f("waveStroke/endWidth") * b.scale;
let t = ctx.time.max(0.0);
let k_hi = (t * freq).floor() as i64;
let k_lo = (((t - life) * freq).floor() as i64).max(0).max(k_hi - 256);
// (radius, half width, rotation, fade) per live wave.
let waves: Vec<(f64, f64, f64, f32)> = (k_lo..=k_hi)
// (centre, radius, half width, rotation, fade) per live wave.
let waves: Vec<((f64, f64), f64, f64, f64, f32)> = (k_lo..=k_hi)
.filter_map(|k| {
let age = t - k as f64 / freq;
if !(0.0..life).contains(&age) {
@@ -295,19 +380,25 @@ fn radio_waves(ctx: &EffectCtx, mut b: Buf) -> Buf {
}
let fi = if fin > 0.0 { (age / fin).min(1.0) } else { 1.0 };
let fo = if fout > 0.0 { ((life - age) / fout).min(1.0) } else { 1.0 };
Some((vel * age, ((sw + (ew - sw) * age / life) * 0.5).max(0.25), spin * age, (fi * fo) as f32))
let centre = (c.0 + dirn.sin() * vel * age, c.1 - dirn.cos() * vel * age);
Some((centre, expansion * age, ((sw + (ew - sw) * age / life) * 0.5).max(0.25), orient + spin * age, (fi * fo) as f32))
})
.collect();
let seg = 2.0 * PI / sides;
let circle = sides >= 64.0;
let circle = sides >= 64.0 && !star;
// Unit outline (radius 1) of the polygon or star, rotated per wave below.
let n = sides as usize;
let unit: Vec<(f64, f64)> = if star {
(0..2 * n).map(|i| (PI * i as f64 / n as f64 - PI / 2.0, if i % 2 == 0 { 1.0 } else { (1.0 + depth).max(0.0) })).collect()
} else {
(0..n).map(|i| (2.0 * PI * i as f64 / n as f64 - PI / 2.0, 1.0)).collect()
};
let outlines: Vec<Vec<(f64, f64)>> =
waves.iter().map(|&(_, rad, _, rot, _)| unit.iter().map(|&(a, k)| ((a + rot).cos() * rad * k, (a + rot).sin() * rad * k)).collect()).collect();
map_xy(&mut b.img, |x, y, px| {
let (dx, dy) = (x as f64 + 0.5 - c.0, y as f64 + 0.5 - c.1);
let r = (dx * dx + dy * dy).sqrt();
let th = dy.atan2(dx);
let mut a = 0.0f32;
for &(rad, hw, rot, fade) in &waves {
let rb = if circle { rad } else { rad * (PI / sides).cos() / (((th - rot).rem_euclid(seg)) - seg * 0.5).cos() };
let d = (r - rb).abs();
for (wi, &(cc, rad, hw, _, fade)) in waves.iter().enumerate() {
let (dx, dy) = (x as f64 + 0.5 - cc.0, y as f64 + 0.5 - cc.1);
let d = if circle { ((dx * dx + dy * dy).sqrt() - rad).abs() } else { outline_dist(&outlines[wi], dx, dy) };
a = a.max((hw - d + 0.5).clamp(0.0, 1.0) as f32 * fade);
}
let a = a * op * color[3];
@@ -320,6 +411,9 @@ fn radio_waves(ctx: &EffectCtx, mut b: Buf) -> Buf {
type Seg = ((f64, f64), (f64, f64), f32);
/// Advanced Lightning's Lightning Type options.
const LIGHTNING_TYPES: [&str; 8] = ["Direction", "Strike", "Breaking", "Bouncy", "Omni", "Anywhere", "Vertical", "Two-Way Strike"];
fn bolt(a: (f64, f64), z: (f64, f64), depth: u32, inten: f32, turb: f64, fork: f64, decay: f32, rng: &mut Rng, out: &mut Vec<Seg>) {
if out.len() > 20_000 {
return;
@@ -346,42 +440,70 @@ fn bolt(a: (f64, f64), z: (f64, f64), depth: u32, inten: f32, turb: f64, fork: f
fn lightning_segments(ctx: &EffectCtx, b: &Buf) -> Vec<Seg> {
let kind = ctx.params.e("lightningType");
let decay_main = ctx.params.b("decayMainCore");
let o = b.to_px(ctx.params.v2("origin"));
let d = b.to_px(ctx.params.v2("direction"));
let turb = ctx.params.f("turbulence").max(0.0);
let fork = (ctx.params.f("forking") / 100.0).clamp(0.0, 1.0);
let decay = ctx.params.f("decay").clamp(0.0, 1.0) as f32;
let depth = ctx.params.f("complexity").round().clamp(1.0, 12.0) as u32;
let depth = ctx.params.f("expertSettings/complexity").round().clamp(1.0, 12.0) as u32;
let state = ctx.params.f("conductivityState").floor() as i64 as u64;
let mut rng = Rng::new(state ^ ((ctx.seed as u64) << 32));
let mut segs = Vec::new();
let (h, w) = (b.img.height as f64, b.img.width as f64);
// LIGHTNING_TYPES order.
match kind {
1 => {
// Direction: travels toward the Direction point and beyond.
0 => {
let z = (o.0 + (d.0 - o.0) * 3.0, o.1 + (d.1 - o.1) * 3.0);
bolt(o, z, depth, 1.0, turb, fork, decay, &mut rng, &mut segs);
}
// Breaking: more branching as the points move apart.
2 => {
let dist = ((d.0 - o.0).powi(2) + (d.1 - o.1).powi(2)).sqrt();
let f = (fork * (0.5 + dist / w.max(h).max(1.0))).min(1.0);
bolt(o, d, depth, 1.0, turb, f, decay, &mut rng, &mut segs);
}
// Bouncy: a strike with a stronger zig-zag.
3 => bolt(o, d, depth, 1.0, turb * 1.6, fork, decay, &mut rng, &mut segs),
// Omni / Anywhere: bolts in all directions out to the Outer Radius.
4 | 5 => {
let len = ((d.0 - o.0).powi(2) + (d.1 - o.1).powi(2)).sqrt().max(w.min(h) * 0.25);
for _ in 0..4 {
let a = rng.f() * 2.0 * PI;
let z = (o.0 + a.cos() * len, o.1 + a.sin() * len);
let l = if kind == 5 { len * (0.3 + 0.7 * rng.f()) } else { len };
let z = (o.0 + a.cos() * l, o.1 + a.sin() * l);
bolt(o, z, depth, 1.0, turb, fork, decay, &mut rng, &mut segs);
}
}
3 => bolt(o, (o.0, h), depth, 1.0, turb, fork, decay, &mut rng, &mut segs),
6 => bolt(o, (o.0, h), depth, 1.0, turb, fork, decay, &mut rng, &mut segs),
// Two-Way Strike: from both ends toward the middle.
7 => {
let m = ((o.0 + d.0) * 0.5, (o.1 + d.1) * 0.5);
bolt(o, m, depth.saturating_sub(1).max(1), 1.0, turb, fork, decay, &mut rng, &mut segs);
bolt(d, m, depth.saturating_sub(1).max(1), 1.0, turb, fork, decay, &mut rng, &mut segs);
}
// Strike.
_ => bolt(o, d, depth, 1.0, turb, fork, decay, &mut rng, &mut segs),
}
// Decay Main Core: the whole bolt fades with distance from the origin.
if decay_main {
let far = segs.iter().map(|(_, z, _)| ((z.0 - o.0).powi(2) + (z.1 - o.1).powi(2)).sqrt()).fold(1e-9, f64::max);
for (a, _, i) in &mut segs {
let t = (((a.0 - o.0).powi(2) + (a.1 - o.1).powi(2)).sqrt() / far) as f32;
*i *= (1.0 - decay * t).max(0.0);
}
}
segs
}
fn advanced_lightning(ctx: &EffectCtx, mut b: Buf) -> Buf {
let core_r = (ctx.params.f("coreRadius") * b.scale).max(0.3);
let core_op = (ctx.params.f("coreOpacity") / 100.0) as f32;
let core_c = ctx.params.color("coreColor");
let glow_r = ctx.params.f("glowRadius") * b.scale;
let glow_op = (ctx.params.f("glowOpacity") / 100.0) as f32;
let glow_c = ctx.params.color("glowColor");
let core_r = (ctx.params.f("coreSettings/coreRadius") * b.scale).max(0.3);
let core_op = (ctx.params.f("coreSettings/coreOpacity") / 100.0) as f32;
let core_c = ctx.params.color("coreSettings/coreColor");
let glow_r = ctx.params.f("glowSettings/glowRadius") * b.scale;
let glow_op = (ctx.params.f("glowSettings/glowOpacity") / 100.0) as f32;
let glow_c = ctx.params.color("glowSettings/glowColor");
let composite = ctx.params.b("compositeOnOriginal");
let segs = lightning_segments(ctx, &b);
let (w, h) = (b.img.width as usize, b.img.height as usize);
@@ -588,20 +710,20 @@ pub fn specs() -> Vec<EffectSpec> {
"ec.generate.cellpattern",
"Cell Pattern",
vec![
p(
"cellPattern",
"Cell Pattern",
Value::Enum(0),
popup(&["Bubbles", "Crystals", "Plates", "Static Plates", "Crystallize", "Pillow", "Mixed Crystals", "Dots", "Tubular"]),
),
p("cellPattern", "Cell Pattern", Value::Enum(0), popup(&CELL_PATTERNS)),
p("invert", "Invert", Value::Bool(false), ParamUi::Checkbox),
p("contrast", "Contrast", num(100.0), slider(0.0, 10000.0, 0.0, 400.0, 1)),
p("overflow", "Overflow", Value::Enum(0), popup(&["Clip", "Soft Clamp", "Wrap Back"])),
p("disperse", "Disperse", num(1.0), slider(0.0, 1.5, 0.0, 1.5, 2)),
p("size", "Size", num(60.0), slider(2.0, 4000.0, 2.0, 400.0, 1)),
p("offset", "Offset", pt(0.5, 0.5), ParamUi::Point),
p("tilingOptions/enableTiling", "Enable Tiling", Value::Bool(false), ParamUi::Checkbox),
p("tilingOptions/cellsHorizontal", "Cells Horizontal", num(16.0), slider(1.0, 1000.0, 1.0, 100.0, 0)),
p("tilingOptions/cellsVertical", "Cells Vertical", num(16.0), slider(1.0, 1000.0, 1.0, 100.0, 0)),
p("evolution", "Evolution", num(0.0), ang()),
p("randomSeed", "Random Seed", num(0.0), slider(0.0, 100000.0, 0.0, 1000.0, 0)),
p("evolutionOptions/cycleEvolution", "Cycle Evolution", Value::Bool(false), ParamUi::Checkbox),
p("evolutionOptions/cycle", "Cycle (in Revolutions)", num(1.0), slider(1.0, 1000.0, 1.0, 20.0, 0)),
p("evolutionOptions/randomSeed", "Random Seed", num(0.0), slider(0.0, 100000.0, 0.0, 1000.0, 0)),
],
cell_pattern,
),
@@ -644,6 +766,7 @@ pub fn specs() -> Vec<EffectSpec> {
p("softness", "Softness", num(20.0), pct()),
p("insideColor", "Inside Color", col(1.0, 1.0, 1.0), ParamUi::Color),
p("outsideColor", "Outside Color", col(0.4, 0.4, 1.0), ParamUi::Color),
p("perspective3d", "3D Perspective", Value::Bool(true), ParamUi::Checkbox),
p("compositeOnOriginal", "Composite On Original", Value::Bool(true), ParamUi::Checkbox),
],
beam,
@@ -653,17 +776,22 @@ pub fn specs() -> Vec<EffectSpec> {
"Radio Waves",
vec![
p("producerPoint", "Producer Point", pt(0.5, 0.5), ParamUi::Point),
p("sides", "Sides", num(64.0), slider(3.0, 64.0, 3.0, 64.0, 0)),
p("frequency", "Frequency", num(1.0), slider(0.01, 100.0, 0.01, 10.0, 2)),
p("velocity", "Velocity", num(100.0), slider(0.0, 10000.0, 0.0, 1000.0, 1)),
p("spin", "Spin", num(0.0), slider(-3600.0, 3600.0, -360.0, 360.0, 1)),
p("lifespan", "Lifespan (sec)", num(2.0), slider(0.01, 100.0, 0.01, 10.0, 2)),
p("color", "Color", col(1.0, 1.0, 1.0), ParamUi::Color),
p("opacity", "Opacity", num(100.0), pct()),
p("fadeInTime", "Fade-in Time", num(0.0), slider(0.0, 100.0, 0.0, 5.0, 2)),
p("fadeOutTime", "Fade-out Time", num(0.0), slider(0.0, 100.0, 0.0, 5.0, 2)),
p("startWidth", "Start Width", num(5.0), slider(0.0, 1000.0, 0.0, 100.0, 1)),
p("endWidth", "End Width", num(5.0), slider(0.0, 1000.0, 0.0, 100.0, 1)),
p("polygon/sides", "Sides", num(64.0), slider(3.0, 64.0, 3.0, 64.0, 0)),
p("polygon/star", "Star", Value::Bool(false), ParamUi::Checkbox),
p("polygon/starDepth", "Star Depth", num(-0.3), slider(-1.0, 1.0, -1.0, 1.0, 2)),
p("waveMotion/frequency", "Frequency", num(1.0), slider(0.01, 100.0, 0.01, 10.0, 2)),
p("waveMotion/expansion", "Expansion", num(100.0), slider(0.0, 10000.0, 0.0, 1000.0, 1)),
p("waveMotion/orientation", "Orientation", num(0.0), ang()),
p("waveMotion/direction", "Direction", num(90.0), ang()),
p("waveMotion/velocity", "Velocity", num(0.0), slider(0.0, 10000.0, 0.0, 1000.0, 1)),
p("waveMotion/spin", "Spin", num(0.0), slider(-3600.0, 3600.0, -360.0, 360.0, 1)),
p("waveMotion/lifespan", "Lifespan (sec)", num(2.0), slider(0.01, 100.0, 0.01, 10.0, 2)),
p("waveStroke/color", "Color", col(1.0, 1.0, 1.0), ParamUi::Color),
p("waveStroke/opacity", "Opacity", num(100.0), pct()),
p("waveStroke/fadeInTime", "Fade-in Time", num(0.0), slider(0.0, 100.0, 0.0, 5.0, 2)),
p("waveStroke/fadeOutTime", "Fade-out Time", num(0.0), slider(0.0, 100.0, 0.0, 5.0, 2)),
p("waveStroke/startWidth", "Start Width", num(5.0), slider(0.0, 1000.0, 0.0, 100.0, 1)),
p("waveStroke/endWidth", "End Width", num(5.0), slider(0.0, 1000.0, 0.0, 100.0, 1)),
],
radio_waves,
),
@@ -671,21 +799,22 @@ pub fn specs() -> Vec<EffectSpec> {
"ec.generate.advancedlightning",
"Advanced Lightning",
vec![
p("lightningType", "Lightning Type", Value::Enum(0), popup(&["Strike", "Direction", "Omni", "Vertical"])),
p("lightningType", "Lightning Type", Value::Enum(1), popup(&LIGHTNING_TYPES)),
p("origin", "Origin", pt(0.25, 0.2), ParamUi::Point),
p("direction", "Direction", pt(0.75, 0.8), ParamUi::Point),
p("conductivityState", "Conductivity State", num(10.0), slider(0.0, 100000.0, 0.0, 100.0, 1)),
p("coreRadius", "Core Radius", num(3.0), slider(0.0, 100.0, 0.0, 20.0, 1)),
p("coreOpacity", "Core Opacity", num(75.0), pct()),
p("coreColor", "Core Color", col(1.0, 1.0, 1.0), ParamUi::Color),
p("glowRadius", "Glow Radius", num(50.0), slider(0.0, 1000.0, 0.0, 200.0, 1)),
p("glowOpacity", "Glow Opacity", num(50.0), pct()),
p("glowColor", "Glow Color", col(0.25, 0.35, 1.0), ParamUi::Color),
p("coreSettings/coreRadius", "Core Radius", num(3.0), slider(0.0, 100.0, 0.0, 20.0, 1)),
p("coreSettings/coreOpacity", "Core Opacity", num(75.0), pct()),
p("coreSettings/coreColor", "Core Color", col(1.0, 1.0, 1.0), ParamUi::Color),
p("glowSettings/glowRadius", "Glow Radius", num(50.0), slider(0.0, 1000.0, 0.0, 200.0, 1)),
p("glowSettings/glowOpacity", "Glow Opacity", num(50.0), pct()),
p("glowSettings/glowColor", "Glow Color", col(0.25, 0.35, 1.0), ParamUi::Color),
p("turbulence", "Turbulence", num(1.0), slider(0.0, 10.0, 0.0, 4.0, 2)),
p("forking", "Forking", num(25.0), pct()),
p("decay", "Decay", num(0.3), slider(0.0, 1.0, 0.0, 1.0, 2)),
p("complexity", "Complexity", num(6.0), slider(1.0, 12.0, 1.0, 12.0, 0)),
p("compositeOnOriginal", "Composite on Original", Value::Bool(true), ParamUi::Checkbox),
p("decayMainCore", "Decay Main Core", Value::Bool(false), ParamUi::Checkbox),
p("compositeOnOriginal", "Composite On Original", Value::Bool(true), ParamUi::Checkbox),
p("expertSettings/complexity", "Complexity", num(6.0), slider(1.0, 12.0, 1.0, 12.0, 0)),
],
advanced_lightning,
),
@@ -763,7 +892,7 @@ mod tests {
let a = run("ec.generate.cellpattern", &[("size", num(10.0))], Image::new(40, 30));
let b2 = run("ec.generate.cellpattern", &[("size", num(10.0))], Image::new(40, 30));
assert_eq!(a.img, b2.img);
let c = run("ec.generate.cellpattern", &[("size", num(10.0)), ("randomSeed", num(5.0))], Image::new(40, 30));
let c = run("ec.generate.cellpattern", &[("size", num(10.0)), ("evolutionOptions/randomSeed", num(5.0))], Image::new(40, 30));
assert_ne!(a.img, c.img);
assert!(a.img.data.iter().all(|p| p[3] == 1.0 && (0.0..=1.0).contains(&p[0])));
}
@@ -795,6 +924,89 @@ mod tests {
assert!(o.img.get(2, 16)[3] < 1e-3);
}
#[test]
fn cell_pattern_tiles() {
// 4×4-cell tiles of 8 px: the pattern repeats every 32 px.
let set = [
("size", num(8.0)),
("tilingOptions/enableTiling", Value::Bool(true)),
("tilingOptions/cellsHorizontal", num(4.0)),
("tilingOptions/cellsVertical", num(4.0)),
];
let o = run("ec.generate.cellpattern", &set, Image::new(64, 64));
for (x, y) in [(3, 5), (10, 20), (17, 2)] {
let (a, b2) = (o.img.get(x, y), o.img.get(x + 32, y + 32));
assert!((a[0] - b2[0]).abs() < 1e-4, "{x},{y}: {a:?} vs {b2:?}");
}
}
#[test]
fn radio_waves_expansion_velocity_and_star() {
let r = |set: &[(&str, Value)], t: f64| {
let s = crate::find("ec.generate.radiowaves").unwrap();
let mut params = Params { values: s.params.iter().map(|p| (p.id.to_string(), p.default.clone())).collect() };
params.values.insert("producerPoint".into(), Value::Vec2([32.0, 32.0]));
for (k, v) in set {
params.values.insert(k.to_string(), v.clone());
}
let ctx = EffectCtx { params: &params, time: t, layer_size: [64.0, 64.0], seed: 3, adjustment: false, env: Default::default() };
crate::apply(s, &ctx, Buf { img: Image::new(64, 64), offset: [0.0, 0.0], scale: 1.0 })
};
// One wave born at t = 0, 0.2 s old: radius = Expansion × age = 20 px.
let base = [("waveMotion/expansion", num(100.0)), ("waveMotion/frequency", num(0.5))];
let o = r(&base, 0.2);
assert!(o.img.get(52, 32)[3] > 0.9, "{:?}", o.img.get(52, 32));
assert!(o.img.get(32, 32)[3] < 0.01);
// Velocity moves the wave toward Direction (90° = right).
let mut moving = base.to_vec();
moving.push(("waveMotion/velocity", num(50.0)));
let o = r(&moving, 0.2);
assert!(o.img.get(62, 32)[3] > 0.9 && o.img.get(52, 32)[3] < 0.5, "{:?}", o.img.get(62, 32));
// A 4-point star: the outline dips toward the centre between the points.
let mut star = base.to_vec();
star.extend([("polygon/sides", num(4.0)), ("polygon/star", Value::Bool(true)), ("polygon/starDepth", num(-0.5))]);
let o = r(&star, 0.2);
assert!(o.img.get(32, 12)[3] > 0.9, "point straight up");
// Between points (45°) the outline sits near half the radius.
assert!(o.img.get(39, 24)[3] > 0.5, "{:?}", o.img.get(39, 24));
assert!(o.img.get(46, 18)[3] < 0.01, "no circle there");
}
#[test]
fn lightning_types_and_decay_main_core() {
let a = run("ec.generate.advancedlightning", &[], Image::new(64, 48));
let strike = run("ec.generate.advancedlightning", &[("lightningType", Value::Enum(1))], Image::new(64, 48));
assert_eq!(a.img, strike.img, "Strike is the default");
for t in 0..8 {
let o = run("ec.generate.advancedlightning", &[("lightningType", Value::Enum(t))], Image::new(64, 48));
assert!(o.img.data.iter().any(|p| p[3] > 0.3), "type {t} draws");
}
let sum = |i: &Image| i.data.iter().map(|p| p[3]).sum::<f32>();
let d = run("ec.generate.advancedlightning", &[("decayMainCore", Value::Bool(true)), ("decay", num(0.9))], Image::new(64, 48));
let n = run("ec.generate.advancedlightning", &[("decay", num(0.9))], Image::new(64, 48));
assert!(sum(&d.img) < sum(&n.img));
}
#[test]
fn beam_3d_perspective_controls_thickness() {
// Short beam near the start: with 3D Perspective its thickness comes from its position
// (thin, near the start); without, its head takes the full ending thickness.
let set = |p: bool| {
vec![
("length", num(20.0)),
("time", num(0.0)),
("softness", num(0.0)),
("startThickness", num(2.0)),
("endThickness", num(20.0)),
("perspective3d", Value::Bool(p)),
]
};
let on = run("ec.generate.beam", &set(true), Image::new(64, 32));
let off = run("ec.generate.beam", &set(false), Image::new(64, 32));
let sum = |i: &Image| i.data.iter().map(|p| p[3]).sum::<f32>();
assert!(sum(&off.img) > sum(&on.img) * 1.5, "{} {}", sum(&off.img), sum(&on.img));
}
#[test]
fn lens_flare_brightest_at_center() {
let o = run("ec.generate.lensflare", &[], Image::new(64, 64));