mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-19 16:45:28 +00:00
Merge pull request #3215 from vangel76/cc-ball-action-params-3197
Ball Grid effect has all of After Effects' CC Ball Action controls, including flat balls without shading
This commit is contained in:
14 files changed
+489
-40
No files matched your search
@@ -147,7 +147,7 @@ pub fn effects_markdown() -> String {
|
||||
- **Status**: {} implemented in full, {partial} partial (what is missing is listed).\n\n",
|
||||
r.len() - partial
|
||||
));
|
||||
s.push_str("Effects are addressed by id (`ec.<category>.<name>`) or display name in commands, scripts and the control channel, and every parameter by its id (`effects/#1/blurriness`).\n\n");
|
||||
s.push_str("Effects are addressed by id (`ec.<category>.<name>`) or display name in commands, scripts and the control channel, and every parameter by its id (`effects/#1/blurriness`). A parameter that was renamed keeps its old name working in expressions of older projects: `effect(\"CC Ball Action\")(\"Instability State\")` still reads Scatter Motion.\n\n");
|
||||
for cat in CATEGORIES {
|
||||
let list: Vec<_> = r.iter().filter(|e| e.category == *cat).collect();
|
||||
if list.is_empty() {
|
||||
|
||||
@@ -44,6 +44,9 @@ pub const PARAM_ID_ALIASES: &[(&str, &str, &str)] = &[
|
||||
("ec.key.innerouter", "additionalBackground", "additionalBackground/background1"),
|
||||
// Generate: Radio Waves' growth speed was called Velocity; Velocity now moves the wave.
|
||||
("ec.generate.radiowaves", "velocity", "waveMotion/expansion"),
|
||||
// Simulation: CC Ball Action's Instability State is treated as the control After Effects
|
||||
// 24.2 calls Scatter Motion (#3197; an assumption: 24.2 shows no Instability State).
|
||||
("ec.sim.ccballaction", "instabilityState", "scatterMotion"),
|
||||
];
|
||||
|
||||
/// Popup option labels renamed since they were first saved:
|
||||
@@ -192,6 +195,14 @@ fn take_at(g: &mut PropGroup, id: &str) -> Option<Property> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The position of the property at spec id `id` (`a/b/param`) among its siblings.
|
||||
fn index_at(g: &PropGroup, id: &str) -> Option<usize> {
|
||||
match id.split_once('/') {
|
||||
None => g.children.iter().position(|c| matches!(c, Node::Prop(p) if p.match_id == id)),
|
||||
Some((first, rest)) => index_at(g.sub(first)?, rest),
|
||||
}
|
||||
}
|
||||
|
||||
fn prop_at<'a>(g: &'a mut PropGroup, id: &str) -> Option<&'a mut Property> {
|
||||
match id.split_once('/') {
|
||||
None => g.get_mut(id),
|
||||
@@ -279,6 +290,12 @@ pub fn upgrade_instance(spec: &EffectSpec, g: &mut PropGroup, ids: &mut Ids, lay
|
||||
// before it moved into a twirl-down group.
|
||||
let found = prop_at(g, ps.id).is_some();
|
||||
if !found {
|
||||
// A parameter renamed within its group keeps its place, so expressions that address
|
||||
// it by index still read it.
|
||||
let slot = PARAM_ID_ALIASES
|
||||
.iter()
|
||||
.filter(|(e, old, new)| *e == spec.id && *new == ps.id && old.rsplit_once('/').map(|(p, _)| p) == new.rsplit_once('/').map(|(p, _)| p))
|
||||
.find_map(|(_, old, _)| index_at(g, old));
|
||||
let moved = PARAM_ID_ALIASES.iter().filter(|(e, _, new)| *e == spec.id && *new == ps.id).find_map(|(_, old, _)| take_at(g, old)).or_else(|| {
|
||||
let leaf = ps.id.rsplit('/').next().unwrap_or(ps.id);
|
||||
// Not when the top-level leaf is an old id of another parameter (Radio
|
||||
@@ -300,9 +317,13 @@ pub fn upgrade_instance(spec: &EffectSpec, g: &mut PropGroup, ids: &mut Ids, lay
|
||||
pr
|
||||
}
|
||||
};
|
||||
let at = |sub: &mut PropGroup| match slot {
|
||||
Some(i) if i <= sub.children.len() => sub.children.insert(i, pr.into()),
|
||||
_ => sub.children.push(pr.into()),
|
||||
};
|
||||
match path.and_then(|path| group_at(g, ids, path)) {
|
||||
Some(sub) => sub.children.push(pr.into()),
|
||||
None => g.children.push(pr.into()),
|
||||
Some(sub) => at(sub),
|
||||
None => at(g),
|
||||
}
|
||||
}
|
||||
if let Some(pr) = prop_at(g, ps.id) {
|
||||
@@ -584,6 +605,27 @@ mod tests {
|
||||
assert_eq!((&pr.ui, &pr.value), (&ParamUi::Point, &Value::Vec2([20.0, -5.0])));
|
||||
}
|
||||
|
||||
/// #3197 review: an old CC Ball Action saved Instability State as its 8th property; renamed to
|
||||
/// Scatter Motion it keeps that place, so an expression that reads `effect(..)(8)` still gets
|
||||
/// the same control (new controls are appended after it).
|
||||
#[test]
|
||||
fn upgrade_renames_a_param_in_place_and_keeps_its_index() {
|
||||
let spec = find("ec.sim.ccballaction").unwrap();
|
||||
let mut next = 1;
|
||||
let mut g = instantiate(spec, &mut Ids(&mut next), "Ball Grid", [100.0, 50.0]);
|
||||
// The layout an earlier version saved: eight parameters, Instability State last.
|
||||
let old = ["scatter", "rotationAxis", "rotation", "twistProperty", "twistAngle", "gridSpacing", "ballSize", "scatterMotion"];
|
||||
let mut kept: Vec<Property> = old.iter().map(|id| take_prop(&mut g, id).unwrap()).collect();
|
||||
g.children.clear();
|
||||
kept[7].match_id = "instabilityState".into();
|
||||
kept[7].value = Value::Scalar(33.0);
|
||||
g.children.extend(kept.into_iter().map(Node::from));
|
||||
assert!(upgrade_instance(spec, &mut g, &mut Ids(&mut next), [100.0, 50.0]));
|
||||
let ids: Vec<&str> = g.children.iter().take(8).map(|c| c.match_id()).collect();
|
||||
assert_eq!(ids, ["scatter", "rotationAxis", "rotation", "twistProperty", "twistAngle", "gridSpacing", "ballSize", "scatterMotion"]);
|
||||
assert_eq!(g.get("scatterMotion").unwrap().value, Value::Scalar(33.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn upgrade_moves_params_into_twirl_down_groups() {
|
||||
let spec = find(crate::warp_stab::ID).unwrap();
|
||||
|
||||
@@ -93,6 +93,10 @@ pub enum Shape {
|
||||
Disc,
|
||||
/// Lit sphere (upper-left light, specular).
|
||||
Sphere,
|
||||
/// CC Ball Action's ball: [`Shape::Sphere`]'s light and shine scaled by `|shade|` (1 is the
|
||||
/// sphere's look, 0 a flat disc; callers keep it finite, the GPU draws the same); a negative
|
||||
/// `shade` mirrors the light's direction (lit from the lower right).
|
||||
Ball { shade: f32 },
|
||||
/// Disc fading linearly to its rim.
|
||||
Faded,
|
||||
/// Thin ring with a highlight.
|
||||
@@ -277,6 +281,24 @@ fn sprite_shade(s: &Sprite, x: f32, y: f32) -> Option<Px> {
|
||||
rgb = [rgb[0] * k + spec, rgb[1] * k + spec, rgb[2] * k + spec];
|
||||
cv
|
||||
}
|
||||
Shape::Ball { shade } => {
|
||||
let d = (dx * dx + dy * dy).sqrt();
|
||||
let cv = aa(r - d);
|
||||
if cv <= 0.0 {
|
||||
return None;
|
||||
}
|
||||
let (nx, ny) = (dx / r, dy / r);
|
||||
let nz = (1.0 - nx * nx - ny * ny).max(0.0).sqrt();
|
||||
let m = if shade < 0.0 { -1.0 } else { 1.0 };
|
||||
let (lx, ly, lz) = (-0.48 * m, -0.58 * m, 0.66);
|
||||
let diff = (nx * lx + ny * ly + nz * lz).max(0.0);
|
||||
let rz = 2.0 * diff * nz - lz;
|
||||
let st = shade.abs();
|
||||
let spec = rz.max(0.0).powi(20) * 0.6 * st;
|
||||
let k = (1.0 - st * 0.8 * (1.0 - diff)).max(0.0);
|
||||
rgb = [rgb[0] * k + spec, rgb[1] * k + spec, rgb[2] * k + spec];
|
||||
cv
|
||||
}
|
||||
Shape::Bubble => {
|
||||
let d = (dx * dx + dy * dy).sqrt() / r;
|
||||
if d > 1.0 + 1.0 / r {
|
||||
|
||||
@@ -4,10 +4,91 @@ use super::{Acc, Buf, EffectCtx, IntoParallelIterator, ParallelIterator, Post, S
|
||||
|
||||
// ------------------------------------------------------------------ CC Ball Action
|
||||
|
||||
/// CC Ball Action's Coloring: how a ball takes its colour from the layer under its grid cell.
|
||||
/// An approximation: After Effects' own meaning is not published beyond "how smooth the
|
||||
/// balls look". Crisp takes the nearest pixel, Medium keeps EffectCraft's earlier smooth
|
||||
/// sample at the cell centre (for compatibility), Smooth averages 16 samples over the cell.
|
||||
pub(super) const BALL_COLORING: &[&str] = &["Crisp", "Medium", "Smooth"];
|
||||
pub(super) const BALL_COLORING_MEDIUM: u32 = 1;
|
||||
/// CC Ball Action's default Shading: the lit sphere (`Shape::Sphere`); 0 draws flat discs.
|
||||
pub(super) const BALL_SHADING_DEFAULT: f64 = -75.0;
|
||||
/// CC Ball Action's Displace Property: what pushes a ball towards (high values) or away from
|
||||
/// (low values) the camera. The option names come from public descriptions; what Radius,
|
||||
/// Diamond and Spherize compute here is an assumption pending a comparison with After Effects.
|
||||
pub(super) const BALL_DISPLACE_PROPERTIES: &[&str] = &["Red", "Green", "Blue", "Brightness", "Saturation", "RGB", "Radius", "Diamond", "Spherize"];
|
||||
pub(super) const BALL_DISPLACE_BRIGHTNESS: u32 = 3;
|
||||
|
||||
pub(super) fn ball_action(ctx: &EffectCtx, b: Buf) -> Buf {
|
||||
ball_action_plan(ctx, &b).finish(b)
|
||||
}
|
||||
|
||||
/// A parameter's number, or `default` when the instance does not carry it.
|
||||
fn f_or(ctx: &EffectCtx, id: &str, default: f64) -> f64 {
|
||||
ctx.params.values.get(id).map(|v| v.as_f64()).unwrap_or(default)
|
||||
}
|
||||
|
||||
/// The layer's straight colour and alpha for the ball of the grid cell centred on (`sx`, `sy`)
|
||||
/// (buffer pixels, cell `cell` buffer pixels wide), by Coloring `coloring`.
|
||||
fn ball_color(src: &effectcraft_raster::Image, sx: f64, sy: f64, cell: f64, coloring: u32) -> ([f32; 3], f32) {
|
||||
match coloring {
|
||||
// Crisp: the pixel under the cell centre.
|
||||
0 => unpremul(src.get(sx.floor() as i64, sy.floor() as i64)),
|
||||
// Smooth: the cell's average (4 × 4 samples, premultiplied).
|
||||
2 => {
|
||||
const N: u32 = 4;
|
||||
let mut acc = [0.0f32; 4];
|
||||
for j in 0..N {
|
||||
for i in 0..N {
|
||||
let ox = (f64::from(i) + 0.5) / f64::from(N) - 0.5;
|
||||
let oy = (f64::from(j) + 0.5) / f64::from(N) - 0.5;
|
||||
let p = src.sample_bilinear(sx + ox * cell, sy + oy * cell);
|
||||
for (a, v) in acc.iter_mut().zip(p) {
|
||||
*a += v;
|
||||
}
|
||||
}
|
||||
}
|
||||
let n = (N * N) as f32;
|
||||
unpremul([acc[0] / n, acc[1] / n, acc[2] / n, acc[3] / n])
|
||||
}
|
||||
// Medium: a smooth sample at the cell centre.
|
||||
_ => unpremul(src.sample_bilinear(sx, sy)),
|
||||
}
|
||||
}
|
||||
|
||||
/// CC Ball Action's Displace Property `prop` (0..1) for a ball of straight colour `c` at
|
||||
/// (`gx`, `gy`) on a `lw` × `lh` layer (`maxr`: half its diagonal). Assumed meanings (not
|
||||
/// compared with After Effects yet): Radius, Diamond and Spherize are shapes that peak at the
|
||||
/// layer centre.
|
||||
fn ball_displace_value(prop: u32, c: [f32; 3], gx: f32, gy: f32, lw: f32, lh: f32, maxr: f32) -> f32 {
|
||||
let (cx, cy) = (lw * 0.5, lh * 0.5);
|
||||
let v = match prop {
|
||||
0 => c[0],
|
||||
1 => c[1],
|
||||
2 => c[2],
|
||||
// Brightness: the brightest channel (HSB brightness).
|
||||
3 => c[0].max(c[1]).max(c[2]),
|
||||
// Saturation: HSB saturation.
|
||||
4 => {
|
||||
let mx = c[0].max(c[1]).max(c[2]);
|
||||
let mn = c[0].min(c[1]).min(c[2]);
|
||||
if mx > 0.0 { (mx - mn) / mx } else { 0.0 }
|
||||
}
|
||||
// RGB: the channels' mean.
|
||||
5 => (c[0] + c[1] + c[2]) / 3.0,
|
||||
// Radius: high at the centre, low at the corners.
|
||||
6 => 1.0 - (gx - cx).hypot(gy - cy) / maxr.max(1.0),
|
||||
// Diamond: high at the centre, falling linearly to the edge midpoints' diamond.
|
||||
7 => 1.0 - ((gx - cx).abs() / cx.max(0.5) + (gy - cy).abs() / cy.max(0.5)) * 0.5,
|
||||
// Spherize: a hemisphere over the largest centred circle.
|
||||
_ => {
|
||||
let rr = cx.min(cy).max(0.5);
|
||||
let d = (gx - cx).hypot(gy - cy) / rr;
|
||||
(1.0 - d * d).max(0.0).sqrt()
|
||||
}
|
||||
};
|
||||
if v.is_finite() { v.clamp(0.0, 1.0) } else { 0.0 }
|
||||
}
|
||||
|
||||
/// CC Ball Action's balls (far to near), coloured by the layer's pixels.
|
||||
fn ball_action_plan(ctx: &EffectCtx, b: &Buf) -> SpritePlan {
|
||||
let pr = ctx.params;
|
||||
@@ -18,7 +99,29 @@ fn ball_action_plan(ctx: &EffectCtx, b: &Buf) -> SpritePlan {
|
||||
let twist = pr.f("twistAngle").to_radians();
|
||||
let spacing = pr.f("gridSpacing").max(1.0) as f32;
|
||||
let size = pr.f("ballSize") as f32 / 100.0;
|
||||
let instab = pr.f("instabilityState").to_radians() as f32;
|
||||
// Scatter Motion, treated as the renamed Instability State (an assumption: After Effects
|
||||
// 24.2 shows Scatter Motion and no Instability State): turns each ball's scatter direction.
|
||||
let instab = pr.f("scatterMotion").to_radians() as f32;
|
||||
let coloring = pr.values.get("coloring").map(|v| v.as_enum()).unwrap_or(BALL_COLORING_MEDIUM);
|
||||
let shading = f_or(ctx, "shading", BALL_SHADING_DEFAULT);
|
||||
// Shading: -75 is the lit sphere as it always was, 0 flat discs; the magnitude scales the
|
||||
// light and shine (strength 1 at 75) and the sign mirrors the light's direction (positive
|
||||
// lights the balls from the lower right). How this compares with After Effects' sign
|
||||
// (described as concave versus convex) is unverified, as is the -100..100 range.
|
||||
let shape = if shading == BALL_SHADING_DEFAULT || !shading.is_finite() {
|
||||
Shape::Sphere
|
||||
} else if shading == 0.0 {
|
||||
Shape::Disc
|
||||
} else {
|
||||
// Clamped: a huge value would reach the GPU as an infinite strength (and NaN colours).
|
||||
Shape::Ball { shade: (-shading.clamp(-100.0, 100.0) / 75.0) as f32 }
|
||||
};
|
||||
// Displace: pushes each ball along z by its Displace Property (high values towards the
|
||||
// camera, pivoting at the property's middle value); 100 moves the extremes by half the
|
||||
// layer's diagonal. Scale, direction, pivot and range are EffectCraft's own choice,
|
||||
// pending a comparison with After Effects. Clamped so huge values stay finite.
|
||||
let displace = pr.f("displace").clamp(-1000.0, 1000.0) as f32;
|
||||
let displace_prop = pr.values.get("displaceProperty").map(|v| v.as_enum()).unwrap_or(BALL_DISPLACE_BRIGHTNESS);
|
||||
let seed = ctx.seed.wrapping_mul(0x2545f491);
|
||||
let (lw, lh) = (ctx.layer_size[0] as f32, ctx.layer_size[1] as f32);
|
||||
let s = b.scale as f32;
|
||||
@@ -43,7 +146,7 @@ fn ball_action_plan(ctx: &EffectCtx, b: &Buf) -> SpritePlan {
|
||||
let gx = (i % nx) as f32 * spacing + spacing * 0.5;
|
||||
let gy = (i / nx) as f32 * spacing + spacing * 0.5;
|
||||
let (sx, sy) = b.to_px([gx as f64, gy as f64]);
|
||||
let (c, a) = unpremul(src.sample_bilinear(sx, sy));
|
||||
let (c, a) = ball_color(src, sx, sy, f64::from(spacing * s), coloring);
|
||||
if a <= 0.0 || size <= 0.0 {
|
||||
return None;
|
||||
}
|
||||
@@ -54,11 +157,16 @@ fn ball_action_plan(ctx: &EffectCtx, b: &Buf) -> SpritePlan {
|
||||
_ => crate::util::rgb3([c[0], c[1], c[2], 0.0]).iter().sum::<f32>() / 3.0,
|
||||
} as f64;
|
||||
let ang = rot + twist * tp;
|
||||
// Scatter: random 3D offsets whose direction drifts with the instability state.
|
||||
// Scatter: random 3D offsets whose direction drifts with Scatter Motion.
|
||||
let ph = h(i, 1, seed) * std::f32::consts::TAU + instab;
|
||||
let sc = scatter * h(i, 2, seed);
|
||||
let off = [(sc * ph.cos()) as f64, (sc * ph.sin()) as f64, (scatter * hs(i, 3, seed)) as f64];
|
||||
let p0 = [gx as f64 - cx + off[0], gy as f64 - cy + off[1], off[2]];
|
||||
let mut p0 = [gx as f64 - cx + off[0], gy as f64 - cy + off[1], off[2]];
|
||||
// Only when set, so Displace 0 leaves every depth (and the far-to-near order) as is.
|
||||
if displace != 0.0 && displace.is_finite() {
|
||||
let v = ball_displace_value(displace_prop, c, gx, gy, lw, lh, maxr);
|
||||
p0[2] -= f64::from(displace / 100.0 * (v - 0.5) * 2.0 * maxr);
|
||||
}
|
||||
let m = rot_axis(ax, ang);
|
||||
let q: [f64; 3] = std::array::from_fn(|k| m[k][0] * p0[0] + m[k][1] * p0[1] + m[k][2] * p0[2]);
|
||||
if d + q[2] <= d * 0.05 {
|
||||
@@ -67,7 +175,7 @@ fn ball_action_plan(ctx: &EffectCtx, b: &Buf) -> SpritePlan {
|
||||
let persp = d / (d + q[2]);
|
||||
let (bx, by) = b.to_px([cx + q[0] * persp, cy + q[1] * persp]);
|
||||
let r = spacing * 0.5 * size * persp as f32 * s;
|
||||
Some((q[2], Sprite::new(bx as f32, by as f32, r, [c[0], c[1], c[2], a], Shape::Sphere)))
|
||||
Some((q[2], Sprite::new(bx as f32, by as f32, r, [c[0], c[1], c[2], a], shape)))
|
||||
})
|
||||
.collect();
|
||||
balls.sort_by(|a, b| b.0.total_cmp(&a.0));
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use super::foam::{FOAM_TEXTURES, foam};
|
||||
use super::pixels::{ball_action, pixel_polly, scatterize};
|
||||
use super::pixels::{
|
||||
BALL_COLORING, BALL_COLORING_MEDIUM, BALL_DISPLACE_BRIGHTNESS, BALL_DISPLACE_PROPERTIES, BALL_SHADING_DEFAULT, ball_action, pixel_polly, scatterize,
|
||||
};
|
||||
use super::shatter::{CD_PROPS, CD_SOURCES, SHATTER_PATTERNS, SHATTER_TEXTURE_MODES, card_dance, shatter};
|
||||
use super::surfaces::{caustics, wave_world};
|
||||
use super::{EffectSpec, ParamUi, Value, col, num, p, pct, popup, pt, slider, spec};
|
||||
@@ -80,15 +82,22 @@ pub fn specs() -> Vec<EffectSpec> {
|
||||
spec(
|
||||
"ec.sim.ccballaction",
|
||||
"Ball Grid",
|
||||
// After Effects' order and defaults since 24.2 (#3197). Scatter Motion is treated as
|
||||
// the renamed Instability State (an assumption, `migrate::PARAM_ID_ALIASES`). The
|
||||
// Shading range is not published; -100..100 is an assumption.
|
||||
vec![
|
||||
p("gridSpacing", "Grid Spacing", num(5.0), slider(1.0, 200.0, 1.0, 50.0, 0)),
|
||||
p("ballSize", "Ball Size", num(100.0), slider(0.0, 400.0, 0.0, 200.0, 1)),
|
||||
p("coloring", "Coloring", Value::Enum(BALL_COLORING_MEDIUM), popup(BALL_COLORING)),
|
||||
p("shading", "Shading", num(BALL_SHADING_DEFAULT), slider(-100.0, 100.0, -100.0, 100.0, 1)),
|
||||
p("scatter", "Scatter", num(0.0), slider(0.0, 2000.0, 0.0, 300.0, 1)),
|
||||
p("scatterMotion", "Scatter Motion", num(0.0), ParamUi::Angle),
|
||||
p("displace", "Displace", num(0.0), slider(-1000.0, 1000.0, 0.0, 100.0, 1)),
|
||||
p("displaceProperty", "Displace Property", Value::Enum(BALL_DISPLACE_BRIGHTNESS), popup(BALL_DISPLACE_PROPERTIES)),
|
||||
p("twistAngle", "Twist Angle", num(0.0), ParamUi::Angle),
|
||||
p("twistProperty", "Twist Property", Value::Enum(0), popup(&["X Axis", "Y Axis", "Radius", "Brightness"])),
|
||||
p("rotationAxis", "Rotation Axis", Value::Enum(0), popup(&["X Axis", "Y Axis", "Z Axis", "XY Axis", "XZ Axis", "YZ Axis", "XYZ Axis"])),
|
||||
p("rotation", "Rotation", num(0.0), ParamUi::Angle),
|
||||
p("twistProperty", "Twist Property", Value::Enum(0), popup(&["X Axis", "Y Axis", "Radius", "Brightness"])),
|
||||
p("twistAngle", "Twist Angle", num(0.0), ParamUi::Angle),
|
||||
p("gridSpacing", "Grid Spacing", num(4.0), slider(1.0, 200.0, 1.0, 50.0, 0)),
|
||||
p("ballSize", "Ball Size", num(40.0), slider(0.0, 400.0, 0.0, 200.0, 1)),
|
||||
p("instabilityState", "Instability State", num(0.0), ParamUi::Angle),
|
||||
],
|
||||
ball_action,
|
||||
),
|
||||
|
||||
@@ -46,6 +46,138 @@ fn ball_action_draws_balls() {
|
||||
assert!(sum_diff(&a, &sc) > 1.0);
|
||||
}
|
||||
|
||||
/// #3197: CC Ball Action has After Effects' controls (since 24.2), in its order, with its
|
||||
/// defaults: Coloring, Shading, Scatter Motion (formerly Instability State), Displace and
|
||||
/// Displace Property were missing.
|
||||
#[test]
|
||||
fn ball_action_has_after_effects_controls() {
|
||||
let spec = crate::find("ec.sim.ccballaction").unwrap();
|
||||
let names: Vec<&str> = spec.params.iter().map(|p| p.name).collect();
|
||||
assert_eq!(
|
||||
names,
|
||||
[
|
||||
"Grid Spacing",
|
||||
"Ball Size",
|
||||
"Coloring",
|
||||
"Shading",
|
||||
"Scatter",
|
||||
"Scatter Motion",
|
||||
"Displace",
|
||||
"Displace Property",
|
||||
"Twist Angle",
|
||||
"Twist Property",
|
||||
"Rotation Axis",
|
||||
"Rotation"
|
||||
]
|
||||
);
|
||||
let sp = |id: &str| spec.params.iter().find(|p| p.id == id).unwrap_or_else(|| panic!("no {id}"));
|
||||
assert_eq!(sp("gridSpacing").default, num(5.0));
|
||||
assert_eq!(sp("ballSize").default, num(100.0));
|
||||
assert_eq!(sp("coloring").default, Value::Enum(1));
|
||||
assert_eq!(sp("coloring").ui, ParamUi::Popup { options: vec!["Crisp".into(), "Medium".into(), "Smooth".into()] });
|
||||
assert_eq!(sp("shading").default, num(-75.0));
|
||||
assert!(matches!(sp("shading").ui, ParamUi::Slider { min, max, .. } if min <= -100.0 && max >= 100.0));
|
||||
assert_eq!(sp("scatterMotion").default, num(0.0));
|
||||
assert_eq!(sp("scatterMotion").ui, ParamUi::Angle);
|
||||
assert_eq!(sp("displace").default, num(0.0));
|
||||
let ParamUi::Popup { options } = &sp("displaceProperty").ui else { panic!("Displace Property is a popup") };
|
||||
let Value::Enum(d) = sp("displaceProperty").default else { panic!("Displace Property defaults to an option") };
|
||||
assert_eq!(options.get(d as usize).map(String::as_str), Some("Brightness"));
|
||||
// Old projects' Instability State becomes Scatter Motion through `PARAM_ID_ALIASES`; the
|
||||
// engine test `opening_an_old_project_upgrades_effect_instances` covers every alias.
|
||||
}
|
||||
|
||||
/// #3197: the new controls at After Effects' defaults draw exactly what CC Ball Action drew
|
||||
/// before (the lit sphere, a smooth colour sample, no displacement).
|
||||
#[test]
|
||||
fn ball_action_new_controls_at_defaults_keep_the_render() {
|
||||
let base = [("ballSize", num(80.0)), ("scatter", num(6.0)), ("rotationAxis", Value::Enum(1)), ("rotation", num(25.0))];
|
||||
let a = run("ec.sim.ccballaction", &base, ramp(32, 32), 0.0);
|
||||
let mut explicit = base.to_vec();
|
||||
explicit.extend([
|
||||
("coloring", Value::Enum(1)),
|
||||
("shading", num(-75.0)),
|
||||
("scatterMotion", num(0.0)),
|
||||
("displace", num(0.0)),
|
||||
("displaceProperty", Value::Enum(3)),
|
||||
]);
|
||||
assert_eq!(a, run("ec.sim.ccballaction", &explicit, ramp(32, 32), 0.0));
|
||||
}
|
||||
|
||||
/// #3197: Shading 0 removes the built-in light: every ball is the layer's flat colour. The
|
||||
/// default (-75) shades it; a smaller magnitude shades less, a positive value lights the balls
|
||||
/// from the other side.
|
||||
#[test]
|
||||
fn ball_action_shading_zero_is_flat() {
|
||||
let c = [0.6, 0.3, 0.2, 1.0];
|
||||
let shade = |v: f64| run("ec.sim.ccballaction", &[("ballSize", num(100.0)), ("gridSpacing", num(8.0)), ("shading", num(v))], Image::filled(32, 32, c), 0.0);
|
||||
let flat = shade(0.0);
|
||||
let covered: Vec<&[f32; 4]> = flat.data.iter().filter(|p| p[3] > 0.999).collect();
|
||||
assert!(!covered.is_empty(), "balls drawn");
|
||||
for p in &covered {
|
||||
for k in 0..3 {
|
||||
assert!((p[k] / p[3] - c[k]).abs() < 1e-4, "flat colour: {p:?}");
|
||||
}
|
||||
}
|
||||
let lit = shade(-75.0);
|
||||
assert!(lit.data.iter().any(|p| p[3] > 0.999 && (0..3).any(|k| (p[k] / p[3] - c[k]).abs() > 0.05)), "the default shading lights and darkens the balls");
|
||||
let soft = shade(-30.0);
|
||||
assert!(sum_diff(&flat, &soft) > 0.1 && sum_diff(&flat, &soft) < sum_diff(&flat, &lit), "less shading, closer to flat");
|
||||
assert!(sum_diff(&shade(75.0), &lit) > 1.0, "the sign moves the light");
|
||||
}
|
||||
|
||||
/// #3197: Coloring Crisp takes the pixel under each ball's cell centre; Medium samples
|
||||
/// smoothly between pixels. Grid Spacing 4 puts the cell centres on pixel corners (with the
|
||||
/// default 5 they fall on pixel centres, where Medium's sample equals Crisp's).
|
||||
#[test]
|
||||
fn ball_action_coloring_crisp_takes_the_pixel() {
|
||||
let mut src = Image::new(32, 32);
|
||||
for y in 0..32u32 {
|
||||
for x in 0..32u32 {
|
||||
src.set(x, y, [x as f32 / 32.0, y as f32 / 32.0, ((x * 7 + y * 3) % 5) as f32 / 4.0, 1.0]);
|
||||
}
|
||||
}
|
||||
let col = |m: u32| {
|
||||
let v = [("gridSpacing", num(4.0)), ("ballSize", num(100.0)), ("shading", num(0.0)), ("coloring", Value::Enum(m))];
|
||||
run("ec.sim.ccballaction", &v, src.clone(), 0.0)
|
||||
};
|
||||
let crisp = col(0);
|
||||
// Flat, opaque balls of radius 2 centred on (4i + 2, 4j + 2): the pixel to the lower right
|
||||
// of each centre is fully covered by its ball alone.
|
||||
for j in 0..8i64 {
|
||||
for i in 0..8i64 {
|
||||
let (x, y) = (4 * i + 2, 4 * j + 2);
|
||||
let (got, want) = (crisp.get(x, y), src.get(x, y));
|
||||
assert!((0..4).all(|k| (got[k] - want[k]).abs() < 1e-5), "ball ({i}, {j}): {got:?} vs the pixel {want:?}");
|
||||
}
|
||||
}
|
||||
assert!(sum_diff(&crisp, &col(1)) > 1.0, "medium blends the pixels");
|
||||
}
|
||||
|
||||
/// #3197: a huge Shading (typed or from an expression) is clamped, so the balls stay finite.
|
||||
#[test]
|
||||
fn ball_action_huge_shading_stays_finite() {
|
||||
for v in [1e45, -1e45, f64::MAX] {
|
||||
let o = run("ec.sim.ccballaction", &[("gridSpacing", num(8.0)), ("shading", num(v))], ramp(32, 32), 0.0);
|
||||
assert!(o.data.iter().all(|p| p.iter().all(|c| c.is_finite())), "shading {v}");
|
||||
assert!(o.data.iter().any(|p| p[3] > 0.0), "shading {v}: balls drawn");
|
||||
}
|
||||
}
|
||||
|
||||
/// #3197: Displace pushes the balls along z by the chosen property (Radius: the centre comes
|
||||
/// towards the camera and grows); 0 leaves them in the layer's plane.
|
||||
#[test]
|
||||
fn ball_action_displace_moves_balls_in_depth() {
|
||||
let flat = run("ec.sim.ccballaction", &[("ballSize", num(80.0))], ramp(32, 32), 0.0);
|
||||
let d = run("ec.sim.ccballaction", &[("ballSize", num(80.0)), ("displace", num(60.0)), ("displaceProperty", Value::Enum(6))], ramp(32, 32), 0.0);
|
||||
assert_eq!(d, run("ec.sim.ccballaction", &[("ballSize", num(80.0)), ("displace", num(60.0)), ("displaceProperty", Value::Enum(6))], ramp(32, 32), 0.0));
|
||||
assert!(sum_diff(&flat, &d) > 1.0);
|
||||
for prop in 0..9 {
|
||||
let o = run("ec.sim.ccballaction", &[("ballSize", num(80.0)), ("displace", num(400.0)), ("displaceProperty", Value::Enum(prop))], ramp(32, 32), 0.0);
|
||||
assert!(o.data.iter().all(|p| p.iter().all(|v| v.is_finite())), "property {prop}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pixel_polly_breaks_after_start() {
|
||||
let v = [("forceCenter", pt(16.0, 16.0)), ("gridSpacing", num(4.0))];
|
||||
|
||||
@@ -192,7 +192,7 @@ fn cases() -> Vec<(&'static str, Vec<Set>)> {
|
||||
vec![
|
||||
vec![],
|
||||
vec![("scatter", n(20.0)), ("rotationAxis", e(6)), ("rotation", n(40.0)), ("twistProperty", e(3)), ("twistAngle", n(90.0))],
|
||||
vec![("gridSpacing", n(2.0)), ("ballSize", n(80.0)), ("instabilityState", n(45.0)), ("twistProperty", e(2)), ("twistAngle", n(30.0))],
|
||||
vec![("gridSpacing", n(2.0)), ("ballSize", n(80.0)), ("scatterMotion", n(45.0)), ("twistProperty", e(2)), ("twistAngle", n(30.0))],
|
||||
],
|
||||
),
|
||||
(
|
||||
@@ -538,26 +538,26 @@ const GOLDEN: &[(&str, u64)] = &[
|
||||
("ec.sim.particleplayground/8/32bpc/t1.5", 0xb5b7f0281f26baad),
|
||||
("ec.sim.particleplayground/8/32bpc/t0.8", 0x8b6934363ef4dcfd),
|
||||
("ec.sim.particleplayground/8/32bpc/t2.2", 0x0a31c17e8e34b9f5),
|
||||
("ec.sim.ccballaction/0/8bpc/t0.5", 0x12698ec8353be38c),
|
||||
("ec.sim.ccballaction/0/8bpc/t1.5", 0x12698ec8353be38c),
|
||||
("ec.sim.ccballaction/0/8bpc/t0.8", 0x12698ec8353be38c),
|
||||
("ec.sim.ccballaction/0/8bpc/t2.2", 0x12698ec8353be38c),
|
||||
("ec.sim.ccballaction/0/32bpc/t0.5", 0x3fb733487e120261),
|
||||
("ec.sim.ccballaction/0/32bpc/t1.5", 0x3fb733487e120261),
|
||||
("ec.sim.ccballaction/0/32bpc/t0.8", 0x3fb733487e120261),
|
||||
("ec.sim.ccballaction/0/32bpc/t2.2", 0x3fb733487e120261),
|
||||
("ec.sim.ccballaction/0/8bpc/half/t0.5", 0x4946070917cc0945),
|
||||
("ec.sim.ccballaction/0/8bpc/half/t1.5", 0x4946070917cc0945),
|
||||
("ec.sim.ccballaction/0/8bpc/half/t0.8", 0x4946070917cc0945),
|
||||
("ec.sim.ccballaction/0/8bpc/half/t2.2", 0x4946070917cc0945),
|
||||
("ec.sim.ccballaction/1/8bpc/t0.5", 0xf34b3be38a4dd468),
|
||||
("ec.sim.ccballaction/1/8bpc/t1.5", 0xf34b3be38a4dd468),
|
||||
("ec.sim.ccballaction/1/8bpc/t0.8", 0xf34b3be38a4dd468),
|
||||
("ec.sim.ccballaction/1/8bpc/t2.2", 0xf34b3be38a4dd468),
|
||||
("ec.sim.ccballaction/1/32bpc/t0.5", 0x503b7238edf2912c),
|
||||
("ec.sim.ccballaction/1/32bpc/t1.5", 0x503b7238edf2912c),
|
||||
("ec.sim.ccballaction/1/32bpc/t0.8", 0x503b7238edf2912c),
|
||||
("ec.sim.ccballaction/1/32bpc/t2.2", 0x503b7238edf2912c),
|
||||
("ec.sim.ccballaction/0/8bpc/t0.5", 0x5f7401d3d1e5a513),
|
||||
("ec.sim.ccballaction/0/8bpc/t1.5", 0x5f7401d3d1e5a513),
|
||||
("ec.sim.ccballaction/0/8bpc/t0.8", 0x5f7401d3d1e5a513),
|
||||
("ec.sim.ccballaction/0/8bpc/t2.2", 0x5f7401d3d1e5a513),
|
||||
("ec.sim.ccballaction/0/32bpc/t0.5", 0x9cf15a7756ab88ed),
|
||||
("ec.sim.ccballaction/0/32bpc/t1.5", 0x9cf15a7756ab88ed),
|
||||
("ec.sim.ccballaction/0/32bpc/t0.8", 0x9cf15a7756ab88ed),
|
||||
("ec.sim.ccballaction/0/32bpc/t2.2", 0x9cf15a7756ab88ed),
|
||||
("ec.sim.ccballaction/0/8bpc/half/t0.5", 0xe2e3a624434f8e88),
|
||||
("ec.sim.ccballaction/0/8bpc/half/t1.5", 0xe2e3a624434f8e88),
|
||||
("ec.sim.ccballaction/0/8bpc/half/t0.8", 0xe2e3a624434f8e88),
|
||||
("ec.sim.ccballaction/0/8bpc/half/t2.2", 0xe2e3a624434f8e88),
|
||||
("ec.sim.ccballaction/1/8bpc/t0.5", 0x07382912d068a625),
|
||||
("ec.sim.ccballaction/1/8bpc/t1.5", 0x07382912d068a625),
|
||||
("ec.sim.ccballaction/1/8bpc/t0.8", 0x07382912d068a625),
|
||||
("ec.sim.ccballaction/1/8bpc/t2.2", 0x07382912d068a625),
|
||||
("ec.sim.ccballaction/1/32bpc/t0.5", 0xa1e843936e72815f),
|
||||
("ec.sim.ccballaction/1/32bpc/t1.5", 0xa1e843936e72815f),
|
||||
("ec.sim.ccballaction/1/32bpc/t0.8", 0xa1e843936e72815f),
|
||||
("ec.sim.ccballaction/1/32bpc/t2.2", 0xa1e843936e72815f),
|
||||
("ec.sim.ccballaction/2/8bpc/t0.5", 0x0b6bf26753ee4582),
|
||||
("ec.sim.ccballaction/2/8bpc/t1.5", 0x0b6bf26753ee4582),
|
||||
("ec.sim.ccballaction/2/8bpc/t0.8", 0x0b6bf26753ee4582),
|
||||
|
||||
@@ -11,6 +11,7 @@ workspace = true
|
||||
|
||||
[dependencies]
|
||||
effectcraft-time = { workspace = true }
|
||||
effectcraft-effects = { workspace = true }
|
||||
effectcraft-geom = { workspace = true }
|
||||
effectcraft-keyframe = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
@@ -25,5 +26,4 @@ boa_engine = { workspace = true, features = ["js"] }
|
||||
|
||||
[dev-dependencies]
|
||||
effectcraft-color = { workspace = true }
|
||||
effectcraft-effects = { workspace = true }
|
||||
effectcraft-text = { workspace = true }
|
||||
@@ -7,6 +7,7 @@
|
||||
//! the answers and runs the script again. Expressions are pure functions of these answers, so
|
||||
//! re-running is exact, and the runtime stays free of borrowed state.
|
||||
|
||||
use effectcraft_effects::migrate::PARAM_ID_ALIASES;
|
||||
use effectcraft_geom::{Mat3, Mat4};
|
||||
use effectcraft_keyframe::Value;
|
||||
use effectcraft_project::ae_order::{self, AeChild};
|
||||
@@ -300,10 +301,24 @@ fn find_child<'g>(g: &'g PropGroup, key: &Key) -> Option<&'g Node> {
|
||||
// An effect by its After Effects match name, an imported placeholder's effect id
|
||||
// (`effect("Pseudo/0.25")`; its match id is one path segment, `Pseudo_0_25`).
|
||||
.or_else(|| g.children.iter().find(|n| matches!(n.as_group().map(|g| &g.kind), Some(GroupKind::Effect { effect }) if effect == name)))
|
||||
// Last, so a legacy name never shadows a current one.
|
||||
.or_else(|| legacy_effect_child(g, &c))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A parameter of an effect instance addressed by a name it had when the project was saved
|
||||
/// ([`PARAM_ID_ALIASES`]): `effect("CC Ball Action")("Instability State")` keeps reading the
|
||||
/// parameter that is now Scatter Motion. `c` is the compacted (lowercase, no spaces) name. Only
|
||||
/// renames inside the instance's own top-level group count; moves into twirl-downs do not.
|
||||
fn legacy_effect_child<'g>(g: &'g PropGroup, c: &str) -> Option<&'g Node> {
|
||||
let GroupKind::Effect { effect } = &g.kind else { return None };
|
||||
PARAM_ID_ALIASES
|
||||
.iter()
|
||||
.filter(|(e, old, new)| e == effect && !old.contains('/') && !new.contains('/') && compact(old) == c)
|
||||
.find_map(|(_, _, new)| g.children.iter().find(|n| n.match_id() == *new))
|
||||
}
|
||||
|
||||
impl<'a> Resolver<'a> {
|
||||
fn comp(&self, c: u64) -> Option<&'a Comp> {
|
||||
if c == self.ctx.comp_id.0 { Some(self.ctx.comp) } else { self.ctx.project.comp(ItemId(c)) }
|
||||
|
||||
@@ -2145,6 +2145,89 @@ fn bench_evaluation() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Layer A with an old-format CC Ball Action: Scatter Motion saved as `instabilityState`
|
||||
/// ("Instability State"), opened through the migration (#3197). Scatter Motion is 37 and keyed
|
||||
/// 10 at 0 s, 50 at 2 s.
|
||||
fn old_ball_action() -> Fx {
|
||||
let mut f = fx();
|
||||
let spec = effectcraft_effects::find("ec.sim.ccballaction").unwrap();
|
||||
let mut g = group_push(&mut f.p, |ids| effectcraft_effects::instantiate(spec, ids, "CC Ball Action", [20.0, 20.0]));
|
||||
let sm = g.prop_mut("scatterMotion").unwrap();
|
||||
sm.value = Value::Scalar(37.0);
|
||||
sm.keys = vec![Keyframe::new(Tick::ZERO, Value::Scalar(10.0)), Keyframe::new(secs(2.0), Value::Scalar(50.0))];
|
||||
sm.match_id = "instabilityState".into();
|
||||
sm.name = "Instability State".into();
|
||||
let mut next = f.p.next_id;
|
||||
assert!(effectcraft_effects::migrate::upgrade_instance(spec, &mut g, &mut Ids(&mut next), [20.0, 20.0]));
|
||||
f.p.next_id = next;
|
||||
assert!(g.prop("scatterMotion").is_some(), "the migration renamed the parameter");
|
||||
f.p.comp_mut(f.cid).unwrap().layers[0].props.sub_mut("effects").unwrap().children.push(g.into());
|
||||
f
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn old_parameter_names_still_resolve_in_expressions() {
|
||||
let f = old_ball_action();
|
||||
for name in ["Instability State", "instabilityState", "instability state", "InstabilityState"] {
|
||||
// Keyframes still apply: the keyed value at 0 s, not the stored 37.
|
||||
assert_close!(f.num(&format!("effect('CC Ball Action')('{name}')"), 0.0), 10.0);
|
||||
assert_close!(f.num(&format!("effect('CC Ball Action')('{name}')"), 2.0), 50.0);
|
||||
assert_close!(f.num(&format!("effect('CC Ball Action')('{name}').valueAtTime(2)"), 0.0), 50.0);
|
||||
}
|
||||
// Current names read the same property, unchanged.
|
||||
for name in ["Scatter Motion", "scatterMotion"] {
|
||||
assert_close!(f.num(&format!("effect('CC Ball Action')('{name}')"), 0.0), 10.0);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn old_parameter_name_follows_the_parameter_expression() {
|
||||
let mut f = old_ball_action();
|
||||
let p = f.p.comp_mut(f.cid).unwrap().layers[0].props.prop_mut("effects/#2/scatterMotion");
|
||||
let p = match p {
|
||||
Some(p) => p,
|
||||
None => panic!("scatterMotion at effects/#2"),
|
||||
};
|
||||
p.expr = Some(Expression { text: "123".into(), enabled: true });
|
||||
assert_close!(f.num("effect('CC Ball Action')('Instability State')", 0.0), 123.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_parameter_names_still_fail() {
|
||||
let f = old_ball_action();
|
||||
assert!(f.ev(f.a, ROT, "effect('CC Ball Action')('No Such Thing')", 0.0).is_err());
|
||||
// Old names only exist on the effect they were renamed on.
|
||||
assert!(f.ev(f.a, ROT, "effect('Slider Control')('Instability State')", 0.0).is_err());
|
||||
}
|
||||
|
||||
/// Every in-group rename in the alias table keeps resolving by its old id and display name.
|
||||
#[test]
|
||||
fn every_in_group_alias_resolves_by_its_old_name() {
|
||||
let mut n = 0;
|
||||
for (effect, old, new) in effectcraft_effects::migrate::PARAM_ID_ALIASES {
|
||||
if old.contains('/') || new.contains('/') {
|
||||
continue;
|
||||
}
|
||||
let Some(spec) = effectcraft_effects::find(effect) else { continue };
|
||||
let mut f = fx();
|
||||
let g = group_push(&mut f.p, |ids| effectcraft_effects::instantiate(spec, ids, "Probe", [20.0, 20.0]));
|
||||
f.p.comp_mut(f.cid).unwrap().layers[0].props.sub_mut("effects").unwrap().children.push(g.into());
|
||||
let (new_name, kind) = {
|
||||
let l = &f.p.comp(f.cid).unwrap().layers[0];
|
||||
let p = l.props.prop(&format!("effects/#2/{new}")).unwrap();
|
||||
(p.name.clone(), p.value.clone())
|
||||
};
|
||||
if !matches!(kind, Value::Scalar(_)) {
|
||||
continue;
|
||||
}
|
||||
let a = f.ev(f.a, ROT, &format!("effect('Probe')('{old}')"), 0.0).unwrap();
|
||||
let b = f.ev(f.a, ROT, &format!("effect('Probe')('{new_name}')"), 0.0).unwrap();
|
||||
assert_eq!(a, b, "{effect}: {old}");
|
||||
n += 1;
|
||||
}
|
||||
assert!(n >= 1);
|
||||
}
|
||||
|
||||
/// Viewport clipping must never affect layer-space expression reads (#1388).
|
||||
#[test]
|
||||
fn sample_image_reads_3d_shape_behind_camera_before_and_after_effects() {
|
||||
|
||||
@@ -228,6 +228,8 @@ pub(crate) fn sprite_layer(e: &mut Enc, src: &GpuImage, plan: &SpritePlan) -> Op
|
||||
Shape::Square => (6.0, 0.0, 0.0),
|
||||
Shape::Tri => (7.0, 0.0, 0.0),
|
||||
Shape::Line { dx, dy } => (8.0, dx, dy),
|
||||
// The strength rides in the (otherwise unused) first segment slot.
|
||||
Shape::Ball { shade } => (9.0, shade, 0.0),
|
||||
};
|
||||
let mut rec = [kind, s.x, s.y, s.r, s.c[0], s.c[1], s.c[2], s.c[3], s.rot, dx, dy, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
|
||||
match plan.tints.get(i).copied().unwrap_or(Tint::Fixed) {
|
||||
|
||||
@@ -145,6 +145,27 @@ fn fxm_sprite(at: u32, x: f32, y: f32) -> FxmShade {
|
||||
}
|
||||
cov = fxm_aa(m);
|
||||
}
|
||||
// sim::Shape::Ball (CC Ball Action's Shading): the sphere's light and shine scaled by
|
||||
// |shade| (data[at + 9]), lit from the lower right when shade < 0.
|
||||
case 9u: {
|
||||
let d = sqrt(dx * dx + dy * dy);
|
||||
let cv = fxm_aa(r - d);
|
||||
if (cv <= 0.0) {
|
||||
return fxm_none();
|
||||
}
|
||||
let shade = data[at + 9u];
|
||||
let nx = dx / r;
|
||||
let ny = dy / r;
|
||||
let nz = sqrt(max(1.0 - nx * nx - ny * ny, 0.0));
|
||||
let m = select(1.0, -1.0, shade < 0.0);
|
||||
let diff = max(nx * (-0.48 * m) + ny * (-0.58 * m) + nz * 0.66, 0.0);
|
||||
let rz = 2.0 * diff * nz - 0.66;
|
||||
let st = abs(shade);
|
||||
let spec = powz(max(rz, 0.0), 20.0) * 0.6 * st;
|
||||
let k = max(1.0 - st * 0.8 * (1.0 - diff), 0.0);
|
||||
rgb = rgb * k + spec;
|
||||
cov = cv;
|
||||
}
|
||||
default: {
|
||||
let lx = data[at + 9u];
|
||||
let ly = data[at + 10u];
|
||||
|
||||
@@ -141,7 +141,22 @@ fn ball_action_pixel_polly_scatterize() {
|
||||
0.0,
|
||||
0.0,
|
||||
);
|
||||
case("ec.sim.ccballaction", &[("gridSpacing", n(2.0)), ("ballSize", n(80.0)), ("instabilityState", n(45.0)), ("twistProperty", e(2))], 0.0, 0.0);
|
||||
case("ec.sim.ccballaction", &[("gridSpacing", n(2.0)), ("ballSize", n(80.0)), ("scatterMotion", n(45.0)), ("twistProperty", e(2))], 0.0, 0.0);
|
||||
// #3197: Shading (flat, weaker, stronger, lit from the other side), Coloring, Displace.
|
||||
for shading in [0.0, -30.0, -100.0, 60.0, 1e45] {
|
||||
case("ec.sim.ccballaction", &[("ballSize", n(80.0)), ("shading", n(shading))], 0.0, 0.0);
|
||||
}
|
||||
for coloring in [0, 2] {
|
||||
case("ec.sim.ccballaction", &[("ballSize", n(80.0)), ("coloring", e(coloring))], 0.0, 0.0);
|
||||
}
|
||||
for prop in [3, 6, 8] {
|
||||
case(
|
||||
"ec.sim.ccballaction",
|
||||
&[("ballSize", n(80.0)), ("rotationAxis", e(1)), ("rotation", n(30.0)), ("displace", n(40.0)), ("displaceProperty", e(prop))],
|
||||
0.0,
|
||||
0.0,
|
||||
);
|
||||
}
|
||||
for object in 0..4 {
|
||||
case("ec.sim.ccpixelpolly", &[("object", e(object)), ("gridSpacing", n(6.0))], 0.6, 0.0);
|
||||
}
|
||||
|
||||
+3
-3
@@ -3,13 +3,13 @@
|
||||
<!-- Generated from the effect registry (crates/effects/src/catalog.rs); do not edit by hand.
|
||||
Regenerate: UPDATE_DOCS=1 cargo test -p effectcraft-effects --lib effects_doc_is_current -->
|
||||
|
||||
EffectCraft ships 308 effects with 2988 parameters in total, grouped into the same categories as the Effects & Presets panel. Every effect is our own implementation, written from public behaviour descriptions and standard image-processing literature. Parameter names, order, popup options, units, defaults and ranges follow the reference application so that projects, expressions and muscle memory carry over.
|
||||
EffectCraft ships 308 effects with 2992 parameters in total, grouped into the same categories as the Effects & Presets panel. Every effect is our own implementation, written from public behaviour descriptions and standard image-processing literature. Parameter names, order, popup options, units, defaults and ranges follow the reference application so that projects, expressions and muscle memory carry over.
|
||||
|
||||
- **GPU**: 280 effects also run on the GPU compositor with identical results.
|
||||
- **32**: 308 effects process 32-bit float (HDR, overbright) pixels without clamping.
|
||||
- **Status**: 308 implemented in full, 0 partial (what is missing is listed).
|
||||
|
||||
Effects are addressed by id (`ec.<category>.<name>`) or display name in commands, scripts and the control channel, and every parameter by its id (`effects/#1/blurriness`).
|
||||
Effects are addressed by id (`ec.<category>.<name>`) or display name in commands, scripts and the control channel, and every parameter by its id (`effects/#1/blurriness`). A parameter that was renamed keeps its old name working in expressions of older projects: `effect("CC Ball Action")("Instability State")` still reads Scatter Motion.
|
||||
|
||||
## 3D Channel
|
||||
|
||||
@@ -319,7 +319,7 @@ Effects are addressed by id (`ec.<category>.<name>`) or display name in commands
|
||||
|
||||
| Effect | Id | Params | GPU | 32 | Status |
|
||||
|---|---|---:|:-:|:-:|---|
|
||||
| Ball Grid | `ec.sim.ccballaction` | 8 | GPU | 32 | Implemented |
|
||||
| Ball Grid | `ec.sim.ccballaction` | 12 | GPU | 32 | Implemented |
|
||||
| Bubbles | `ec.sim.ccbubbles` | 7 | GPU | 32 | Implemented |
|
||||
| Card Dance | `ec.sim.carddance` | 53 | GPU | 32 | Implemented |
|
||||
| Caustics | `ec.sim.caustics` | 28 | GPU | 32 | Implemented |
|
||||
|
||||
Reference in new issue
Block a user