Merge main into M13.28 worktree
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -91,36 +91,12 @@ const CPU_ONLY_CONTROLS: &[(&str, &[&str])] = &[
|
||||
];
|
||||
|
||||
/// Whether the GPU kernel of effect `id` covers the instance's current settings (see
|
||||
/// [`CPU_ONLY_CONTROLS`]; plus Cell Pattern's HQ variants, Turbulent Displace's locked
|
||||
/// pinning, Warp's strong Fisheye / Twist and Timewarp with a Matte Layer).
|
||||
/// [`CPU_ONLY_CONTROLS`]; plus Cell Pattern's HQ variants and Turbulent Displace's locked
|
||||
/// pinning).
|
||||
pub fn gpu_supported(id: &str, ctx: &crate::EffectCtx) -> bool {
|
||||
match id {
|
||||
"ec.generate.cellpattern" if (6..=10).contains(&ctx.params.e("cellPattern")) => return false,
|
||||
"ec.distort.turbulentdisplace" if ctx.params.e("pinning") >= 8 => return false,
|
||||
// Shatter's wireframe views; Foam's User Defined texture, Environment Map and flow-map
|
||||
// preview (the GPU draws the rendered pieces and the sprite bubbles only).
|
||||
"ec.sim.shatter" if ctx.params.e("view") != 0 => return false,
|
||||
"ec.sim.foam" => {
|
||||
let set = |id: &str| matches!(ctx.params.get(id), Some(effectcraft_keyframe::Value::Layer(Some(_))));
|
||||
let view = ctx.params.e("view");
|
||||
if (view == 2 && ctx.params.e("rendering/bubbleTexture") == 5)
|
||||
|| (view == 2 && ctx.params.f("rendering/reflectionStrength") > 0.0 && set("rendering/environmentMap"))
|
||||
|| (view == 1 && set("flowMap/flowMap"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Timewarp's Matte Layer (foreground and background on their own vectors).
|
||||
"ec.time.timewarp" if ctx.params.get("matteLayer").and_then(effectcraft_keyframe::Value::as_layer).is_some() => return false,
|
||||
// Fisheye / Twist (a crease at the unit circle) bent past 50 % or with Horizontal /
|
||||
// Vertical Distortion: Newton's inverse wanders chaotically before converging near the
|
||||
// fold, so f32 lands on other pixels than the CPU's f64.
|
||||
"ec.distort.warp"
|
||||
if matches!(ctx.params.e("warpStyle"), 11 | 14)
|
||||
&& (ctx.params.f("bend").abs() > 50.0 || ctx.params.f("horizontalDistortion") != 0.0 || ctx.params.f("verticalDistortion") != 0.0) =>
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
let Some((_, controls)) = CPU_ONLY_CONTROLS.iter().find(|(e, _)| *e == id) else { return true };
|
||||
|
||||
@@ -663,13 +663,24 @@ fn warp(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
if k == 0.0 && hd == 0.0 && vd == 0.0 {
|
||||
return b;
|
||||
}
|
||||
let style = ctx.params.e("warpStyle");
|
||||
let vertical = ctx.params.e("warpAxis") == 1;
|
||||
let (hx, hy) = (ctx.layer_size[0] * b.scale * 0.5, ctx.layer_size[1] * b.scale * 0.5);
|
||||
if !ctx.adjustment {
|
||||
let pad = ((k.abs() + hd.abs() + vd.abs()) * 0.6 * hx.max(hy)).ceil().min(4096.0);
|
||||
b.pad(pad as u32 + 1);
|
||||
}
|
||||
b.img = remap(&b.img, false, warp_inverse(ctx, &b));
|
||||
b
|
||||
}
|
||||
|
||||
/// Warp's inverse map for buffer geometry `b` (padded): the source point of an output point
|
||||
/// (buffer px), by Newton iterations on the forward warp; `None` = transparent.
|
||||
fn warp_inverse(ctx: &EffectCtx, b: &Buf) -> impl Fn(f64, f64) -> Option<(f64, f64)> + Sync + use<> {
|
||||
let k = ctx.params.f("bend") / 100.0;
|
||||
let hd = ctx.params.f("horizontalDistortion") / 100.0;
|
||||
let vd = ctx.params.f("verticalDistortion") / 100.0;
|
||||
let style = ctx.params.e("warpStyle");
|
||||
let vertical = ctx.params.e("warpAxis") == 1;
|
||||
let (hx, hy) = (ctx.layer_size[0] * b.scale * 0.5, ctx.layer_size[1] * b.scale * 0.5);
|
||||
let c = b.to_px([ctx.layer_size[0] * 0.5, ctx.layer_size[1] * 0.5]);
|
||||
let (hx, hy) = (hx.max(1e-6), hy.max(1e-6));
|
||||
let fwd = move |x: f64, y: f64| -> (f64, f64) {
|
||||
@@ -682,7 +693,7 @@ fn warp(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
x1 *= 1.0 + 0.5 * vd * y1;
|
||||
(c.0 + x1 * hx, c.1 + y1 * hy)
|
||||
};
|
||||
b.img = remap(&b.img, false, |x, y| {
|
||||
move |x, y| {
|
||||
let (mut sx, mut sy) = (x, y);
|
||||
for _ in 0..12 {
|
||||
let (fx, fy) = fwd(sx, sy);
|
||||
@@ -706,8 +717,19 @@ fn warp(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
return None;
|
||||
}
|
||||
Some((sx, sy))
|
||||
});
|
||||
b
|
||||
}
|
||||
}
|
||||
|
||||
/// Warp's inverse map over a `w` × `h` buffer with geometry `b` (its pixels are not read), as
|
||||
/// an image of (source x, source y, 1, 0) per pixel centre, transparent where the warp leaves
|
||||
/// the pixel empty: the plan of the GPU compositor's Warp where the Newton iterations must run
|
||||
/// in f64 to land on the CPU's pixels (strong Fisheye / Twist bends).
|
||||
pub fn warp_inverse_map(ctx: &EffectCtx, b: &Buf, w: u32, h: u32) -> Image {
|
||||
let f = warp_inverse(ctx, b);
|
||||
crate::util::gen_image(w, h, |x, y| match f(x as f64 + 0.5, y as f64 + 0.5) {
|
||||
Some((sx, sy)) => [sx as f32, sy as f32, 1.0, 0.0],
|
||||
None => [0.0; 4],
|
||||
})
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- Detail-preserving Upscale
|
||||
|
||||
@@ -75,7 +75,7 @@ pub use color2::{Curve, auto_correct_settings, color_link_mode, color_link_sampl
|
||||
pub use color3::OffsetCurve;
|
||||
pub use distort::transform_shutter;
|
||||
pub use distort2::{MAGNIFY_MODES, bezier_grid, parse_mesh};
|
||||
pub use distort3::{RESHAPE_POINTS, ReshapeSetup, SmearSetup, reshape_setup, smear_setup};
|
||||
pub use distort3::{RESHAPE_POINTS, ReshapeSetup, SmearSetup, reshape_setup, smear_setup, warp_inverse_map};
|
||||
pub use distort4::liquify_mesh;
|
||||
use effectcraft_keyframe::Value;
|
||||
use effectcraft_project::build::Ids;
|
||||
@@ -83,7 +83,7 @@ use effectcraft_project::{GroupKind, ParamUi, PropGroup, Property};
|
||||
pub use effectcraft_raster::{AuxChannels, Image};
|
||||
pub use misc::{INVERT_ALPHA, INVERT_CHANNELS, glow_ab_t, glow_operation};
|
||||
pub use sim::particle_state;
|
||||
pub use sim3::playground_state;
|
||||
pub use sim3::{PgBlit, PgPlan, playground_plan, playground_state};
|
||||
pub use stylize2::strobe_on;
|
||||
// CPU helpers the GPU kernels share (effectcraft-gpu).
|
||||
pub use blur2::{camera_lens_plain, camera_lens_spans};
|
||||
@@ -109,7 +109,10 @@ pub use ocio::color_stabilizer_maps;
|
||||
pub use channel3d::{CRYPTO_LAYERS, id_color, selection_hashes};
|
||||
pub use ocio::{ColorOp, Straight, Tf, color_program};
|
||||
pub use sim::{Acc, Blob, Bubble, Post, Shape, Sprite, SpritePlan, Tint, bubble_list, drizzle_drops, mercury_blobs, sprite_plan};
|
||||
pub use sim2::{CausticsSetup, Piece, PiecePlan, PieceTex, WavePlan, Waves, caustics_setup, piece_plan, wave_world_plan};
|
||||
pub use sim2::{
|
||||
CausticsSetup, FoamDisc, FoamEnv, FoamPlan, Piece, PiecePlan, PieceTex, PixelPlan, WavePlan, Waves, caustics_setup, foam_full_plan, piece_plan, pixel_plan,
|
||||
wave_world_plan,
|
||||
};
|
||||
pub use utility::{Lut, load_lut};
|
||||
pub use vr::{equi_dir as vr_equi_dir, rotation as vr_rotation};
|
||||
|
||||
@@ -990,6 +993,14 @@ pub const GPU_EFFECTS: &[&str] = &[
|
||||
"ec.sim.shatter",
|
||||
"ec.sim.carddance",
|
||||
"ec.transition.cardwipe",
|
||||
// effectcraft-gpu fx_particles (particle render passes)
|
||||
"ec.sim.ccparticleworld",
|
||||
"ec.sim.ccparticlesystems2",
|
||||
"ec.sim.particleplayground",
|
||||
"ec.sim.ccballaction",
|
||||
"ec.sim.ccpixelpolly",
|
||||
"ec.sim.ccscatterize",
|
||||
"ec.noise.curlnoise",
|
||||
// effectcraft-gpu fx_light (the CC light family)
|
||||
"ec.generate.cclightrays",
|
||||
"ec.generate.cclightburst",
|
||||
|
||||
+106
-15
@@ -888,6 +888,88 @@ pub enum ColorOp {
|
||||
/// A LUT (0 nearest, 1 trilinear, 2 tetrahedral) with an optional per-channel shaper, forward
|
||||
/// or inverse (as [`FileXform::apply`]).
|
||||
Lut { lut: Arc<Lut>, shaper: Option<Arc<[Vec<(f32, f32)>; 3]>>, interp: u32, inverse: bool },
|
||||
/// `m × (c + pre) + post` (a custom config's MatrixTransform and RangeTransform).
|
||||
Affine { m: [[f32; 3]; 3], pre: [f32; 3], post: [f32; 3] },
|
||||
/// `max(c, 0) ^ p` per channel (ExponentTransform).
|
||||
Pow([f32; 3]),
|
||||
/// LogTransform / LogAffineTransform, forward or inverse (as `ocio_config::Xf::apply`).
|
||||
LogAffine { base: f32, log_slope: [f32; 3], log_offset: [f32; 3], lin_slope: [f32; 3], lin_offset: [f32; 3], inverse: bool },
|
||||
}
|
||||
|
||||
/// The ops of a LUT / CDL file transform (as [`FileXform::apply`]).
|
||||
fn file_ops(x: &FileXform, interp: u32, inverse: bool, ccc_id: &str, ops: &mut Vec<ColorOp>) {
|
||||
match x {
|
||||
FileXform::Cdl(list) => {
|
||||
let cdl = list.iter().find(|(i, _)| !ccc_id.is_empty() && i == ccc_id).or(list.first()).map(|(_, c)| *c).unwrap_or_default();
|
||||
ops.push(ColorOp::Cdl { cdl, clamp: true, inverse });
|
||||
}
|
||||
FileXform::Lut { lut, shaper } => {
|
||||
ops.push(ColorOp::Lut { lut: Arc::new(lut.clone()), shaper: shaper.clone().map(Arc::new), interp, inverse });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The ops of a custom config's transform `x` (as `Xf::apply`).
|
||||
fn config_xf_ops(x: &crate::ocio_config::Xf, inverse: bool, ops: &mut Vec<ColorOp>) {
|
||||
use crate::ocio_config::Xf;
|
||||
let f3 = |v: &[f64; 3]| v.map(|x| x as f32);
|
||||
match x {
|
||||
Xf::Inverse(x) => config_xf_ops(x, !inverse, ops),
|
||||
Xf::Matrix { m, offset } => {
|
||||
if !inverse {
|
||||
let m = [0, 1, 2].map(|r| [m[r * 4] as f32, m[r * 4 + 1] as f32, m[r * 4 + 2] as f32]);
|
||||
ops.push(ColorOp::Affine { m, pre: [0.0; 3], post: [offset[0] as f32, offset[1] as f32, offset[2] as f32] });
|
||||
} else if let Some(inv) = crate::ocio_config::mat3_inverse(m) {
|
||||
let m = inv.map(|r| r.map(|v| v as f32));
|
||||
ops.push(ColorOp::Affine { m, pre: [-offset[0] as f32, -offset[1] as f32, -offset[2] as f32], post: [0.0; 3] });
|
||||
}
|
||||
}
|
||||
Xf::File { xf: Some(x), interp, ccc, .. } => file_ops(x, *interp, inverse, ccc, ops),
|
||||
Xf::File { xf: None, .. } | Xf::Unsupported(_) => {}
|
||||
Xf::Exponent(e) => ops.push(ColorOp::Pow([0, 1, 2].map(|k| (if inverse { 1.0 / e[k].max(1e-9) } else { e[k] }) as f32))),
|
||||
Xf::Log { base } => {
|
||||
ops.push(ColorOp::LogAffine { base: *base as f32, log_slope: [1.0; 3], log_offset: [0.0; 3], lin_slope: [1.0; 3], lin_offset: [0.0; 3], inverse })
|
||||
}
|
||||
Xf::LogAffine { base, log_slope, log_offset, lin_slope, lin_offset } => ops.push(ColorOp::LogAffine {
|
||||
base: *base as f32,
|
||||
log_slope: f3(log_slope),
|
||||
log_offset: f3(log_offset),
|
||||
lin_slope: f3(lin_slope),
|
||||
lin_offset: f3(lin_offset),
|
||||
inverse,
|
||||
}),
|
||||
Xf::Cdl(cdl) => ops.push(ColorOp::Cdl { cdl: *cdl, clamp: true, inverse }),
|
||||
Xf::Range { min_in, max_in, min_out, max_out } => {
|
||||
let (a0, a1, b0, b1) = if inverse { (*min_out, *max_out, *min_in, *max_in) } else { (*min_in, *max_in, *min_out, *max_out) };
|
||||
let k = if (a1 - a0).abs() > 1e-12 { (b1 - b0) / (a1 - a0) } else { 0.0 };
|
||||
let k = k as f32;
|
||||
ops.push(ColorOp::Affine { m: [[k, 0.0, 0.0], [0.0, k, 0.0], [0.0, 0.0, k]], pre: [-a0 as f32; 3], post: [b0 as f32; 3] });
|
||||
}
|
||||
Xf::Group(list) => {
|
||||
if inverse {
|
||||
list.iter().rev().for_each(|x| config_xf_ops(x, true, ops));
|
||||
} else {
|
||||
list.iter().for_each(|x| config_xf_ops(x, false, ops));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The ops of a custom config's conversion from space `a` to space `z` (as `Config::convert`).
|
||||
fn config_ops(a: &crate::ocio_config::ConfigSpace, z: &crate::ocio_config::ConfigSpace, ops: &mut Vec<ColorOp>) {
|
||||
if a.is_data || z.is_data || a.name == z.name {
|
||||
return;
|
||||
}
|
||||
match (&a.to_ref, &a.from_ref) {
|
||||
(Some(x), _) => config_xf_ops(x, false, ops),
|
||||
(None, Some(x)) => config_xf_ops(x, true, ops),
|
||||
_ => {}
|
||||
}
|
||||
match (&z.from_ref, &z.to_ref) {
|
||||
(Some(x), _) => config_xf_ops(x, false, ops),
|
||||
(None, Some(x)) => config_xf_ops(x, true, ops),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// How a colour program meets premultiplied pixels.
|
||||
@@ -912,8 +994,8 @@ fn xform_ops(x: &Xform, ops: &mut Vec<ColorOp>) {
|
||||
}
|
||||
|
||||
/// Effect `id`'s per-pixel transform as a list of [`ColorOp`]s that reproduces the CPU effect
|
||||
/// (empty = the layer passes through). `None` when it has no such form (a custom OCIO config,
|
||||
/// another effect).
|
||||
/// (empty = the layer passes through; custom OCIO configs compile their transforms too). `None`
|
||||
/// for another effect.
|
||||
pub fn color_program(id: &str, ctx: &EffectCtx) -> Option<(Vec<ColorOp>, Straight)> {
|
||||
let pr = ctx.params;
|
||||
let mut ops = vec![];
|
||||
@@ -926,7 +1008,16 @@ pub fn color_program(id: &str, ctx: &EffectCtx) -> Option<(Vec<ColorOp>, Straigh
|
||||
}
|
||||
"ec.color.ociocolorspace" => {
|
||||
if pr.e("config") == 1 {
|
||||
return custom_config(ctx).is_none().then_some((ops, Straight::Unpremul));
|
||||
// A custom config (one that can't be read, or names unknown spaces: the pixels
|
||||
// pass through).
|
||||
if let Some(cfg) = custom_config(ctx)
|
||||
&& let (Some(a), Some(z)) =
|
||||
(custom_space(&cfg, pr.s("sourceName"), pr.e("source")), custom_space(&cfg, pr.s("destinationName"), pr.e("destination")))
|
||||
{
|
||||
let (a, z) = if pr.e("direction") == 1 { (z, a) } else { (a, z) };
|
||||
config_ops(a, z, &mut ops);
|
||||
}
|
||||
return Some((ops, Straight::Unpremul));
|
||||
}
|
||||
let (a, z) = (space_at(pr.e("source")), space_at(pr.e("destination")));
|
||||
let (a, z) = if pr.e("direction") == 1 { (z, a) } else { (a, z) };
|
||||
@@ -942,7 +1033,17 @@ pub fn color_program(id: &str, ctx: &EffectCtx) -> Option<(Vec<ColorOp>, Straigh
|
||||
}
|
||||
"ec.color.ociodisplay" => {
|
||||
if pr.e("config") == 1 {
|
||||
return custom_config(ctx).is_none().then_some((ops, Straight::Unpremul));
|
||||
if let Some(cfg) = custom_config(ctx) {
|
||||
let display = DISPLAYS.get(pr.e("display") as usize).map_or("", |d| d.0);
|
||||
let view = VIEWS.get(pr.e("view") as usize).copied().unwrap_or("");
|
||||
let dn = if pr.s("displayName").is_empty() { display } else { pr.s("displayName") };
|
||||
let vn = if pr.s("viewName").is_empty() { view } else { pr.s("viewName") };
|
||||
if let (Some(a), Some(z)) = (custom_space(&cfg, pr.s("sourceName"), pr.e("source")), cfg.view_space(dn, vn)) {
|
||||
let (a, z) = if pr.e("direction") == 1 { (z, a) } else { (a, z) };
|
||||
config_ops(a, z, &mut ops);
|
||||
}
|
||||
}
|
||||
return Some((ops, Straight::Unpremul));
|
||||
}
|
||||
let input = space_at(pr.e("source"));
|
||||
let (display, view, inverse) = (pr.e("display") as usize, pr.e("view") as usize, pr.e("direction") == 1);
|
||||
@@ -974,17 +1075,7 @@ pub fn color_program(id: &str, ctx: &EffectCtx) -> Option<(Vec<ColorOp>, Straigh
|
||||
1 => 1,
|
||||
_ => 2,
|
||||
};
|
||||
let inverse = pr.e("direction") == 1;
|
||||
match &*x {
|
||||
FileXform::Cdl(list) => {
|
||||
let id = pr.s("cccId");
|
||||
let cdl = list.iter().find(|(i, _)| !id.is_empty() && i == id).or(list.first()).map(|(_, c)| *c).unwrap_or_default();
|
||||
ops.push(ColorOp::Cdl { cdl, clamp: true, inverse });
|
||||
}
|
||||
FileXform::Lut { lut, shaper } => {
|
||||
ops.push(ColorOp::Lut { lut: Arc::new(lut.clone()), shaper: shaper.clone().map(Arc::new), interp, inverse });
|
||||
}
|
||||
}
|
||||
file_ops(&x, interp, pr.e("direction") == 1, pr.s("cccId"), &mut ops);
|
||||
}
|
||||
}
|
||||
"ec.color.ociolook" => {
|
||||
|
||||
@@ -439,7 +439,7 @@ fn mat_apply(m: &[f64; 16], off: &[f64; 4], c: [f64; 3]) -> [f64; 3] {
|
||||
[0, 1, 2].map(|r| m[r * 4] * c[0] + m[r * 4 + 1] * c[1] + m[r * 4 + 2] * c[2] + off[r])
|
||||
}
|
||||
|
||||
fn mat3_inverse(m: &[f64; 16]) -> Option<[[f64; 3]; 3]> {
|
||||
pub(crate) fn mat3_inverse(m: &[f64; 16]) -> Option<[[f64; 3]; 3]> {
|
||||
let a = [[m[0], m[1], m[2]], [m[4], m[5], m[6]], [m[8], m[9], m[10]]];
|
||||
let det = a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) - a[0][1] * (a[1][0] * a[2][2] - a[1][2] * a[2][0])
|
||||
+ a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0]);
|
||||
|
||||
+32
-26
@@ -268,6 +268,8 @@ pub fn sprite_plan(id: &str, ctx: &EffectCtx, b: &Buf) -> Option<SpritePlan> {
|
||||
crate::sim2::WavePlan::Height { .. } => None,
|
||||
}),
|
||||
"ec.sim.foam" => crate::sim2::foam_plan(ctx, b),
|
||||
"ec.sim.ccparticleworld" => particle_world_plan(ctx, b),
|
||||
"ec.sim.ccparticlesystems2" => Some(particle_systems2_plan(ctx, b)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -1059,12 +1061,20 @@ fn pw_phys(ctx: &EffectCtx) -> Phys {
|
||||
}
|
||||
}
|
||||
|
||||
fn particle_world(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
fn particle_world(ctx: &EffectCtx, b: Buf) -> Buf {
|
||||
match particle_world_plan(ctx, &b) {
|
||||
Some(plan) => plan.finish(b),
|
||||
None => b,
|
||||
}
|
||||
}
|
||||
|
||||
/// CC Particle World's sprites (far to near), `None` before anything is born.
|
||||
fn particle_world_plan(ctx: &EffectCtx, b: &Buf) -> Option<SpritePlan> {
|
||||
let pr = ctx.params;
|
||||
let (lw, lh) = (ctx.layer_size[0] as f32, ctx.layer_size[1] as f32);
|
||||
let phys = pw_phys(ctx);
|
||||
if phys.rate <= 0.0 && ctx.time <= 0.0 {
|
||||
return b;
|
||||
return None;
|
||||
}
|
||||
let key = params_key(ctx, &Buf { img: Image::new(0, 0), offset: [0.0; 2], scale: 1.0 }, 1);
|
||||
let st = accelerated(ctx, key, &phys).unwrap_or_else(|| simulate(&PW_CACHE, key, ctx.time, &phys));
|
||||
@@ -1097,20 +1107,24 @@ fn particle_world(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
.collect();
|
||||
list.sort_by(|a, b| b.0.total_cmp(&a.0));
|
||||
let sprites: Vec<Sprite> = list.into_iter().map(|(_, s)| s).collect();
|
||||
let mode = pr.e("particle/transferMode");
|
||||
let fx = splat(b.img.width, b.img.height, &sprites, if mode == 2 { Acc::Add } else { Acc::Over });
|
||||
b.img = combine(
|
||||
&b.img,
|
||||
&fx,
|
||||
match mode {
|
||||
Some(particle_sprites(sprites, pr.e("particle/transferMode")))
|
||||
}
|
||||
|
||||
/// The CC particle systems' sprites with their Transfer Mode (Composite, Screen, Add, Black
|
||||
/// Background).
|
||||
fn particle_sprites(sprites: Vec<Sprite>, mode: u32) -> SpritePlan {
|
||||
SpritePlan {
|
||||
sprites,
|
||||
tints: vec![],
|
||||
acc: if mode == 2 { Acc::Add } else { Acc::Over },
|
||||
post: Post::Combine(match mode {
|
||||
0 => 0,
|
||||
1 => 1,
|
||||
2 => 2,
|
||||
3 => 5,
|
||||
_ => 0,
|
||||
},
|
||||
);
|
||||
b
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ CC Particle Systems II
|
||||
@@ -1143,7 +1157,12 @@ fn ps2_phys(ctx: &EffectCtx) -> Phys {
|
||||
}
|
||||
}
|
||||
|
||||
fn particle_systems2(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
fn particle_systems2(ctx: &EffectCtx, b: Buf) -> Buf {
|
||||
particle_systems2_plan(ctx, &b).finish(b)
|
||||
}
|
||||
|
||||
/// CC Particle Systems II's sprites.
|
||||
fn particle_systems2_plan(ctx: &EffectCtx, b: &Buf) -> SpritePlan {
|
||||
let pr = ctx.params;
|
||||
let lh = ctx.layer_size[1] as f32;
|
||||
let unit = lh.max(1.0);
|
||||
@@ -1167,20 +1186,7 @@ fn particle_systems2(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
type_sprite(kind, bx as f32, by as f32, r, c, q.v[0] * unit * s, q.v[1] * unit * s, (q.id % 628) as f32 * 0.01 + q.age * 2.0)
|
||||
})
|
||||
.collect();
|
||||
let mode = pr.e("particle/transferMode");
|
||||
let fx = splat(b.img.width, b.img.height, &sprites, if mode == 2 { Acc::Add } else { Acc::Over });
|
||||
b.img = combine(
|
||||
&b.img,
|
||||
&fx,
|
||||
match mode {
|
||||
0 => 0,
|
||||
1 => 1,
|
||||
2 => 2,
|
||||
3 => 5,
|
||||
_ => 0,
|
||||
},
|
||||
);
|
||||
b
|
||||
particle_sprites(sprites, pr.e("particle/transferMode"))
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ CC Mr. Mercury
|
||||
|
||||
+176
-90
@@ -12,7 +12,7 @@ use rayon::prelude::*;
|
||||
|
||||
use crate::card3d::{Lighting, Proj};
|
||||
use crate::generate::value_noise;
|
||||
use crate::sim::{Acc, Shape, Sprite, h, hs, pct, pt, raster, spec, splat};
|
||||
use crate::sim::{Acc, Post, Shape, Sprite, SpritePlan, h, hs, pct, pt, raster, spec, splat};
|
||||
use crate::util::{Plane, SimCache, gauss_plane, layer_or_self, params_key, unpremul};
|
||||
use crate::{Buf, EffectCtx, EffectSpec, col, num, p, popup, slider};
|
||||
|
||||
@@ -146,7 +146,10 @@ impl PiecePlan {
|
||||
pub fn piece_plan(id: &str, ctx: &EffectCtx, b: &Buf) -> Option<PiecePlan> {
|
||||
match id {
|
||||
"ec.sim.carddance" => Some(card_dance_plan(ctx, b)),
|
||||
"ec.sim.shatter" if ctx.params.e("view") == 0 => shatter_impl(ctx, b, true).err(),
|
||||
"ec.sim.shatter" if ctx.params.e("view") == 0 => match shatter_impl(ctx, b) {
|
||||
ShatterPlan::Pieces(plan) => Some(plan),
|
||||
ShatterPlan::Wire(_) => None,
|
||||
},
|
||||
"ec.transition.cardwipe" => crate::transition::card_wipe_plan(ctx, b),
|
||||
_ => None,
|
||||
}
|
||||
@@ -290,7 +293,12 @@ pub(crate) fn sort_far_first(pieces: &mut [Piece]) {
|
||||
|
||||
// ------------------------------------------------------------------ CC Ball Action
|
||||
|
||||
fn ball_action(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
fn ball_action(ctx: &EffectCtx, b: Buf) -> Buf {
|
||||
ball_action_plan(ctx, &b).finish(b)
|
||||
}
|
||||
|
||||
/// 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;
|
||||
let scatter = pr.f("scatter") as f32;
|
||||
let axis = pr.e("rotationAxis");
|
||||
@@ -307,7 +315,7 @@ fn ball_action(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
let ny = (lh / spacing).ceil().max(1.0) as u32;
|
||||
let d = 2.0 * lw.max(lh) as f64;
|
||||
let (cx, cy) = (lw as f64 * 0.5, lh as f64 * 0.5);
|
||||
let src = b.img.clone();
|
||||
let src = &b.img;
|
||||
let ax: [f64; 3] = match axis {
|
||||
0 => [1.0, 0.0, 0.0],
|
||||
1 => [0.0, 1.0, 0.0],
|
||||
@@ -353,17 +361,24 @@ fn ball_action(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
.collect();
|
||||
balls.sort_by(|a, b| b.0.total_cmp(&a.0));
|
||||
let sprites: Vec<Sprite> = balls.into_iter().map(|(_, s)| s).collect();
|
||||
b.img = splat(src.width, src.height, &sprites, Acc::Over);
|
||||
b
|
||||
SpritePlan { sprites, tints: vec![], acc: Acc::Over, post: Post::Replace }
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ CC Pixel Polly
|
||||
|
||||
fn pixel_polly(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
fn pixel_polly(ctx: &EffectCtx, b: Buf) -> Buf {
|
||||
match pixel_polly_plan(ctx, &b) {
|
||||
Some(plan) => plan.finish(b),
|
||||
None => b,
|
||||
}
|
||||
}
|
||||
|
||||
/// CC Pixel Polly's pieces, `None` before Start Time (the layer as is).
|
||||
fn pixel_polly_plan(ctx: &EffectCtx, b: &Buf) -> Option<PiecePlan> {
|
||||
let pr = ctx.params;
|
||||
let t = ctx.time - pr.f("startTime");
|
||||
if t <= 0.0 {
|
||||
return b;
|
||||
return None;
|
||||
}
|
||||
let force = pr.f("force");
|
||||
let gravity = pr.f("gravity");
|
||||
@@ -383,7 +398,7 @@ fn pixel_polly(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
let tri = object <= 1;
|
||||
let textured = object == 1 || object == 3;
|
||||
let maxd = lw.max(lh);
|
||||
let src = b.img.clone();
|
||||
let src = &b.img;
|
||||
let per = if tri { 2 } else { 1 };
|
||||
let mut pieces: Vec<Piece> = (0..nx * ny * per)
|
||||
.into_par_iter()
|
||||
@@ -425,21 +440,26 @@ fn pixel_polly(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
if depth_sort {
|
||||
sort_far_first(&mut pieces);
|
||||
}
|
||||
let mut out = Image::new(src.width, src.height);
|
||||
draw_pieces(&mut out, &pieces, &src, None);
|
||||
b.img = out;
|
||||
b
|
||||
Some(PiecePlan { pieces, front: PieceTex::Layer, back: None })
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ CC Scatterize
|
||||
|
||||
fn scatterize(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
fn scatterize(ctx: &EffectCtx, b: Buf) -> Buf {
|
||||
match scatterize_plan(ctx, &b) {
|
||||
Some(plan) => plan.finish(b),
|
||||
None => b,
|
||||
}
|
||||
}
|
||||
|
||||
/// CC Scatterize's pixel dots, `None` when nothing moves (the layer as is).
|
||||
fn scatterize_plan(ctx: &EffectCtx, b: &Buf) -> Option<SpritePlan> {
|
||||
let pr = ctx.params;
|
||||
let scatter = pr.f("scatter") as f32;
|
||||
let right = pr.f("rightTwist").to_radians();
|
||||
let left = pr.f("leftTwist").to_radians();
|
||||
if scatter == 0.0 && right == 0.0 && left == 0.0 {
|
||||
return b;
|
||||
return None;
|
||||
}
|
||||
let add = pr.e("transferMode") == 1;
|
||||
let seed = ctx.seed.wrapping_mul(0x7feb352d);
|
||||
@@ -471,8 +491,29 @@ fn scatterize(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
Some(Sprite::new(sx as f32, sy as f32, 0.6 * persp as f32, [c[0], c[1], c[2], a], Shape::Disc))
|
||||
})
|
||||
.collect();
|
||||
b.img = splat(w, hh, &sprites, if add { Acc::Add } else { Acc::Over });
|
||||
b
|
||||
Some(SpritePlan { sprites, tints: vec![], acc: if add { Acc::Add } else { Acc::Over }, post: Post::Replace })
|
||||
}
|
||||
|
||||
/// What a particle effect that reads the layer's pixels draws this frame (CC Ball Action, CC
|
||||
/// Pixel Polly, CC Scatterize, Shatter's wireframe views), for layer `b`; `None` for other
|
||||
/// effects or a frame showing the layer as is.
|
||||
pub enum PixelPlan {
|
||||
Sprites(SpritePlan),
|
||||
Pieces(PiecePlan),
|
||||
}
|
||||
|
||||
/// The [`PixelPlan`] of effect `id` for layer `b` (its pixels are read).
|
||||
pub fn pixel_plan(id: &str, ctx: &EffectCtx, b: &Buf) -> Option<PixelPlan> {
|
||||
match id {
|
||||
"ec.sim.ccballaction" => Some(PixelPlan::Sprites(ball_action_plan(ctx, b))),
|
||||
"ec.sim.ccpixelpolly" => pixel_polly_plan(ctx, b).map(PixelPlan::Pieces),
|
||||
"ec.sim.ccscatterize" => scatterize_plan(ctx, b).map(PixelPlan::Sprites),
|
||||
"ec.sim.shatter" => Some(match shatter_impl(ctx, b) {
|
||||
ShatterPlan::Pieces(plan) => PixelPlan::Pieces(plan),
|
||||
ShatterPlan::Wire(plan) => PixelPlan::Sprites(plan),
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ Card Dance
|
||||
@@ -686,14 +727,19 @@ fn map_key(c: [f32; 4]) -> u32 {
|
||||
}
|
||||
|
||||
fn shatter(ctx: &EffectCtx, b: Buf) -> Buf {
|
||||
match shatter_impl(ctx, &b, false) {
|
||||
Ok(img) => Buf { img, ..b },
|
||||
Err(plan) => plan.finish(b),
|
||||
match shatter_impl(ctx, &b) {
|
||||
ShatterPlan::Pieces(plan) => plan.finish(b),
|
||||
ShatterPlan::Wire(plan) => plan.finish(b),
|
||||
}
|
||||
}
|
||||
|
||||
/// Shatter: the frame (`Ok`), or with `plan_only` in the Rendered view its pieces (`Err`).
|
||||
fn shatter_impl(ctx: &EffectCtx, b: &Buf, plan_only: bool) -> Result<Image, PiecePlan> {
|
||||
/// What Shatter draws: the pieces (Rendered view) or the wireframe lines.
|
||||
enum ShatterPlan {
|
||||
Pieces(PiecePlan),
|
||||
Wire(SpritePlan),
|
||||
}
|
||||
|
||||
fn shatter_impl(ctx: &EffectCtx, b: &Buf) -> ShatterPlan {
|
||||
let pr = ctx.params;
|
||||
let view = pr.e("view");
|
||||
let render = pr.e("render");
|
||||
@@ -770,7 +816,6 @@ fn shatter_impl(ctx: &EffectCtx, b: &Buf, plan_only: bool) -> Result<Image, Piec
|
||||
e.1 += 1.0;
|
||||
}
|
||||
let g3 = [gdir.sin() * ginc.cos() * gravity * unit, -gdir.cos() * ginc.cos() * gravity * unit, ginc.sin() * gravity * unit];
|
||||
let src = b.img.clone();
|
||||
let mut pieces: Vec<Piece> = polys
|
||||
.par_iter()
|
||||
.zip(keys.par_iter())
|
||||
@@ -902,13 +947,8 @@ fn shatter_impl(ctx: &EffectCtx, b: &Buf, plan_only: bool) -> Result<Image, Piec
|
||||
let tex = |i: &Option<Image>| i.clone().map(PieceTex::Image);
|
||||
let front_t = tex(&front.img).unwrap_or(PieceTex::Layer);
|
||||
let back_t = tex(&backf.img).unwrap_or_else(|| front_t.clone());
|
||||
let plan = PiecePlan { pieces, front: front_t, back: Some(back_t) };
|
||||
if plan_only {
|
||||
return Err(plan);
|
||||
}
|
||||
return Ok(plan.finish(Buf { img: src, offset: b.offset, scale: b.scale }).img);
|
||||
return ShatterPlan::Pieces(PiecePlan { pieces, front: front_t, back: Some(back_t) });
|
||||
}
|
||||
let out;
|
||||
{
|
||||
// Wireframes: piece outlines (front view: at rest; otherwise animated), plus forces.
|
||||
let animated = view == 2 || view == 4;
|
||||
@@ -948,9 +988,8 @@ fn shatter_impl(ctx: &EffectCtx, b: &Buf, plan_only: bool) -> Result<Image, Piec
|
||||
}
|
||||
}
|
||||
}
|
||||
out = splat(src.width, src.height, &lines, Acc::Over);
|
||||
ShatterPlan::Wire(SpritePlan { sprites: lines, tints: vec![], acc: Acc::Over, post: Post::Replace })
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ Caustics
|
||||
@@ -1516,22 +1555,97 @@ fn foam_pop_age(id: u32, lifespan: f32, frailty: f32, seed: u32) -> f32 {
|
||||
/// neighbours away at Pop Velocity. Rendered bubbles use a built-in texture or the Bubble
|
||||
/// Texture Layer, oriented by Bubble Orientation, and reflect the Environment Map.
|
||||
fn foam(ctx: &EffectCtx, b: Buf) -> Buf {
|
||||
match foam_impl(ctx, &b, false) {
|
||||
Ok(img) => Buf { img, ..b },
|
||||
Err(plan) => plan.finish(b),
|
||||
}
|
||||
foam_full_plan(ctx, &b).finish(b)
|
||||
}
|
||||
|
||||
/// Foam's bubbles as sprites, `None` when it draws more than sprites (a User Defined bubble
|
||||
/// texture, an Environment Map reflection or the Draft + Flow Map view's flow map).
|
||||
pub(crate) fn foam_plan(ctx: &EffectCtx, b: &Buf) -> Option<crate::sim::SpritePlan> {
|
||||
if !crate::catalog::gpu_supported("ec.sim.foam", ctx) {
|
||||
return None;
|
||||
}
|
||||
foam_impl(ctx, b, true).err()
|
||||
let plan = foam_full_plan(ctx, b);
|
||||
(plan.user.is_none() && plan.env.is_none() && plan.flow.is_none()).then_some(plan.sprites)
|
||||
}
|
||||
|
||||
fn foam_impl(ctx: &EffectCtx, b: &Buf, plan_only: bool) -> Result<Image, crate::sim::SpritePlan> {
|
||||
/// A bubble disc filled by Foam's User Defined texture (buffer px; `rot` radians).
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct FoamDisc {
|
||||
pub x: f64,
|
||||
pub y: f64,
|
||||
pub r: f32,
|
||||
pub rot: f32,
|
||||
pub fade: f32,
|
||||
}
|
||||
|
||||
/// Foam's Environment Map reflection: the map fitted to the buffer, Reflection Convergence and
|
||||
/// Strength, and the bubble discs reflecting it (`rot` and `fade` unused).
|
||||
pub struct FoamEnv {
|
||||
pub img: Image,
|
||||
pub conv: f64,
|
||||
pub strength: f32,
|
||||
pub discs: Vec<FoamDisc>,
|
||||
}
|
||||
|
||||
/// What Foam draws this frame over a transparent frame of the layer's size: the bubble sprites,
|
||||
/// then the User Defined texture's discs, the Environment Map's reflections and (Draft + Flow
|
||||
/// Map) the flow map under it all, each [`foam_disc`]-composited in bubble order.
|
||||
pub struct FoamPlan {
|
||||
pub sprites: crate::sim::SpritePlan,
|
||||
pub user: Option<(crate::LayerPixels, Vec<FoamDisc>)>,
|
||||
pub env: Option<FoamEnv>,
|
||||
/// The flow map fitted to the buffer.
|
||||
pub flow: Option<Image>,
|
||||
}
|
||||
|
||||
impl FoamPlan {
|
||||
pub fn finish(&self, b: Buf) -> Buf {
|
||||
let mut out = splat(b.img.width, b.img.height, &self.sprites.sprites, self.sprites.acc);
|
||||
// User Defined: the texture layer fills each bubble's disc.
|
||||
if let Some((tex, discs)) = &self.user {
|
||||
for d in discs {
|
||||
let (rot, fade) = (d.rot, d.fade);
|
||||
foam_disc(&mut out, d.x, d.y, d.r as f64, |u, v| {
|
||||
// u, v in −1..1 across the bubble, rotated into the texture.
|
||||
let (sr, cr) = rot.sin_cos();
|
||||
let (tu, tv) = (u as f32 * cr + v as f32 * sr, -u as f32 * sr + v as f32 * cr);
|
||||
let (x, y) = ((tu as f64 * 0.5 + 0.5) * tex.size[0], (tv as f64 * 0.5 + 0.5) * tex.size[1]);
|
||||
let px = tex.buf.img.sample_bilinear(x * tex.buf.scale + tex.buf.offset[0], y * tex.buf.scale + tex.buf.offset[1]);
|
||||
px.map(|c| c * fade)
|
||||
});
|
||||
}
|
||||
}
|
||||
// Environment Map: each bubble reflects the map along its sphere normal (Reflection
|
||||
// Convergence pulls the reflection towards the bubble's own spot of the map).
|
||||
if let Some(env) = &self.env {
|
||||
let (conv, strength) = (env.conv, env.strength);
|
||||
let (w, h) = (b.img.width as f64, b.img.height as f64);
|
||||
for d in &env.discs {
|
||||
let (bx, by) = (d.x, d.y);
|
||||
foam_disc(&mut out, bx, by, d.r as f64, |u, v| {
|
||||
// Sphere normal; the reflection looks across the whole map, or (convergence 1)
|
||||
// just behind the bubble.
|
||||
let (ex, ey) =
|
||||
if conv >= 1.0 { (bx, by) } else { (bx * conv + (u * 0.5 + 0.5) * w * (1.0 - conv), by * conv + (v * 0.5 + 0.5) * h * (1.0 - conv)) };
|
||||
let e = env.img.sample_bilinear(ex, ey);
|
||||
let rim = ((u * u + v * v) as f32).min(1.0);
|
||||
let k = strength * (0.3 + 0.7 * rim);
|
||||
[e[0] * k, e[1] * k, e[2] * k, 0.0]
|
||||
});
|
||||
}
|
||||
}
|
||||
// Draft + Flow Map shows the flow map under the bubbles.
|
||||
if let Some(fm) = &self.flow {
|
||||
out.data.par_iter_mut().zip(fm.data.par_iter()).for_each(|(o, f)| {
|
||||
let k = 1.0 - o[3];
|
||||
for c in 0..4 {
|
||||
o[c] += f[c] * 0.5 * k;
|
||||
}
|
||||
});
|
||||
}
|
||||
Buf { img: out, ..b }
|
||||
}
|
||||
}
|
||||
|
||||
/// Foam's [`FoamPlan`] for layer geometry `b` (its size; its pixels are not read).
|
||||
pub fn foam_full_plan(ctx: &EffectCtx, b: &Buf) -> FoamPlan {
|
||||
let pr = ctx.params;
|
||||
let (lw, lh) = (ctx.layer_size[0] as f32, ctx.layer_size[1] as f32);
|
||||
let unit = lw * 0.01;
|
||||
@@ -1754,62 +1868,34 @@ fn foam_impl(ctx: &EffectCtx, b: &Buf, plan_only: bool) -> Result<Image, crate::
|
||||
})
|
||||
.collect();
|
||||
let acc = if blend == 0 && view == 2 { Acc::Add } else { Acc::Over };
|
||||
if plan_only {
|
||||
return Err(crate::sim::SpritePlan { sprites, tints: vec![], acc, post: crate::sim::Post::Replace });
|
||||
}
|
||||
let mut out = splat(b.img.width, b.img.height, &sprites, acc);
|
||||
// User Defined: the texture layer fills each bubble's disc.
|
||||
if let Some(tex) = &user_tex {
|
||||
for q in &order {
|
||||
let (bx, by, r, rot) = place(q);
|
||||
let fade = ((foam_pop_age(q.id, lifespan, frailty, seed) - q.age) / 5.0).clamp(0.0, 1.0);
|
||||
foam_disc(&mut out, bx, by, r as f64, |u, v| {
|
||||
// u, v in −1..1 across the bubble, rotated into the texture.
|
||||
let (sr, cr) = rot.sin_cos();
|
||||
let (tu, tv) = (u as f32 * cr + v as f32 * sr, -u as f32 * sr + v as f32 * cr);
|
||||
let (x, y) = ((tu as f64 * 0.5 + 0.5) * tex.size[0], (tv as f64 * 0.5 + 0.5) * tex.size[1]);
|
||||
let px = tex.buf.img.sample_bilinear(x * tex.buf.scale + tex.buf.offset[0], y * tex.buf.scale + tex.buf.offset[1]);
|
||||
px.map(|c| c * fade)
|
||||
});
|
||||
}
|
||||
}
|
||||
// Environment Map: each bubble reflects the map along its sphere normal (Reflection
|
||||
// Convergence pulls the reflection towards the bubble's own spot of the map).
|
||||
let disc = |q: &&FoamBubble| {
|
||||
let (x, y, r, rot) = place(q);
|
||||
let fade = ((foam_pop_age(q.id, lifespan, frailty, seed) - q.age) / 5.0).clamp(0.0, 1.0);
|
||||
FoamDisc { x, y, r, rot, fade }
|
||||
};
|
||||
let user = user_tex.map(|tex| (tex, order.iter().map(disc).collect()));
|
||||
let strength = pr.f("rendering/reflectionStrength").clamp(0.0, 1.0) as f32;
|
||||
if view == 2
|
||||
let env = if view == 2
|
||||
&& strength > 0.0
|
||||
&& let Some(env) = ctx.layer_param("rendering/environmentMap", true)
|
||||
{
|
||||
let env_img = crate::util::fit_layer(ctx, b, &env, true);
|
||||
let conv = pr.f("rendering/reflectionConvergence").clamp(0.0, 1.0);
|
||||
let (w, h) = (b.img.width as f64, b.img.height as f64);
|
||||
for q in &order {
|
||||
let (bx, by, r, _) = place(q);
|
||||
foam_disc(&mut out, bx, by, r as f64, |u, v| {
|
||||
// Sphere normal; the reflection looks across the whole map, or (convergence 1)
|
||||
// just behind the bubble.
|
||||
let (ex, ey) =
|
||||
if conv >= 1.0 { (bx, by) } else { (bx * conv + (u * 0.5 + 0.5) * w * (1.0 - conv), by * conv + (v * 0.5 + 0.5) * h * (1.0 - conv)) };
|
||||
let e = env_img.sample_bilinear(ex, ey);
|
||||
let rim = ((u * u + v * v) as f32).min(1.0);
|
||||
let k = strength * (0.3 + 0.7 * rim);
|
||||
[e[0] * k, e[1] * k, e[2] * k, 0.0]
|
||||
});
|
||||
}
|
||||
}
|
||||
// Draft + Flow Map shows the flow map under the bubbles.
|
||||
if view == 1
|
||||
Some(FoamEnv {
|
||||
img: crate::util::fit_layer(ctx, b, &env, true),
|
||||
conv: pr.f("rendering/reflectionConvergence").clamp(0.0, 1.0),
|
||||
strength,
|
||||
discs: order.iter().map(disc).collect(),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let flow = if view == 1
|
||||
&& let Some(lp) = &flow
|
||||
{
|
||||
let fm = crate::util::fit_layer(ctx, b, lp, true);
|
||||
out.data.par_iter_mut().zip(fm.data.par_iter()).for_each(|(o, f)| {
|
||||
let k = 1.0 - o[3];
|
||||
for c in 0..4 {
|
||||
o[c] += f[c] * 0.5 * k;
|
||||
}
|
||||
});
|
||||
}
|
||||
Ok(out)
|
||||
Some(crate::util::fit_layer(ctx, b, lp, true))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
FoamPlan { sprites: crate::sim::SpritePlan { sprites, tints: vec![], acc, post: crate::sim::Post::Replace }, user, env, flow }
|
||||
}
|
||||
|
||||
/// Add `f(u, v)` (premultiplied; u, v ∈ −1..1 across the disc) over the disc of radius `r` at
|
||||
|
||||
+55
-17
@@ -716,7 +716,12 @@ pub fn playground_state(ctx: &EffectCtx) -> Option<Vec<crate::psim::SimParticle>
|
||||
)
|
||||
}
|
||||
|
||||
fn particle_playground(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
fn particle_playground(ctx: &EffectCtx, b: Buf) -> Buf {
|
||||
playground_plan(ctx, &b).finish(b)
|
||||
}
|
||||
|
||||
/// Particle Playground's [`PgPlan`] for buffer geometry `b` (its pixels are not read).
|
||||
pub fn playground_plan(ctx: &EffectCtx, b: &Buf) -> PgPlan {
|
||||
let pr = ctx.params;
|
||||
let (lw, lh) = (ctx.layer_size[0] as f32, ctx.layer_size[1] as f32);
|
||||
let pg = pg_of(ctx);
|
||||
@@ -825,7 +830,6 @@ fn particle_playground(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
let offset_type = pr.e("layerMap/timeOffsetType");
|
||||
let offset = pr.f("layerMap/timeOffset");
|
||||
let fps = ctx.fps();
|
||||
let mut frames: std::collections::HashMap<i64, Option<crate::LayerPixels>> = std::collections::HashMap::new();
|
||||
let mut sprites: Vec<Sprite> = vec![];
|
||||
let mut blits: Vec<(PgParticle, i64)> = vec![];
|
||||
for q in &parts {
|
||||
@@ -869,30 +873,64 @@ fn particle_playground(ctx: &EffectCtx, mut b: Buf) -> Buf {
|
||||
None => sprites.push(Sprite::new(x as f32, y as f32, q.r * sc * s, q.c, Shape::Disc)),
|
||||
}
|
||||
}
|
||||
let mut fx = splat(b.img.width, b.img.height, &sprites, Acc::Over);
|
||||
let mut plan = PgPlan { sprites: SpritePlan { sprites, tints: vec![], acc: Acc::Over, post: Post::Combine(5) }, blits: vec![], frames: vec![] };
|
||||
if let (Some(id), Some(host)) = (map_id, ctx.env.host) {
|
||||
let me = pr.get(&crate::layer_source_id("layerMap/layerMapLayer")).is_none_or(|v| v.as_enum() != 0);
|
||||
// Fetched frames by frame number: their index in `plan.frames` (`None` = unavailable).
|
||||
let mut frames: std::collections::HashMap<i64, Option<usize>> = std::collections::HashMap::new();
|
||||
for (q, frame) in &blits {
|
||||
if !frames.contains_key(frame) && frames.len() >= 32 {
|
||||
let at = if !frames.contains_key(frame) && frames.len() >= 32 {
|
||||
// Too many distinct times: reuse the nearest fetched frame.
|
||||
if let Some(k) = frames.keys().min_by_key(|k| (*k - frame).abs()).copied()
|
||||
&& let Some(Some(lp)) = frames.get(&k)
|
||||
{
|
||||
let (x, y) = b.to_px([q.p[0] as f64, q.p[1] as f64]);
|
||||
blit_layer(&mut fx, lp, x, y, q.angle as f64, [q.scale[0] as f64, q.scale[1] as f64], b.scale, q.c[3]);
|
||||
match frames.keys().min_by_key(|k| (*k - frame).abs()).copied() {
|
||||
Some(k) => frames.get(&k).copied().flatten(),
|
||||
None => None,
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let lp = frames.entry(*frame).or_insert_with(|| host.layer_at(id, *frame as f64 / fps, me));
|
||||
if let Some(lp) = lp {
|
||||
} else {
|
||||
*frames.entry(*frame).or_insert_with(|| {
|
||||
let lp = host.layer_at(id, *frame as f64 / fps, me)?;
|
||||
plan.frames.push(lp);
|
||||
Some(plan.frames.len() - 1)
|
||||
})
|
||||
};
|
||||
if let Some(i) = at {
|
||||
let (x, y) = b.to_px([q.p[0] as f64, q.p[1] as f64]);
|
||||
blit_layer(&mut fx, lp, x, y, q.angle as f64, [q.scale[0] as f64, q.scale[1] as f64], b.scale, q.c[3]);
|
||||
plan.blits.push(PgBlit { frame: i, x, y, angle: q.angle as f64, scale: [q.scale[0] as f64, q.scale[1] as f64], alpha: q.c[3] });
|
||||
}
|
||||
}
|
||||
}
|
||||
// Particles replace the layer's own pixels.
|
||||
b.img = combine(&b.img, &fx, 5);
|
||||
b
|
||||
plan
|
||||
}
|
||||
|
||||
/// A Layer Map particle: frame `frame` of [`PgPlan::frames`] centred on (`x`, `y`) buffer px,
|
||||
/// rotated `angle` degrees, scaled and faded to `alpha`.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct PgBlit {
|
||||
pub frame: usize,
|
||||
pub x: f64,
|
||||
pub y: f64,
|
||||
pub angle: f64,
|
||||
pub scale: [f64; 2],
|
||||
pub alpha: f32,
|
||||
}
|
||||
|
||||
/// What Particle Playground draws this frame: the dot and text particles as sprites, then the
|
||||
/// Layer Map particles over them in order; the result replaces the layer's own pixels.
|
||||
pub struct PgPlan {
|
||||
pub sprites: SpritePlan,
|
||||
pub blits: Vec<PgBlit>,
|
||||
pub frames: Vec<crate::LayerPixels>,
|
||||
}
|
||||
|
||||
impl PgPlan {
|
||||
pub fn finish(&self, mut b: Buf) -> Buf {
|
||||
let mut fx = splat(b.img.width, b.img.height, &self.sprites.sprites, self.sprites.acc);
|
||||
for q in &self.blits {
|
||||
blit_layer(&mut fx, &self.frames[q.frame], q.x, q.y, q.angle, q.scale, b.scale, q.alpha);
|
||||
}
|
||||
// Particles replace the layer's own pixels.
|
||||
b.img = combine(&b.img, &fx, 5);
|
||||
b
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- CC Hair
|
||||
|
||||
+102
-117
@@ -680,18 +680,22 @@ fn fetch_layer(ctx: &EffectCtx, id: &str, times: &[f64], grid: &Buf) -> Option<V
|
||||
)
|
||||
}
|
||||
|
||||
/// One output instant of a Timewarp without a Matte Layer: a fetched frame, a cross-fade of two,
|
||||
/// or the in-between frame built along a motion field ([`TimewarpPlan::flows`]).
|
||||
/// One output instant of a Timewarp: a frame, a cross-fade of two, or the in-between frame
|
||||
/// built along a motion field ([`TimewarpPlan::flows`]); with a Matte Layer's Pixel Motion, the
|
||||
/// foreground and background pairs (`[frame a, frame b, flow]`) each built on their own vectors
|
||||
/// and shown as Show asks.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum TwStep {
|
||||
Whole(usize),
|
||||
Mix(usize, usize, f32),
|
||||
Motion { a: usize, b: usize, w: f32, flow: usize },
|
||||
Layered { fg: [usize; 3], bg: [usize; 3], w: f32, show: u32 },
|
||||
}
|
||||
|
||||
/// Timewarp without a Matte Layer, prepared for the GPU compositor (effectcraft-gpu `fx_time`):
|
||||
/// the fetched frames on one grid, the instants across the shutter (with their weights) and the
|
||||
/// motion fields (block matching on the CPU). [`TimewarpPlan::render_cpu`] is the CPU effect.
|
||||
/// Timewarp prepared for the GPU compositor (effectcraft-gpu `fx_time`): the fetched frames on
|
||||
/// one grid (plus the matte-masked ones a Matte Layer needs), the instants across the shutter
|
||||
/// (with their weights) and the motion fields (block matching on the CPU).
|
||||
/// [`TimewarpPlan::render_cpu`] is the CPU effect.
|
||||
pub struct TimewarpPlan {
|
||||
pub grid: Buf,
|
||||
pub frames: Vec<Image>,
|
||||
@@ -710,6 +714,11 @@ impl TimewarpPlan {
|
||||
TwStep::Whole(i) => f[i].clone(),
|
||||
TwStep::Mix(i, j, w) => effectcraft_raster::flow::mix(&f[i], &f[j], w),
|
||||
TwStep::Motion { a, b, w, flow } => timewarp_interpolate(&f[a], &f[b], w, &self.flows[flow], &self.pm),
|
||||
TwStep::Layered { fg, bg, w, show } => {
|
||||
let fgi = timewarp_interpolate(&f[fg[0]], &f[fg[1]], w, &self.flows[fg[2]], &self.pm);
|
||||
let bgi = timewarp_interpolate(&f[bg[0]], &f[bg[1]], w, &self.flows[bg[2]], &self.pm);
|
||||
layered(fgi, bgi, show)
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let weights: Vec<f32> = self.steps.iter().map(|(_, w)| *w).collect();
|
||||
@@ -758,48 +767,102 @@ fn tw_split(s: f64, fps: f64) -> (f64, f32) {
|
||||
(f0, ((f - f0) as f32).max(0.0))
|
||||
}
|
||||
|
||||
/// [`TimewarpPlan`] of a Timewarp instance without a Matte Layer. `None` without the effect host
|
||||
/// (the layer passes through) or with a Matte Layer.
|
||||
/// [`TimewarpPlan`] of a Timewarp instance. `None` without the effect host or source frames (the
|
||||
/// layer passes through). With a Matte Layer the frames the instants need (masked by the matte,
|
||||
/// or the matte itself for Show Matte) are prepared here and join [`TimewarpPlan::frames`].
|
||||
pub fn timewarp_plan(ctx: &EffectCtx) -> Option<TimewarpPlan> {
|
||||
ctx.env.host?;
|
||||
if ctx.params.get("matteLayer").and_then(Value::as_layer).is_some() {
|
||||
return None;
|
||||
}
|
||||
// Instants of source time (with weights) across the shutter; each needs the frame at or
|
||||
// before it and the next one.
|
||||
let (instants, times, fps) = timewarp_instants(ctx);
|
||||
let method = ctx.params.e("method");
|
||||
let one = method > 0 && ctx.params.b("tuning/buildFromOneImage");
|
||||
let fr = fetch(ctx, ×)?;
|
||||
let pm = PixelMotion::from(ctx, fr.grid.scale);
|
||||
let mattes = fetch_layer(ctx, "matteLayer", ×, &fr.grid);
|
||||
let warps = fetch_layer(ctx, "warpLayer", ×, &fr.grid);
|
||||
let matte_ch = ctx.params.e("matteChannel");
|
||||
let show = ctx.params.e("show");
|
||||
let idx = |t: f64| times.iter().position(|q| (q - t).abs() < 1e-9).unwrap_or(0);
|
||||
let mut flows: Vec<(i64, Flow)> = vec![];
|
||||
let mut frames = fr.imgs;
|
||||
let add = |frames: &mut Vec<Image>, img: Image| {
|
||||
frames.push(img);
|
||||
frames.len() - 1
|
||||
};
|
||||
// Motion fields: per source frame pair (keyed), or per masked pair (unkeyed).
|
||||
let mut flows: Vec<(Option<i64>, Flow)> = vec![];
|
||||
let mut steps = vec![];
|
||||
for &(s, wgt) in &instants {
|
||||
let (f0, frac) = tw_split(s, fps);
|
||||
let (i0, i1) = (idx(f0 / fps), idx((f0 + 1.0) / fps));
|
||||
let ma = mattes.as_ref().map(|m| matte_of(&m[i0], matte_ch));
|
||||
let mb = mattes.as_ref().map(|m| matte_of(&m[i1], matte_ch));
|
||||
let step = if method == 0 || frac < 1e-4 || (one && method == 1) {
|
||||
// Whole frames (Build From One Image with Frame Mix: the nearest frame).
|
||||
let pick = if method == 0 || frac < 1e-4 { 0.0 } else { frac.round() };
|
||||
TwStep::Whole(if pick < 0.5 { i0 } else { i1 })
|
||||
let i = if pick < 0.5 { i0 } else { i1 };
|
||||
let base = &frames[i];
|
||||
let derived = match (show, &ma, &mb) {
|
||||
(1, Some(m), _) if pick < 0.5 => Some(times_mask(base, m, false)),
|
||||
(2, Some(m), _) if pick < 0.5 => Some(times_mask(base, m, true)),
|
||||
(1, _, Some(m)) => Some(times_mask(base, m, false)),
|
||||
(2, _, Some(m)) => Some(times_mask(base, m, true)),
|
||||
(3, Some(m), _) => Some(matte_image(if pick < 0.5 { m } else { mb.as_ref().unwrap_or(m) }, base)),
|
||||
_ => None,
|
||||
};
|
||||
TwStep::Whole(match derived {
|
||||
Some(img) => add(&mut frames, img),
|
||||
None => i,
|
||||
})
|
||||
} else if method == 1 {
|
||||
TwStep::Mix(i0, i1, frac)
|
||||
match (&ma, &mb, show) {
|
||||
(Some(m0), Some(m1), 3) => {
|
||||
let (a, b) = (matte_image(m0, &frames[i0]), matte_image(m1, &frames[i1]));
|
||||
TwStep::Mix(add(&mut frames, a), add(&mut frames, b), frac)
|
||||
}
|
||||
(Some(m0), Some(m1), 1 | 2) => {
|
||||
let (a, b) = (times_mask(&frames[i0], m0, show == 2), times_mask(&frames[i1], m1, show == 2));
|
||||
TwStep::Mix(add(&mut frames, a), add(&mut frames, b), frac)
|
||||
}
|
||||
_ => TwStep::Mix(i0, i1, frac),
|
||||
}
|
||||
} else {
|
||||
// Pixel Motion: vectors from the warp layer if any, else from the layer.
|
||||
let key = f0 as i64;
|
||||
let flow = match flows.iter().position(|(k, _)| *k == key) {
|
||||
let flow = match flows.iter().position(|(k, _)| *k == Some(key)) {
|
||||
Some(k) => k,
|
||||
None => {
|
||||
let f = match &warps {
|
||||
Some(w) => timewarp_flow(&w[i0], &w[i1], &pm),
|
||||
None => timewarp_flow(&fr.imgs[i0], &fr.imgs[i1], &pm),
|
||||
None => timewarp_flow(&frames[i0], &frames[i1], &pm),
|
||||
};
|
||||
flows.push((key, f));
|
||||
flows.push((Some(key), f));
|
||||
flows.len() - 1
|
||||
}
|
||||
};
|
||||
TwStep::Motion { a: i0, b: i1, w: frac, flow }
|
||||
match (&ma, &mb) {
|
||||
(Some(m0), Some(m1)) => {
|
||||
// Foreground and background each move on their own vectors.
|
||||
let (fa, fb) = (times_mask(&frames[i0], m0, false), times_mask(&frames[i1], m1, false));
|
||||
let (ga, gb) = (times_mask(&frames[i0], m0, true), times_mask(&frames[i1], m1, true));
|
||||
let mut own = |a: &Image, b: &Image| {
|
||||
if warps.is_some() {
|
||||
return flow;
|
||||
}
|
||||
flows.push((None, timewarp_flow(a, b, &pm)));
|
||||
flows.len() - 1
|
||||
};
|
||||
let (fg_flow, bg_flow) = (own(&fa, &fb), own(&ga, &gb));
|
||||
let fg = [add(&mut frames, fa), add(&mut frames, fb), fg_flow];
|
||||
let bg = [add(&mut frames, ga), add(&mut frames, gb), bg_flow];
|
||||
TwStep::Layered { fg, bg, w: frac, show }
|
||||
}
|
||||
_ => TwStep::Motion { a: i0, b: i1, w: frac, flow },
|
||||
}
|
||||
};
|
||||
steps.push((step, wgt));
|
||||
}
|
||||
Some(TimewarpPlan { grid: fr.grid, frames: fr.imgs, steps, flows: flows.into_iter().map(|(_, f)| f).collect(), pm })
|
||||
Some(TimewarpPlan { grid: fr.grid, frames, steps, flows: flows.into_iter().map(|(_, f)| f).collect(), pm })
|
||||
}
|
||||
|
||||
/// Timewarp. Whole Frames shows the nearest source frame, Frame Mix cross-fades the two
|
||||
@@ -809,108 +872,30 @@ pub fn timewarp_plan(ctx: &EffectCtx) -> Option<TimewarpPlan> {
|
||||
/// Warp Layer supplies the motion instead of the layer itself. Motion Blur averages Shutter
|
||||
/// Samples instants across the shutter.
|
||||
fn timewarp(ctx: &EffectCtx, b: Buf) -> Buf {
|
||||
if ctx.env.host.is_none() {
|
||||
return b;
|
||||
match timewarp_plan(ctx) {
|
||||
Some(plan) => plan.render_cpu(),
|
||||
None => b,
|
||||
}
|
||||
if ctx.params.get("matteLayer").and_then(Value::as_layer).is_none() {
|
||||
return match timewarp_plan(ctx) {
|
||||
Some(plan) => plan.render_cpu(),
|
||||
None => b,
|
||||
};
|
||||
}
|
||||
// Instants of source time (with weights) across the shutter; each needs the frame at or
|
||||
// before it and the next one.
|
||||
let (instants, times, fps) = timewarp_instants(ctx);
|
||||
let split = |s: f64| tw_split(s, fps);
|
||||
let method = ctx.params.e("method");
|
||||
let one = method > 0 && ctx.params.b("tuning/buildFromOneImage");
|
||||
let Some(fr) = fetch(ctx, ×) else { return b };
|
||||
let grid = fr.grid.clone();
|
||||
let frame = |t: f64| -> &Image {
|
||||
let k = times.iter().position(|q| (q - t).abs() < 1e-9).unwrap_or(0);
|
||||
&fr.imgs[k]
|
||||
};
|
||||
let pm = PixelMotion::from(ctx, grid.scale);
|
||||
let mattes = fetch_layer(ctx, "matteLayer", ×, &grid);
|
||||
let warps = fetch_layer(ctx, "warpLayer", ×, &grid);
|
||||
let matte_ch = ctx.params.e("matteChannel");
|
||||
let show = ctx.params.e("show");
|
||||
let mut flows: Vec<((i64, bool), Flow)> = vec![];
|
||||
let mut out_frames = vec![];
|
||||
for &(s, wgt) in &instants {
|
||||
let (f0, frac) = split(s);
|
||||
let (t0, t1) = (f0 / fps, (f0 + 1.0) / fps);
|
||||
let (a, bb) = (frame(t0), frame(t1));
|
||||
let idx = |t: f64| times.iter().position(|q| (q - t).abs() < 1e-9).unwrap_or(0);
|
||||
let ma = mattes.as_ref().map(|m| matte_of(&m[idx(t0)], matte_ch));
|
||||
let mb = mattes.as_ref().map(|m| matte_of(&m[idx(t1)], matte_ch));
|
||||
let img = if method == 0 || frac < 1e-4 || (one && method == 1) {
|
||||
// Whole frames (Build From One Image with Frame Mix: the nearest frame).
|
||||
let pick = if method == 0 || frac < 1e-4 { 0.0 } else { frac.round() };
|
||||
let base = if pick < 0.5 { a } else { bb };
|
||||
match (show, &ma, &mb) {
|
||||
(1, Some(m), _) if pick < 0.5 => times_mask(base, m, false),
|
||||
(2, Some(m), _) if pick < 0.5 => times_mask(base, m, true),
|
||||
(1, _, Some(m)) => times_mask(base, m, false),
|
||||
(2, _, Some(m)) => times_mask(base, m, true),
|
||||
(3, Some(m), _) => matte_image(if pick < 0.5 { m } else { mb.as_ref().unwrap_or(m) }, base),
|
||||
_ => base.clone(),
|
||||
}
|
||||
} else if method == 1 {
|
||||
match (&ma, &mb, show) {
|
||||
(Some(m0), Some(m1), 3) => effectcraft_raster::flow::mix(&matte_image(m0, a), &matte_image(m1, bb), frac),
|
||||
(Some(m0), Some(m1), 1 | 2) => effectcraft_raster::flow::mix(×_mask(a, m0, show == 2), ×_mask(bb, m1, show == 2), frac),
|
||||
_ => effectcraft_raster::flow::mix(a, bb, frac),
|
||||
}
|
||||
} else {
|
||||
// Pixel Motion: vectors from the warp layer if any, else from the layer.
|
||||
let key = ((f0 as i64), false);
|
||||
let flow_ab = |fa: &Image, fb: &Image| -> Flow { timewarp_flow(fa, fb, &pm) };
|
||||
let flow = match flows.iter().find(|(k, _)| *k == key) {
|
||||
Some((_, f)) => f.clone(),
|
||||
None => {
|
||||
let f = match &warps {
|
||||
Some(w) => flow_ab(&w[idx(t0)], &w[idx(t1)]),
|
||||
None => flow_ab(a, bb),
|
||||
};
|
||||
flows.push((key, f.clone()));
|
||||
f
|
||||
}
|
||||
|
||||
/// Pixel Motion with a Matte Layer: the foreground and background frames built on their own
|
||||
/// vectors, shown as Show asks (0 Normal: foreground over background).
|
||||
fn layered(fg: Image, bg: Image, show: u32) -> Image {
|
||||
match show {
|
||||
1 => fg,
|
||||
2 => bg,
|
||||
3 => matte_image(&fg.data.iter().map(|p| p[3]).collect::<Vec<_>>(), &fg),
|
||||
_ => {
|
||||
let mut o = bg;
|
||||
o.data.par_iter_mut().zip(fg.data.par_iter()).for_each(|(p, q)| {
|
||||
let k = 1.0 - q[3];
|
||||
for c in 0..4 {
|
||||
p[c] = q[c] + p[c] * k;
|
||||
}
|
||||
};
|
||||
match (&ma, &mb) {
|
||||
(Some(m0), Some(m1)) => {
|
||||
// Foreground and background each move on their own vectors.
|
||||
let (fa, fb) = (times_mask(a, m0, false), times_mask(bb, m1, false));
|
||||
let (ga, gb) = (times_mask(a, m0, true), times_mask(bb, m1, true));
|
||||
let fg_flow = if warps.is_some() { flow.clone() } else { flow_ab(&fa, &fb) };
|
||||
let bg_flow = if warps.is_some() { flow.clone() } else { flow_ab(&ga, &gb) };
|
||||
let fg = timewarp_interpolate(&fa, &fb, frac, &fg_flow, &pm);
|
||||
let bg = timewarp_interpolate(&ga, &gb, frac, &bg_flow, &pm);
|
||||
match show {
|
||||
1 => fg,
|
||||
2 => bg,
|
||||
3 => matte_image(&fg.data.iter().map(|p| p[3]).collect::<Vec<_>>(), &fg),
|
||||
_ => {
|
||||
let mut o = bg;
|
||||
o.data.par_iter_mut().zip(fg.data.par_iter()).for_each(|(p, q)| {
|
||||
let k = 1.0 - q[3];
|
||||
for c in 0..4 {
|
||||
p[c] = q[c] + p[c] * k;
|
||||
}
|
||||
});
|
||||
o
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => timewarp_interpolate(a, bb, frac, &flow, &pm),
|
||||
}
|
||||
};
|
||||
out_frames.push((img, wgt));
|
||||
});
|
||||
o
|
||||
}
|
||||
}
|
||||
let imgs: Vec<Image> = out_frames.iter().map(|(i, _)| i.clone()).collect();
|
||||
let weights: Vec<f32> = out_frames.iter().map(|(_, w)| *w).collect();
|
||||
let img = if imgs.len() == 1 { imgs.into_iter().next().unwrap_or_default() } else { average(&imgs, &weights) };
|
||||
with_img(grid, img)
|
||||
}
|
||||
|
||||
/// A matte shown as opaque grey.
|
||||
|
||||
@@ -0,0 +1,661 @@
|
||||
//! Golden hashes of the CPU particle effects (M13.29).
|
||||
//!
|
||||
//! The sibling of `sim_golden.rs` for the particle systems and the per-pixel "particle" effects
|
||||
//! that the GPU compositor draws from a shared per-frame plan: CC Particle World, CC Particle
|
||||
//! Systems II, Particle Playground (cannon, grid, text, layer exploder, layer map, property
|
||||
//! mappers, repel), CC Ball Action, CC Pixel Polly, CC Scatterize and Curl Noise. Same set-up,
|
||||
//! hashing and re-pinning (`SIM_GOLDEN_PRINT=1`, `SIM_GOLDEN_OUT=<dir>`) as `sim_golden.rs`: any
|
||||
//! change to the CPU output of these effects, however small, fails the test.
|
||||
|
||||
use effectcraft_effects::{Buf, EffectCtx, EffectEnv, EffectHost, LayerPixels, Params, apply, default_value, find};
|
||||
use effectcraft_keyframe::Value;
|
||||
use effectcraft_raster::Image;
|
||||
|
||||
const W: u32 = 64;
|
||||
const H: u32 = 48;
|
||||
/// Layer ids served by [`Host`]: a texture and a luminance map.
|
||||
const TEX: u64 = 7;
|
||||
const MAP: u64 = 8;
|
||||
|
||||
/// The effect's own layer: a colour ramp with a clear hole and a half-transparent band
|
||||
/// (`hdr` makes part of it overbright).
|
||||
fn layer(hdr: bool) -> Image {
|
||||
let mut img = Image::new(W, H);
|
||||
for y in 0..H {
|
||||
for x in 0..W {
|
||||
let (u, v) = (x as f32 / W as f32, y as f32 / H as f32);
|
||||
let (dx, dy) = (x as f32 - 40.0, y as f32 - 20.0);
|
||||
let a = if dx * dx + dy * dy < 64.0 {
|
||||
0.0
|
||||
} else if (30..36).contains(&y) {
|
||||
0.45
|
||||
} else {
|
||||
1.0
|
||||
};
|
||||
let gain = if hdr && x < 20 { 1.6 } else { 1.0 };
|
||||
let c = [u * gain, v * gain, (0.3 + 0.4 * (u * 9.0).sin().abs()) * gain];
|
||||
img.set(x, y, [c[0] * a, c[1] * a, c[2] * a, a]);
|
||||
}
|
||||
}
|
||||
img
|
||||
}
|
||||
|
||||
/// Another layer: a checker texture (`TEX`) or a radial luminance map (`MAP`).
|
||||
fn other(id: u64) -> Image {
|
||||
let mut img = Image::new(W, H);
|
||||
for y in 0..H {
|
||||
for x in 0..W {
|
||||
let p = if id == TEX {
|
||||
let k = ((x / 8 + y / 8) % 2) as f32;
|
||||
[0.9 * k + 0.1, 0.3 + 0.5 * (1.0 - k), 0.6, 1.0]
|
||||
} else {
|
||||
let d = ((x as f32 - 32.0).powi(2) + (y as f32 - 24.0).powi(2)).sqrt() / 40.0;
|
||||
let l = (1.0 - d).clamp(0.0, 1.0);
|
||||
[l, l, l, 1.0]
|
||||
};
|
||||
img.set(x, y, p);
|
||||
}
|
||||
}
|
||||
img
|
||||
}
|
||||
|
||||
struct Host;
|
||||
impl EffectHost for Host {
|
||||
fn layer(&self, id: u64, _: bool) -> Option<LayerPixels> {
|
||||
let img = other(id);
|
||||
Some(LayerPixels { buf: Buf { img, offset: [0.0; 2], scale: 1.0 }, size: [W as f64, H as f64] })
|
||||
}
|
||||
fn layer_at(&self, id: u64, comp_time: f64, _: bool) -> Option<LayerPixels> {
|
||||
// A frame that changes with time (Particle Playground's Layer Map times).
|
||||
let mut img = other(id);
|
||||
let k = ((comp_time * 30.0).round() as i64).rem_euclid(5) as f32 * 0.15;
|
||||
for p in img.data.iter_mut() {
|
||||
p[0] = (p[0] + k).min(1.0) * p[3];
|
||||
}
|
||||
Some(LayerPixels { buf: Buf { img, offset: [0.0; 2], scale: 1.0 }, size: [W as f64, H as f64] })
|
||||
}
|
||||
fn audio(&self, _: u64, _: f64, _: usize, _: u32) -> Option<Vec<f32>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn n(v: f64) -> Value {
|
||||
Value::Scalar(v)
|
||||
}
|
||||
fn e(v: u32) -> Value {
|
||||
Value::Enum(v)
|
||||
}
|
||||
fn l(id: u64) -> Value {
|
||||
Value::Layer(Some(id))
|
||||
}
|
||||
|
||||
type Set = Vec<(&'static str, Value)>;
|
||||
|
||||
fn b(v: bool) -> Value {
|
||||
Value::Bool(v)
|
||||
}
|
||||
fn v2(x: f64, y: f64) -> Value {
|
||||
Value::Vec2([x, y])
|
||||
}
|
||||
fn s(v: &str) -> Value {
|
||||
Value::Str(v.into())
|
||||
}
|
||||
|
||||
/// A Particle Playground grid (cannon off) plus `more`.
|
||||
fn grid(more: Set) -> Set {
|
||||
let mut g: Set = vec![
|
||||
("cannonEnabled", b(false)),
|
||||
("gridEnabled", b(true)),
|
||||
("grid/gridPosition", v2(32.0, 20.0)),
|
||||
("grid/gridWidth", n(40.0)),
|
||||
("grid/gridHeight", n(20.0)),
|
||||
("grid/particlesAcross", n(5.0)),
|
||||
("grid/particlesDown", n(3.0)),
|
||||
("grid/gridParticleRadius", n(3.0)),
|
||||
("gravity/gravityForce", n(20.0)),
|
||||
];
|
||||
g.extend(more);
|
||||
g
|
||||
}
|
||||
|
||||
/// (effect id, parameter sets) — the first set of each is the defaults.
|
||||
fn cases() -> Vec<(&'static str, Vec<Set>)> {
|
||||
vec![
|
||||
(
|
||||
"ec.sim.ccparticleworld",
|
||||
vec![
|
||||
vec![],
|
||||
vec![("birthRate", n(2.0)), ("particle/particleType", e(1)), ("particle/transferMode", e(2)), ("physics/animation", e(1))],
|
||||
vec![("particle/particleType", e(4)), ("physics/animation", e(2)), ("particle/transferMode", e(1)), ("producer/radiusZ", n(0.3))],
|
||||
vec![("particle/particleType", e(8)), ("physics/animation", e(5)), ("particle/transferMode", e(3)), ("particle/birthSize", n(0.4))],
|
||||
vec![("particle/particleType", e(5)), ("physics/animation", e(8)), ("particle/sizeVariation", n(50.0)), ("physics/resistance", n(1.0))],
|
||||
vec![("particle/particleType", e(3)), ("physics/animation", e(6)), ("particle/maxOpacity", n(100.0))],
|
||||
vec![("particle/particleType", e(6)), ("physics/animation", e(4)), ("particle/deathSize", n(0.6))],
|
||||
vec![("particle/particleType", e(7)), ("physics/animation", e(3))],
|
||||
vec![("particle/particleType", e(2)), ("physics/animation", e(9))],
|
||||
],
|
||||
),
|
||||
(
|
||||
"ec.sim.ccparticlesystems2",
|
||||
vec![
|
||||
vec![],
|
||||
vec![("particle/particleType", e(1)), ("particle/transferMode", e(2)), ("physics/animation", e(2)), ("birthRate", n(4.0))],
|
||||
vec![("particle/particleType", e(5)), ("physics/animation", e(6)), ("particle/transferMode", e(1))],
|
||||
vec![("particle/particleType", e(7)), ("particle/transferMode", e(3)), ("physics/animation", e(9)), ("producer/radiusX", n(10.0))],
|
||||
vec![("particle/particleType", e(3)), ("physics/animation", e(4)), ("particle/sizeVariation", n(40.0))],
|
||||
vec![("particle/particleType", e(4)), ("physics/animation", e(5)), ("physics/direction", n(60.0))],
|
||||
],
|
||||
),
|
||||
(
|
||||
"ec.sim.particleplayground",
|
||||
vec![
|
||||
vec![],
|
||||
vec![
|
||||
("cannon/cannonPosition", v2(20.0, 40.0)),
|
||||
("cannon/particlesPerSecond", n(120.0)),
|
||||
("cannon/velocity", n(80.0)),
|
||||
("gravity/gravityForce", n(40.0)),
|
||||
],
|
||||
grid(vec![]),
|
||||
grid(vec![("options/gridText", s("Ab C")), ("grid/gridParticleRadius", n(12.0)), ("options/autoOrientRotation", b(true))]),
|
||||
vec![
|
||||
("cannonEnabled", b(false)),
|
||||
("exploderEnabled", b(true)),
|
||||
("layerExploder/explodeLayer", l(TEX)),
|
||||
("layerExploder/radiusOfNewParticles", n(3.0)),
|
||||
],
|
||||
grid(vec![
|
||||
("layerMapEnabled", b(true)),
|
||||
("layerMap/layerMapLayer", l(TEX)),
|
||||
("layerMap/timeOffsetType", e(2)),
|
||||
("layerMap/timeOffset", n(0.5)),
|
||||
]),
|
||||
grid(vec![
|
||||
("mapperEnabled", b(true)),
|
||||
("persistentPropertyMapper/useLayerAsMap", l(MAP)),
|
||||
("persistentPropertyMapper/mapRedTo", e(8)),
|
||||
("persistentPropertyMapper/redMin", n(-50.0)),
|
||||
("persistentPropertyMapper/redMax", n(50.0)),
|
||||
]),
|
||||
grid(vec![
|
||||
("ephemeralPropertyMapper/useLayerAsMap", l(MAP)),
|
||||
("ephemeralPropertyMapper/mapRedTo", e(1)),
|
||||
("ephemeralPropertyMapper/mapGreenTo", e(5)),
|
||||
("ephemeralPropertyMapper/greenOperator", e(1)),
|
||||
("ephemeralPropertyMapper/greenMax", n(4.0)),
|
||||
]),
|
||||
grid(vec![("repel/repelForce", n(5.0)), ("repel/repelForceRadius", n(12.0)), ("options/cannonText", s("xy")), ("cannonEnabled", b(true))]),
|
||||
],
|
||||
),
|
||||
(
|
||||
"ec.sim.ccballaction",
|
||||
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))],
|
||||
],
|
||||
),
|
||||
(
|
||||
"ec.sim.ccpixelpolly",
|
||||
vec![
|
||||
vec![],
|
||||
vec![("object", e(1)), ("gridSpacing", n(6.0))],
|
||||
vec![("object", e(2)), ("spinning", n(90.0))],
|
||||
vec![("object", e(3)), ("enableDepthSort", b(false)), ("gravity", n(2.0)), ("startTime", n(0.3))],
|
||||
],
|
||||
),
|
||||
(
|
||||
"ec.sim.ccscatterize",
|
||||
vec![vec![], vec![("scatter", n(10.0))], vec![("rightTwist", n(60.0)), ("leftTwist", n(-30.0)), ("transferMode", e(1)), ("scatter", n(4.0))]],
|
||||
),
|
||||
(
|
||||
"ec.noise.curlnoise",
|
||||
vec![
|
||||
vec![],
|
||||
vec![("view", e(1))],
|
||||
vec![
|
||||
("edgeBehavior", e(1)),
|
||||
("steps", n(8.0)),
|
||||
("displacementAmount", n(60.0)),
|
||||
("scale", n(20.0)),
|
||||
("rotation", n(30.0)),
|
||||
("evolution", n(90.0)),
|
||||
],
|
||||
],
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// Layer times, in order (the third seeks backwards).
|
||||
const TIMES: [f64; 4] = [0.5, 1.5, 0.8, 2.2];
|
||||
|
||||
fn fnv(img: &Image) -> u64 {
|
||||
let mut h = 0xcbf2_9ce4_8422_2325u64;
|
||||
for b in [img.width, img.height].iter().flat_map(|v| v.to_le_bytes()) {
|
||||
h = (h ^ b as u64).wrapping_mul(0x100_0000_01b3);
|
||||
}
|
||||
for p in &img.data {
|
||||
for c in p {
|
||||
for b in c.to_bits().to_le_bytes() {
|
||||
h = (h ^ b as u64).wrapping_mul(0x100_0000_01b3);
|
||||
}
|
||||
}
|
||||
}
|
||||
h
|
||||
}
|
||||
|
||||
fn render(id: &str, set: &Set, time: f64, bpc8: bool, half: bool) -> Image {
|
||||
let spec = find(id).unwrap_or_else(|| panic!("no effect {id}"));
|
||||
let size = [W as f64, H as f64];
|
||||
let mut params = Params { values: spec.params.iter().map(|p| (p.id.to_string(), default_value(p, size))).collect() };
|
||||
for (k, v) in set {
|
||||
assert!(params.values.contains_key(*k), "{id}: unknown param {k}");
|
||||
params.values.insert(k.to_string(), v.clone());
|
||||
}
|
||||
let mut img = layer(!bpc8);
|
||||
if bpc8 {
|
||||
img.clamp01();
|
||||
img.quantize(255.0);
|
||||
}
|
||||
let mut buf = Buf { img, offset: [0.0; 2], scale: 1.0 };
|
||||
if half {
|
||||
// A half-resolution preview buffer padded by 3 px.
|
||||
let (w2, h2) = (W / 2, H / 2);
|
||||
let mut small = Image::new(w2, h2);
|
||||
for y in 0..h2 {
|
||||
for x in 0..w2 {
|
||||
small.set(x, y, buf.img.sample_bilinear(x as f64 * 2.0 + 1.0, y as f64 * 2.0 + 1.0));
|
||||
}
|
||||
}
|
||||
buf = Buf { img: small, offset: [0.0; 2], scale: 0.5 };
|
||||
buf.pad(3);
|
||||
}
|
||||
let host = Host;
|
||||
let env = EffectEnv { host: Some(&host), frame_rate: 30.0, comp_time: time, ..Default::default() };
|
||||
let ctx = EffectCtx { params: ¶ms, time, layer_size: size, seed: 1, adjustment: false, env };
|
||||
let mut out = apply(spec, &ctx, buf).img;
|
||||
if bpc8 {
|
||||
out.clamp01();
|
||||
out.quantize(255.0);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Every case's name and hash, in a fixed order.
|
||||
fn hashes() -> Vec<(String, u64)> {
|
||||
let out_dir = std::env::var_os("SIM_GOLDEN_OUT").map(std::path::PathBuf::from);
|
||||
if let Some(d) = &out_dir {
|
||||
std::fs::create_dir_all(d).unwrap();
|
||||
}
|
||||
let mut v = Vec::new();
|
||||
for (id, sets) in cases() {
|
||||
for (si, set) in sets.iter().enumerate() {
|
||||
for (bpc8, half) in [(true, false), (false, false), (true, true)] {
|
||||
if half && si > 0 {
|
||||
continue;
|
||||
}
|
||||
for t in TIMES {
|
||||
let img = render(id, set, t, bpc8, half);
|
||||
let name = format!("{id}/{si}/{}{}/t{t}", if bpc8 { "8bpc" } else { "32bpc" }, if half { "/half" } else { "" });
|
||||
if let Some(d) = &out_dir {
|
||||
let bytes: Vec<u8> = img.data.iter().flat_map(|p| p.iter().flat_map(|c| c.to_le_bytes())).collect();
|
||||
let file = format!("{}_{}x{}.f32", name.replace('/', "_"), img.width, img.height);
|
||||
std::fs::write(d.join(file), bytes).unwrap();
|
||||
}
|
||||
v.push((name, fnv(&img)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn particle_effects_golden_hashes() {
|
||||
let got = hashes();
|
||||
if std::env::var_os("SIM_GOLDEN_PRINT").is_some() {
|
||||
for (name, h) in &got {
|
||||
println!(" (\"{name}\", 0x{h:016x}),");
|
||||
}
|
||||
}
|
||||
// Deterministic: a second pass (warm simulation caches) renders the same frames.
|
||||
assert_eq!(got, hashes(), "particle effects render deterministically");
|
||||
if cfg!(all(target_os = "macos", target_arch = "aarch64")) {
|
||||
let bad: Vec<String> = got
|
||||
.iter()
|
||||
.zip(GOLDEN)
|
||||
.filter(|((n, h), (gn, gh))| n != gn || h != gh)
|
||||
.map(|((n, h), (_, gh))| format!("{n}: 0x{h:016x} (pinned 0x{gh:016x})"))
|
||||
.collect();
|
||||
assert_eq!(got.len(), GOLDEN.len(), "case count");
|
||||
assert!(bad.is_empty(), "CPU output changed:\n{}", bad.join("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
/// Pinned hashes (aarch64 macOS).
|
||||
const GOLDEN: &[(&str, u64)] = &[
|
||||
("ec.sim.ccparticleworld/0/8bpc/t0.5", 0x263d8f88e7ae651b),
|
||||
("ec.sim.ccparticleworld/0/8bpc/t1.5", 0xb7697683e3cc6d43),
|
||||
("ec.sim.ccparticleworld/0/8bpc/t0.8", 0xb5065326c8bd674a),
|
||||
("ec.sim.ccparticleworld/0/8bpc/t2.2", 0x7f8eb5f2e8d38506),
|
||||
("ec.sim.ccparticleworld/0/32bpc/t0.5", 0x6141abad89cd53ca),
|
||||
("ec.sim.ccparticleworld/0/32bpc/t1.5", 0x2b5682e32bb3e916),
|
||||
("ec.sim.ccparticleworld/0/32bpc/t0.8", 0xe6aaed9716d15c42),
|
||||
("ec.sim.ccparticleworld/0/32bpc/t2.2", 0xa6e9a6f2acad94c0),
|
||||
("ec.sim.ccparticleworld/0/8bpc/half/t0.5", 0xbb0b6803512a6b99),
|
||||
("ec.sim.ccparticleworld/0/8bpc/half/t1.5", 0x70c578ea73992099),
|
||||
("ec.sim.ccparticleworld/0/8bpc/half/t0.8", 0x2d26cb3f73a26b4f),
|
||||
("ec.sim.ccparticleworld/0/8bpc/half/t2.2", 0x2b474438a48ee0e4),
|
||||
("ec.sim.ccparticleworld/1/8bpc/t0.5", 0x294502dc827b0326),
|
||||
("ec.sim.ccparticleworld/1/8bpc/t1.5", 0xf7874709f4012aaa),
|
||||
("ec.sim.ccparticleworld/1/8bpc/t0.8", 0x87664ce9a05e67f9),
|
||||
("ec.sim.ccparticleworld/1/8bpc/t2.2", 0x46e1b5162a0284f4),
|
||||
("ec.sim.ccparticleworld/1/32bpc/t0.5", 0x02d8499e93133cb9),
|
||||
("ec.sim.ccparticleworld/1/32bpc/t1.5", 0x97218172dec765c6),
|
||||
("ec.sim.ccparticleworld/1/32bpc/t0.8", 0xee7da06e0b16e3b7),
|
||||
("ec.sim.ccparticleworld/1/32bpc/t2.2", 0x6b9da0aa7d2a6abb),
|
||||
("ec.sim.ccparticleworld/2/8bpc/t0.5", 0x71468ce82bba3cb2),
|
||||
("ec.sim.ccparticleworld/2/8bpc/t1.5", 0x48595f55e8741a7e),
|
||||
("ec.sim.ccparticleworld/2/8bpc/t0.8", 0x5ebc35e9eb02c8d7),
|
||||
("ec.sim.ccparticleworld/2/8bpc/t2.2", 0xf9a0f63c72bd35f0),
|
||||
("ec.sim.ccparticleworld/2/32bpc/t0.5", 0x757f80d45a2159b1),
|
||||
("ec.sim.ccparticleworld/2/32bpc/t1.5", 0x7924f1cb9c8bf8c7),
|
||||
("ec.sim.ccparticleworld/2/32bpc/t0.8", 0x22f507420a062c87),
|
||||
("ec.sim.ccparticleworld/2/32bpc/t2.2", 0x41171121719a307a),
|
||||
("ec.sim.ccparticleworld/3/8bpc/t0.5", 0xbca7e3d574cf5e37),
|
||||
("ec.sim.ccparticleworld/3/8bpc/t1.5", 0x5c4347a6c70b48ec),
|
||||
("ec.sim.ccparticleworld/3/8bpc/t0.8", 0xc79131dbaa8ff129),
|
||||
("ec.sim.ccparticleworld/3/8bpc/t2.2", 0xc08d0c5e8f87189d),
|
||||
("ec.sim.ccparticleworld/3/32bpc/t0.5", 0x36635fe45324f86d),
|
||||
("ec.sim.ccparticleworld/3/32bpc/t1.5", 0xf9751b9225a373a4),
|
||||
("ec.sim.ccparticleworld/3/32bpc/t0.8", 0xb6026343f72dfaeb),
|
||||
("ec.sim.ccparticleworld/3/32bpc/t2.2", 0x2f0e149de9623753),
|
||||
("ec.sim.ccparticleworld/4/8bpc/t0.5", 0xd53dad7a75976197),
|
||||
("ec.sim.ccparticleworld/4/8bpc/t1.5", 0x2cd0f3cbed038289),
|
||||
("ec.sim.ccparticleworld/4/8bpc/t0.8", 0x46c089373ed50088),
|
||||
("ec.sim.ccparticleworld/4/8bpc/t2.2", 0xfb17c5c3ba44657c),
|
||||
("ec.sim.ccparticleworld/4/32bpc/t0.5", 0x80b338b7bb9794b1),
|
||||
("ec.sim.ccparticleworld/4/32bpc/t1.5", 0x86811f65519e9790),
|
||||
("ec.sim.ccparticleworld/4/32bpc/t0.8", 0x6aad5efc09bc64ff),
|
||||
("ec.sim.ccparticleworld/4/32bpc/t2.2", 0x9957090d6fc97293),
|
||||
("ec.sim.ccparticleworld/5/8bpc/t0.5", 0x56f989c5d7fc1eeb),
|
||||
("ec.sim.ccparticleworld/5/8bpc/t1.5", 0x128313333a936e16),
|
||||
("ec.sim.ccparticleworld/5/8bpc/t0.8", 0xa0efb8bdc0157788),
|
||||
("ec.sim.ccparticleworld/5/8bpc/t2.2", 0x4af31455e2fe2631),
|
||||
("ec.sim.ccparticleworld/5/32bpc/t0.5", 0xf3057d8cf6540f4a),
|
||||
("ec.sim.ccparticleworld/5/32bpc/t1.5", 0x28203947d78e5ee3),
|
||||
("ec.sim.ccparticleworld/5/32bpc/t0.8", 0xa6d8a9a848443344),
|
||||
("ec.sim.ccparticleworld/5/32bpc/t2.2", 0xade682a437a4cba1),
|
||||
("ec.sim.ccparticleworld/6/8bpc/t0.5", 0xa65b30a36baee78a),
|
||||
("ec.sim.ccparticleworld/6/8bpc/t1.5", 0xbf7e4675fec18c48),
|
||||
("ec.sim.ccparticleworld/6/8bpc/t0.8", 0xf98c7d9af9d6c9e2),
|
||||
("ec.sim.ccparticleworld/6/8bpc/t2.2", 0xdf090357b8e4f471),
|
||||
("ec.sim.ccparticleworld/6/32bpc/t0.5", 0x1721a9f149c922de),
|
||||
("ec.sim.ccparticleworld/6/32bpc/t1.5", 0xf378db3b55dff048),
|
||||
("ec.sim.ccparticleworld/6/32bpc/t0.8", 0x72a5d8dc0ea744ad),
|
||||
("ec.sim.ccparticleworld/6/32bpc/t2.2", 0xfbb8e14088bb51ef),
|
||||
("ec.sim.ccparticleworld/7/8bpc/t0.5", 0xc56801146ef15811),
|
||||
("ec.sim.ccparticleworld/7/8bpc/t1.5", 0x3ca9b694e5e55f82),
|
||||
("ec.sim.ccparticleworld/7/8bpc/t0.8", 0x2d72c095e0be6f47),
|
||||
("ec.sim.ccparticleworld/7/8bpc/t2.2", 0x135b14387e6ea480),
|
||||
("ec.sim.ccparticleworld/7/32bpc/t0.5", 0xad79b2f2d63d0c45),
|
||||
("ec.sim.ccparticleworld/7/32bpc/t1.5", 0x902c6b68c6ed615d),
|
||||
("ec.sim.ccparticleworld/7/32bpc/t0.8", 0x45045d7931c23788),
|
||||
("ec.sim.ccparticleworld/7/32bpc/t2.2", 0xd8f8883374a3784f),
|
||||
("ec.sim.ccparticleworld/8/8bpc/t0.5", 0xb681fe6e20dccbf3),
|
||||
("ec.sim.ccparticleworld/8/8bpc/t1.5", 0xfa78174cb4fa5cd4),
|
||||
("ec.sim.ccparticleworld/8/8bpc/t0.8", 0xd4f486333d843f09),
|
||||
("ec.sim.ccparticleworld/8/8bpc/t2.2", 0xbee37590ce17b8b4),
|
||||
("ec.sim.ccparticleworld/8/32bpc/t0.5", 0xccf4339bc42c3c01),
|
||||
("ec.sim.ccparticleworld/8/32bpc/t1.5", 0xc51a8ee4e3c4a826),
|
||||
("ec.sim.ccparticleworld/8/32bpc/t0.8", 0xee3d66e0c4ffb0ec),
|
||||
("ec.sim.ccparticleworld/8/32bpc/t2.2", 0x449fc6d506e837fb),
|
||||
("ec.sim.ccparticlesystems2/0/8bpc/t0.5", 0x3edb24bfeab4b00a),
|
||||
("ec.sim.ccparticlesystems2/0/8bpc/t1.5", 0x78cb639f211cbd5b),
|
||||
("ec.sim.ccparticlesystems2/0/8bpc/t0.8", 0x634c71924e4c68f1),
|
||||
("ec.sim.ccparticlesystems2/0/8bpc/t2.2", 0xe09d41dcb6286423),
|
||||
("ec.sim.ccparticlesystems2/0/32bpc/t0.5", 0xacdb6aec643a9bba),
|
||||
("ec.sim.ccparticlesystems2/0/32bpc/t1.5", 0x4c50991034336999),
|
||||
("ec.sim.ccparticlesystems2/0/32bpc/t0.8", 0xaacc2ea722f2e9e3),
|
||||
("ec.sim.ccparticlesystems2/0/32bpc/t2.2", 0x1a5f7fc66db90a83),
|
||||
("ec.sim.ccparticlesystems2/0/8bpc/half/t0.5", 0x8c89f83a2829dba1),
|
||||
("ec.sim.ccparticlesystems2/0/8bpc/half/t1.5", 0x9239cd8895757d17),
|
||||
("ec.sim.ccparticlesystems2/0/8bpc/half/t0.8", 0x91a16fb0a382d8e1),
|
||||
("ec.sim.ccparticlesystems2/0/8bpc/half/t2.2", 0xc86d8250fe1402c5),
|
||||
("ec.sim.ccparticlesystems2/1/8bpc/t0.5", 0xabade8d131837f05),
|
||||
("ec.sim.ccparticlesystems2/1/8bpc/t1.5", 0x6a3566257b9a0bad),
|
||||
("ec.sim.ccparticlesystems2/1/8bpc/t0.8", 0xc1199f209bad5c33),
|
||||
("ec.sim.ccparticlesystems2/1/8bpc/t2.2", 0xaf337959d8264a5f),
|
||||
("ec.sim.ccparticlesystems2/1/32bpc/t0.5", 0xb1816c2e5562be88),
|
||||
("ec.sim.ccparticlesystems2/1/32bpc/t1.5", 0x02413f0ec8284e39),
|
||||
("ec.sim.ccparticlesystems2/1/32bpc/t0.8", 0xd9bc645b90055a9a),
|
||||
("ec.sim.ccparticlesystems2/1/32bpc/t2.2", 0x2c788bb5816167a3),
|
||||
("ec.sim.ccparticlesystems2/2/8bpc/t0.5", 0xe18fd350f7155fc8),
|
||||
("ec.sim.ccparticlesystems2/2/8bpc/t1.5", 0x956e03e2c83c3899),
|
||||
("ec.sim.ccparticlesystems2/2/8bpc/t0.8", 0x7d16738562170622),
|
||||
("ec.sim.ccparticlesystems2/2/8bpc/t2.2", 0x4e5838737bda7317),
|
||||
("ec.sim.ccparticlesystems2/2/32bpc/t0.5", 0x27d909b24d165f6c),
|
||||
("ec.sim.ccparticlesystems2/2/32bpc/t1.5", 0x47fb5492c0bcb748),
|
||||
("ec.sim.ccparticlesystems2/2/32bpc/t0.8", 0x7dd63be8a11f4d71),
|
||||
("ec.sim.ccparticlesystems2/2/32bpc/t2.2", 0x139259fc5f942375),
|
||||
("ec.sim.ccparticlesystems2/3/8bpc/t0.5", 0xf14aad048c3b4181),
|
||||
("ec.sim.ccparticlesystems2/3/8bpc/t1.5", 0xc261983ac6805eda),
|
||||
("ec.sim.ccparticlesystems2/3/8bpc/t0.8", 0xf93ad1d6a9c493a5),
|
||||
("ec.sim.ccparticlesystems2/3/8bpc/t2.2", 0x88cf7156f9f8ec54),
|
||||
("ec.sim.ccparticlesystems2/3/32bpc/t0.5", 0xdc1df37cb3b92146),
|
||||
("ec.sim.ccparticlesystems2/3/32bpc/t1.5", 0x1c415c633baec738),
|
||||
("ec.sim.ccparticlesystems2/3/32bpc/t0.8", 0x81a765f6e435e762),
|
||||
("ec.sim.ccparticlesystems2/3/32bpc/t2.2", 0x7810e7f2ae55f619),
|
||||
("ec.sim.ccparticlesystems2/4/8bpc/t0.5", 0xd246be64fea5db5f),
|
||||
("ec.sim.ccparticlesystems2/4/8bpc/t1.5", 0x78ca37c0d19e87cf),
|
||||
("ec.sim.ccparticlesystems2/4/8bpc/t0.8", 0xa5eacfbc0cc28a7c),
|
||||
("ec.sim.ccparticlesystems2/4/8bpc/t2.2", 0xa527d1d2cdce5c96),
|
||||
("ec.sim.ccparticlesystems2/4/32bpc/t0.5", 0x41c8b38886ae9652),
|
||||
("ec.sim.ccparticlesystems2/4/32bpc/t1.5", 0x1e6d16247bb9c7a7),
|
||||
("ec.sim.ccparticlesystems2/4/32bpc/t0.8", 0x05b125bdcd9a1794),
|
||||
("ec.sim.ccparticlesystems2/4/32bpc/t2.2", 0x4752ed7777528cc8),
|
||||
("ec.sim.ccparticlesystems2/5/8bpc/t0.5", 0x8ff7adb3b1720dbe),
|
||||
("ec.sim.ccparticlesystems2/5/8bpc/t1.5", 0x2bb835296a78fccb),
|
||||
("ec.sim.ccparticlesystems2/5/8bpc/t0.8", 0x674810581e32f80a),
|
||||
("ec.sim.ccparticlesystems2/5/8bpc/t2.2", 0xecba1a3a740f4325),
|
||||
("ec.sim.ccparticlesystems2/5/32bpc/t0.5", 0x30f53c7cb869066c),
|
||||
("ec.sim.ccparticlesystems2/5/32bpc/t1.5", 0x1eb455f68b9decc8),
|
||||
("ec.sim.ccparticlesystems2/5/32bpc/t0.8", 0xf396c8bdd516ef26),
|
||||
("ec.sim.ccparticlesystems2/5/32bpc/t2.2", 0x7d0a6e30425ea5c3),
|
||||
("ec.sim.particleplayground/0/8bpc/t0.5", 0x1842226399d43e19),
|
||||
("ec.sim.particleplayground/0/8bpc/t1.5", 0xd5676389299c50e9),
|
||||
("ec.sim.particleplayground/0/8bpc/t0.8", 0x30517e3b37e099d5),
|
||||
("ec.sim.particleplayground/0/8bpc/t2.2", 0xae4bc0c296e03d75),
|
||||
("ec.sim.particleplayground/0/32bpc/t0.5", 0x7af5da92e477f075),
|
||||
("ec.sim.particleplayground/0/32bpc/t1.5", 0xb51f5a6d27dc1d85),
|
||||
("ec.sim.particleplayground/0/32bpc/t0.8", 0x8da8efac055a67e5),
|
||||
("ec.sim.particleplayground/0/32bpc/t2.2", 0x7ad7e7a36e107a6d),
|
||||
("ec.sim.particleplayground/0/8bpc/half/t0.5", 0xe262aec0816c3ccd),
|
||||
("ec.sim.particleplayground/0/8bpc/half/t1.5", 0x87e664a185ad2ca1),
|
||||
("ec.sim.particleplayground/0/8bpc/half/t0.8", 0x34e36782ea9592fd),
|
||||
("ec.sim.particleplayground/0/8bpc/half/t2.2", 0x0cf9289dd2950f89),
|
||||
("ec.sim.particleplayground/1/8bpc/t0.5", 0x5dfbd4b5eb4382b9),
|
||||
("ec.sim.particleplayground/1/8bpc/t1.5", 0xac3e8f2a9d4df855),
|
||||
("ec.sim.particleplayground/1/8bpc/t0.8", 0x847292a51edbf41d),
|
||||
("ec.sim.particleplayground/1/8bpc/t2.2", 0x58d9f45b4b984099),
|
||||
("ec.sim.particleplayground/1/32bpc/t0.5", 0x1a3069f5d33c287d),
|
||||
("ec.sim.particleplayground/1/32bpc/t1.5", 0x08e920bd85cd88ad),
|
||||
("ec.sim.particleplayground/1/32bpc/t0.8", 0x692b0c490c09ac51),
|
||||
("ec.sim.particleplayground/1/32bpc/t2.2", 0x21491c337ddd9f75),
|
||||
("ec.sim.particleplayground/2/8bpc/t0.5", 0xb04e21f3c9ee8955),
|
||||
("ec.sim.particleplayground/2/8bpc/t1.5", 0x3e9b871d87e66255),
|
||||
("ec.sim.particleplayground/2/8bpc/t0.8", 0x9052ebc3a39db605),
|
||||
("ec.sim.particleplayground/2/8bpc/t2.2", 0x4b2129a0221866d5),
|
||||
("ec.sim.particleplayground/2/32bpc/t0.5", 0xb59ff67f1e4fdd55),
|
||||
("ec.sim.particleplayground/2/32bpc/t1.5", 0x1ac6b864503401c5),
|
||||
("ec.sim.particleplayground/2/32bpc/t0.8", 0x16a5d9d93e9c95c5),
|
||||
("ec.sim.particleplayground/2/32bpc/t2.2", 0x4b2129a0221866d5),
|
||||
("ec.sim.particleplayground/3/8bpc/t0.5", 0xbf818a3d83f45f7d),
|
||||
("ec.sim.particleplayground/3/8bpc/t1.5", 0x02ee29d54f2f2ca5),
|
||||
("ec.sim.particleplayground/3/8bpc/t0.8", 0x212121b5d3ff40f5),
|
||||
("ec.sim.particleplayground/3/8bpc/t2.2", 0x4b2129a0221866d5),
|
||||
("ec.sim.particleplayground/3/32bpc/t0.5", 0x94901b9480a11505),
|
||||
("ec.sim.particleplayground/3/32bpc/t1.5", 0x18d82bebd984986d),
|
||||
("ec.sim.particleplayground/3/32bpc/t0.8", 0x59b910231e182a8d),
|
||||
("ec.sim.particleplayground/3/32bpc/t2.2", 0x4b2129a0221866d5),
|
||||
("ec.sim.particleplayground/4/8bpc/t0.5", 0xb20c9c68c9e45a88),
|
||||
("ec.sim.particleplayground/4/8bpc/t1.5", 0x4b2129a0221866d5),
|
||||
("ec.sim.particleplayground/4/8bpc/t0.8", 0xdeb3ee1a1a0382d9),
|
||||
("ec.sim.particleplayground/4/8bpc/t2.2", 0x4b2129a0221866d5),
|
||||
("ec.sim.particleplayground/4/32bpc/t0.5", 0x7678784655ad24ef),
|
||||
("ec.sim.particleplayground/4/32bpc/t1.5", 0x4b2129a0221866d5),
|
||||
("ec.sim.particleplayground/4/32bpc/t0.8", 0x2fcf78fef85dc79b),
|
||||
("ec.sim.particleplayground/4/32bpc/t2.2", 0x4b2129a0221866d5),
|
||||
("ec.sim.particleplayground/5/8bpc/t0.5", 0x11c85638b23ca1ad),
|
||||
("ec.sim.particleplayground/5/8bpc/t1.5", 0x0430aedb0bfe9b1d),
|
||||
("ec.sim.particleplayground/5/8bpc/t0.8", 0x848b60fed97e4755),
|
||||
("ec.sim.particleplayground/5/8bpc/t2.2", 0xe06dc84db33e7429),
|
||||
("ec.sim.particleplayground/5/32bpc/t0.5", 0x0195318b4db583a1),
|
||||
("ec.sim.particleplayground/5/32bpc/t1.5", 0x0f5e6c80a182d47d),
|
||||
("ec.sim.particleplayground/5/32bpc/t0.8", 0xfe3ce304bf789bcd),
|
||||
("ec.sim.particleplayground/5/32bpc/t2.2", 0x8dd7ed29d632643d),
|
||||
("ec.sim.particleplayground/6/8bpc/t0.5", 0xb04e21f3c9ee8955),
|
||||
("ec.sim.particleplayground/6/8bpc/t1.5", 0x3e9b871d87e66255),
|
||||
("ec.sim.particleplayground/6/8bpc/t0.8", 0x9052ebc3a39db605),
|
||||
("ec.sim.particleplayground/6/8bpc/t2.2", 0x4b2129a0221866d5),
|
||||
("ec.sim.particleplayground/6/32bpc/t0.5", 0xb59ff67f1e4fdd55),
|
||||
("ec.sim.particleplayground/6/32bpc/t1.5", 0x1ac6b864503401c5),
|
||||
("ec.sim.particleplayground/6/32bpc/t0.8", 0x16a5d9d93e9c95c5),
|
||||
("ec.sim.particleplayground/6/32bpc/t2.2", 0x4b2129a0221866d5),
|
||||
("ec.sim.particleplayground/7/8bpc/t0.5", 0x5587b4a20830fbe1),
|
||||
("ec.sim.particleplayground/7/8bpc/t1.5", 0xcdf7191b5cad91f5),
|
||||
("ec.sim.particleplayground/7/8bpc/t0.8", 0x6e4571273b2d8959),
|
||||
("ec.sim.particleplayground/7/8bpc/t2.2", 0x4b2129a0221866d5),
|
||||
("ec.sim.particleplayground/7/32bpc/t0.5", 0x5080db75b8825039),
|
||||
("ec.sim.particleplayground/7/32bpc/t1.5", 0x9070b3c2bfa25b29),
|
||||
("ec.sim.particleplayground/7/32bpc/t0.8", 0xd406da6427e4b62d),
|
||||
("ec.sim.particleplayground/7/32bpc/t2.2", 0x4b2129a0221866d5),
|
||||
("ec.sim.particleplayground/8/8bpc/t0.5", 0x160e670965dffcd1),
|
||||
("ec.sim.particleplayground/8/8bpc/t1.5", 0xd3a908531f629a05),
|
||||
("ec.sim.particleplayground/8/8bpc/t0.8", 0x70d54b3670a26555),
|
||||
("ec.sim.particleplayground/8/8bpc/t2.2", 0xbd22bfa694d189fd),
|
||||
("ec.sim.particleplayground/8/32bpc/t0.5", 0x8630bbc5c1602bb9),
|
||||
("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/2/8bpc/t0.5", 0x0b6bf26753ee4582),
|
||||
("ec.sim.ccballaction/2/8bpc/t1.5", 0x0b6bf26753ee4582),
|
||||
("ec.sim.ccballaction/2/8bpc/t0.8", 0x0b6bf26753ee4582),
|
||||
("ec.sim.ccballaction/2/8bpc/t2.2", 0x0b6bf26753ee4582),
|
||||
("ec.sim.ccballaction/2/32bpc/t0.5", 0x845e2c5c2719c336),
|
||||
("ec.sim.ccballaction/2/32bpc/t1.5", 0x845e2c5c2719c336),
|
||||
("ec.sim.ccballaction/2/32bpc/t0.8", 0x845e2c5c2719c336),
|
||||
("ec.sim.ccballaction/2/32bpc/t2.2", 0x845e2c5c2719c336),
|
||||
("ec.sim.ccpixelpolly/0/8bpc/t0.5", 0x793db4214db81d01),
|
||||
("ec.sim.ccpixelpolly/0/8bpc/t1.5", 0xf69cf7f742757382),
|
||||
("ec.sim.ccpixelpolly/0/8bpc/t0.8", 0xa81ebe4ddeab9b83),
|
||||
("ec.sim.ccpixelpolly/0/8bpc/t2.2", 0x8d6af96aa12b70ac),
|
||||
("ec.sim.ccpixelpolly/0/32bpc/t0.5", 0x3d03f23d9a915b5e),
|
||||
("ec.sim.ccpixelpolly/0/32bpc/t1.5", 0x1c6a52023b0e21d0),
|
||||
("ec.sim.ccpixelpolly/0/32bpc/t0.8", 0x6041c4d2944492e3),
|
||||
("ec.sim.ccpixelpolly/0/32bpc/t2.2", 0x589763c3342ee81d),
|
||||
("ec.sim.ccpixelpolly/0/8bpc/half/t0.5", 0x3d7bf2e96b64f5a5),
|
||||
("ec.sim.ccpixelpolly/0/8bpc/half/t1.5", 0x24da849dfc0c1700),
|
||||
("ec.sim.ccpixelpolly/0/8bpc/half/t0.8", 0x67992ff4eb32c1c5),
|
||||
("ec.sim.ccpixelpolly/0/8bpc/half/t2.2", 0xdf434cacd5ad0471),
|
||||
("ec.sim.ccpixelpolly/1/8bpc/t0.5", 0xf953bd43d910c59e),
|
||||
("ec.sim.ccpixelpolly/1/8bpc/t1.5", 0x7fa196f56e470219),
|
||||
("ec.sim.ccpixelpolly/1/8bpc/t0.8", 0x1f545b2172052197),
|
||||
("ec.sim.ccpixelpolly/1/8bpc/t2.2", 0xd5eb9e120765f877),
|
||||
("ec.sim.ccpixelpolly/1/32bpc/t0.5", 0xdb57e39c1f6df9f2),
|
||||
("ec.sim.ccpixelpolly/1/32bpc/t1.5", 0x9710c951b521ccd2),
|
||||
("ec.sim.ccpixelpolly/1/32bpc/t0.8", 0x1cc528553c49dfa9),
|
||||
("ec.sim.ccpixelpolly/1/32bpc/t2.2", 0x8f73c69e50a6ce05),
|
||||
("ec.sim.ccpixelpolly/2/8bpc/t0.5", 0x81720809859326c3),
|
||||
("ec.sim.ccpixelpolly/2/8bpc/t1.5", 0x6bd1dee807745400),
|
||||
("ec.sim.ccpixelpolly/2/8bpc/t0.8", 0x41d97e82c0554490),
|
||||
("ec.sim.ccpixelpolly/2/8bpc/t2.2", 0x80def64ff166e725),
|
||||
("ec.sim.ccpixelpolly/2/32bpc/t0.5", 0x10ab39b8f37c10dd),
|
||||
("ec.sim.ccpixelpolly/2/32bpc/t1.5", 0xe66c3cc61794a13d),
|
||||
("ec.sim.ccpixelpolly/2/32bpc/t0.8", 0x8a5fc3d42b56d274),
|
||||
("ec.sim.ccpixelpolly/2/32bpc/t2.2", 0x9b493296a9819722),
|
||||
("ec.sim.ccpixelpolly/3/8bpc/t0.5", 0x12b4b0832fc06783),
|
||||
("ec.sim.ccpixelpolly/3/8bpc/t1.5", 0xe0095bedb7b3b17d),
|
||||
("ec.sim.ccpixelpolly/3/8bpc/t0.8", 0x073b454632a54acc),
|
||||
("ec.sim.ccpixelpolly/3/8bpc/t2.2", 0x5e0f61b3400d0b2e),
|
||||
("ec.sim.ccpixelpolly/3/32bpc/t0.5", 0x014913b7c76771d3),
|
||||
("ec.sim.ccpixelpolly/3/32bpc/t1.5", 0x7117b63447e076c3),
|
||||
("ec.sim.ccpixelpolly/3/32bpc/t0.8", 0xb4c7fe2497dcf95c),
|
||||
("ec.sim.ccpixelpolly/3/32bpc/t2.2", 0xd9fd060aaf88f744),
|
||||
("ec.sim.ccscatterize/0/8bpc/t0.5", 0x8ad88caae775ea83),
|
||||
("ec.sim.ccscatterize/0/8bpc/t1.5", 0x8ad88caae775ea83),
|
||||
("ec.sim.ccscatterize/0/8bpc/t0.8", 0x8ad88caae775ea83),
|
||||
("ec.sim.ccscatterize/0/8bpc/t2.2", 0x8ad88caae775ea83),
|
||||
("ec.sim.ccscatterize/0/32bpc/t0.5", 0xe2b8332b96a1c76e),
|
||||
("ec.sim.ccscatterize/0/32bpc/t1.5", 0xe2b8332b96a1c76e),
|
||||
("ec.sim.ccscatterize/0/32bpc/t0.8", 0xe2b8332b96a1c76e),
|
||||
("ec.sim.ccscatterize/0/32bpc/t2.2", 0xe2b8332b96a1c76e),
|
||||
("ec.sim.ccscatterize/0/8bpc/half/t0.5", 0x730351fffb20e0c8),
|
||||
("ec.sim.ccscatterize/0/8bpc/half/t1.5", 0x730351fffb20e0c8),
|
||||
("ec.sim.ccscatterize/0/8bpc/half/t0.8", 0x730351fffb20e0c8),
|
||||
("ec.sim.ccscatterize/0/8bpc/half/t2.2", 0x730351fffb20e0c8),
|
||||
("ec.sim.ccscatterize/1/8bpc/t0.5", 0x675147db65b68b95),
|
||||
("ec.sim.ccscatterize/1/8bpc/t1.5", 0x675147db65b68b95),
|
||||
("ec.sim.ccscatterize/1/8bpc/t0.8", 0x675147db65b68b95),
|
||||
("ec.sim.ccscatterize/1/8bpc/t2.2", 0x675147db65b68b95),
|
||||
("ec.sim.ccscatterize/1/32bpc/t0.5", 0x6d822bb814b2dbe8),
|
||||
("ec.sim.ccscatterize/1/32bpc/t1.5", 0x6d822bb814b2dbe8),
|
||||
("ec.sim.ccscatterize/1/32bpc/t0.8", 0x6d822bb814b2dbe8),
|
||||
("ec.sim.ccscatterize/1/32bpc/t2.2", 0x6d822bb814b2dbe8),
|
||||
("ec.sim.ccscatterize/2/8bpc/t0.5", 0xd1f4144884af1673),
|
||||
("ec.sim.ccscatterize/2/8bpc/t1.5", 0xd1f4144884af1673),
|
||||
("ec.sim.ccscatterize/2/8bpc/t0.8", 0xd1f4144884af1673),
|
||||
("ec.sim.ccscatterize/2/8bpc/t2.2", 0xd1f4144884af1673),
|
||||
("ec.sim.ccscatterize/2/32bpc/t0.5", 0x95f58900dc6d6f58),
|
||||
("ec.sim.ccscatterize/2/32bpc/t1.5", 0x95f58900dc6d6f58),
|
||||
("ec.sim.ccscatterize/2/32bpc/t0.8", 0x95f58900dc6d6f58),
|
||||
("ec.sim.ccscatterize/2/32bpc/t2.2", 0x95f58900dc6d6f58),
|
||||
("ec.noise.curlnoise/0/8bpc/t0.5", 0xce5b0d9a6bbe529c),
|
||||
("ec.noise.curlnoise/0/8bpc/t1.5", 0xce5b0d9a6bbe529c),
|
||||
("ec.noise.curlnoise/0/8bpc/t0.8", 0xce5b0d9a6bbe529c),
|
||||
("ec.noise.curlnoise/0/8bpc/t2.2", 0xce5b0d9a6bbe529c),
|
||||
("ec.noise.curlnoise/0/32bpc/t0.5", 0x18de53fb08fbec6c),
|
||||
("ec.noise.curlnoise/0/32bpc/t1.5", 0x18de53fb08fbec6c),
|
||||
("ec.noise.curlnoise/0/32bpc/t0.8", 0x18de53fb08fbec6c),
|
||||
("ec.noise.curlnoise/0/32bpc/t2.2", 0x18de53fb08fbec6c),
|
||||
("ec.noise.curlnoise/0/8bpc/half/t0.5", 0x00124f8f5a0bb582),
|
||||
("ec.noise.curlnoise/0/8bpc/half/t1.5", 0x00124f8f5a0bb582),
|
||||
("ec.noise.curlnoise/0/8bpc/half/t0.8", 0x00124f8f5a0bb582),
|
||||
("ec.noise.curlnoise/0/8bpc/half/t2.2", 0x00124f8f5a0bb582),
|
||||
("ec.noise.curlnoise/1/8bpc/t0.5", 0x73e04e5ca0589de4),
|
||||
("ec.noise.curlnoise/1/8bpc/t1.5", 0x73e04e5ca0589de4),
|
||||
("ec.noise.curlnoise/1/8bpc/t0.8", 0x73e04e5ca0589de4),
|
||||
("ec.noise.curlnoise/1/8bpc/t2.2", 0x73e04e5ca0589de4),
|
||||
("ec.noise.curlnoise/1/32bpc/t0.5", 0x111d2c248e7b334b),
|
||||
("ec.noise.curlnoise/1/32bpc/t1.5", 0x111d2c248e7b334b),
|
||||
("ec.noise.curlnoise/1/32bpc/t0.8", 0x111d2c248e7b334b),
|
||||
("ec.noise.curlnoise/1/32bpc/t2.2", 0x111d2c248e7b334b),
|
||||
("ec.noise.curlnoise/2/8bpc/t0.5", 0xe62ab777e41bf94e),
|
||||
("ec.noise.curlnoise/2/8bpc/t1.5", 0xe62ab777e41bf94e),
|
||||
("ec.noise.curlnoise/2/8bpc/t0.8", 0xe62ab777e41bf94e),
|
||||
("ec.noise.curlnoise/2/8bpc/t2.2", 0xe62ab777e41bf94e),
|
||||
("ec.noise.curlnoise/2/32bpc/t0.5", 0xd477a194b7a2d123),
|
||||
("ec.noise.curlnoise/2/32bpc/t1.5", 0xd477a194b7a2d123),
|
||||
("ec.noise.curlnoise/2/32bpc/t0.8", 0xd477a194b7a2d123),
|
||||
("ec.noise.curlnoise/2/32bpc/t2.2", 0xd477a194b7a2d123),
|
||||
];
|
||||
@@ -0,0 +1,239 @@
|
||||
//! Golden hashes of the CPU Timewarp (M13.29), with and without a Matte Layer.
|
||||
//!
|
||||
//! Timewarp's frame building is shared with the GPU compositor as a plan
|
||||
//! (`effectcraft_effects::timewarp_plan`); this pins the CPU output of every method / Show /
|
||||
//! Matte Channel combination, with motion blur and a Warp Layer, so refactoring the plan keeps
|
||||
//! it bit-identical. Same hashing and re-pinning (`SIM_GOLDEN_PRINT=1`) as `sim_golden.rs`;
|
||||
//! pinned for aarch64 macOS.
|
||||
|
||||
use effectcraft_effects::{Buf, EffectCtx, EffectEnv, EffectHost, LayerPixels, Params, apply, default_value, find};
|
||||
use effectcraft_keyframe::Value;
|
||||
use effectcraft_raster::Image;
|
||||
|
||||
const W: u32 = 48;
|
||||
const H: u32 = 32;
|
||||
const FPS: f64 = 10.0;
|
||||
/// Layer ids served by [`Host`]: the same texture standing still (a Warp Layer), a matte white
|
||||
/// on its left part with a soft edge, and a luminance matte.
|
||||
const STILL: u64 = 7;
|
||||
const MATTE: u64 = 8;
|
||||
const LUMA: u64 = 9;
|
||||
|
||||
/// A texture shifted right by `dx` px (premultiplied, partly transparent).
|
||||
fn texture(dx: f64) -> Image {
|
||||
let mut img = Image::new(W, H);
|
||||
for y in 0..H {
|
||||
for x in 0..W {
|
||||
let u = x as f64 - dx;
|
||||
let a = if (10..14).contains(&y) { 0.5 } else { 1.0 };
|
||||
let c = [(0.5 + 0.4 * (u * 0.4).sin()) as f32, (0.5 + 0.4 * (y as f64 * 0.3 + u * 0.1).cos()) as f32, ((u * 0.05).rem_euclid(1.0)) as f32];
|
||||
img.set(x, y, [c[0] * a, c[1] * a, c[2] * a, a]);
|
||||
}
|
||||
}
|
||||
img
|
||||
}
|
||||
|
||||
struct Host;
|
||||
impl EffectHost for Host {
|
||||
fn layer(&self, _: u64, _: bool) -> Option<LayerPixels> {
|
||||
None
|
||||
}
|
||||
fn audio(&self, _: u64, _: f64, _: usize, _: u32) -> Option<Vec<f32>> {
|
||||
None
|
||||
}
|
||||
fn self_at(&self, t: f64, _: usize) -> Option<Buf> {
|
||||
Some(Buf { img: texture((t * FPS).round() * 2.0), offset: [0.0; 2], scale: 1.0 })
|
||||
}
|
||||
fn layer_at(&self, id: u64, t: f64, _: bool) -> Option<LayerPixels> {
|
||||
let img = match id {
|
||||
STILL => texture(0.0),
|
||||
LUMA => {
|
||||
let mut m = Image::new(W, H);
|
||||
for y in 0..H {
|
||||
for x in 0..W {
|
||||
let l = ((x + y) as f32 / (W + H) as f32 + (t * 0.3) as f32).fract();
|
||||
m.set(x, y, [l, l, l, 1.0]);
|
||||
}
|
||||
}
|
||||
m
|
||||
}
|
||||
_ => {
|
||||
let mut m = Image::new(W, H);
|
||||
let edge = 20.0 + (t * FPS).round() * 1.5;
|
||||
for y in 0..H {
|
||||
for x in 0..W {
|
||||
let a = ((edge - x as f64) / 3.0).clamp(0.0, 1.0) as f32;
|
||||
m.set(x, y, [a, a, a, a]);
|
||||
}
|
||||
}
|
||||
m
|
||||
}
|
||||
};
|
||||
Some(LayerPixels { buf: Buf { img, offset: [0.0; 2], scale: 1.0 }, size: [W as f64, H as f64] })
|
||||
}
|
||||
}
|
||||
|
||||
fn n(v: f64) -> Value {
|
||||
Value::Scalar(v)
|
||||
}
|
||||
fn e(v: u32) -> Value {
|
||||
Value::Enum(v)
|
||||
}
|
||||
fn l(id: u64) -> Value {
|
||||
Value::Layer(Some(id))
|
||||
}
|
||||
|
||||
type Set = Vec<(&'static str, Value)>;
|
||||
|
||||
fn cases() -> Vec<Set> {
|
||||
let mut v: Vec<Set> = vec![vec![], vec![("method", e(0))], vec![("method", e(1))]];
|
||||
for method in 0..3 {
|
||||
for show in 0..4 {
|
||||
v.push(vec![("method", e(method)), ("matteLayer", l(MATTE)), ("show", e(show)), ("speed", n(37.0))]);
|
||||
}
|
||||
}
|
||||
for ch in 1..4 {
|
||||
v.push(vec![("matteLayer", l(LUMA)), ("matteChannel", e(ch)), ("speed", n(63.0))]);
|
||||
}
|
||||
v.push(vec![("matteLayer", l(MATTE)), ("warpLayer", l(STILL)), ("speed", n(41.0))]);
|
||||
v.push(vec![("matteLayer", l(MATTE)), ("motionBlur/enableMotionBlur", Value::Bool(true)), ("motionBlur/shutterSamples", n(3.0)), ("show", e(1))]);
|
||||
v.push(vec![("matteLayer", l(MATTE)), ("method", e(1)), ("tuning/buildFromOneImage", Value::Bool(true)), ("show", e(2))]);
|
||||
v.push(vec![("matteLayer", l(MATTE)), ("tuning/buildFromOneImage", Value::Bool(true)), ("speed", n(28.0))]);
|
||||
v.push(vec![("matteLayer", l(MATTE)), ("adjustTimeBy", e(1)), ("sourceFrame", n(4.4)), ("show", e(3))]);
|
||||
v
|
||||
}
|
||||
|
||||
const TIMES: [f64; 3] = [0.55, 1.23, 0.8];
|
||||
|
||||
fn fnv(img: &Image) -> u64 {
|
||||
let mut h = 0xcbf2_9ce4_8422_2325u64;
|
||||
for b in [img.width, img.height].iter().flat_map(|v| v.to_le_bytes()) {
|
||||
h = (h ^ b as u64).wrapping_mul(0x100_0000_01b3);
|
||||
}
|
||||
for p in &img.data {
|
||||
for c in p {
|
||||
for b in c.to_bits().to_le_bytes() {
|
||||
h = (h ^ b as u64).wrapping_mul(0x100_0000_01b3);
|
||||
}
|
||||
}
|
||||
}
|
||||
h
|
||||
}
|
||||
|
||||
fn render(set: &Set, time: f64) -> Image {
|
||||
let spec = find("ec.time.timewarp").unwrap();
|
||||
let size = [W as f64, H as f64];
|
||||
let mut params = Params { values: spec.params.iter().map(|p| (p.id.to_string(), default_value(p, size))).collect() };
|
||||
for (k, v) in set {
|
||||
assert!(params.values.contains_key(*k), "unknown param {k}");
|
||||
params.values.insert(k.to_string(), v.clone());
|
||||
}
|
||||
let host = Host;
|
||||
let env = EffectEnv { host: Some(&host), frame_rate: FPS, comp_time: time, ..Default::default() };
|
||||
let ctx = EffectCtx { params: ¶ms, time, layer_size: size, seed: 1, adjustment: false, env };
|
||||
apply(spec, &ctx, Buf { img: texture(0.0), offset: [0.0; 2], scale: 1.0 }).img
|
||||
}
|
||||
|
||||
fn hashes() -> Vec<(String, u64)> {
|
||||
let mut v = Vec::new();
|
||||
for (si, set) in cases().iter().enumerate() {
|
||||
for t in TIMES {
|
||||
v.push((format!("timewarp/{si}/t{t}"), fnv(&render(set, t))));
|
||||
}
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn timewarp_golden_hashes() {
|
||||
let got = hashes();
|
||||
if std::env::var_os("SIM_GOLDEN_PRINT").is_some() {
|
||||
for (name, h) in &got {
|
||||
println!(" (\"{name}\", 0x{h:016x}),");
|
||||
}
|
||||
}
|
||||
assert_eq!(got, hashes(), "Timewarp renders deterministically");
|
||||
if cfg!(all(target_os = "macos", target_arch = "aarch64")) {
|
||||
let bad: Vec<String> = got
|
||||
.iter()
|
||||
.zip(GOLDEN)
|
||||
.filter(|((n, h), (gn, gh))| n != gn || h != gh)
|
||||
.map(|((n, h), (_, gh))| format!("{n}: 0x{h:016x} (pinned 0x{gh:016x})"))
|
||||
.collect();
|
||||
assert_eq!(got.len(), GOLDEN.len(), "case count");
|
||||
assert!(bad.is_empty(), "CPU output changed:\n{}", bad.join("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
/// Pinned hashes (aarch64 macOS).
|
||||
const GOLDEN: &[(&str, u64)] = &[
|
||||
("timewarp/0/t0.55", 0x85905ea4083d5052),
|
||||
("timewarp/0/t1.23", 0x6499c6f962fed8e7),
|
||||
("timewarp/0/t0.8", 0x48493cd23ed32a5f),
|
||||
("timewarp/1/t0.55", 0x9eca0f14f7cb2d95),
|
||||
("timewarp/1/t1.23", 0xd0c16d4df51315b4),
|
||||
("timewarp/1/t0.8", 0x48493cd23ed32a5f),
|
||||
("timewarp/2/t0.55", 0x9d3703747d8e5b7f),
|
||||
("timewarp/2/t1.23", 0xa9ea3d660b9fd38b),
|
||||
("timewarp/2/t0.8", 0x48493cd23ed32a5f),
|
||||
("timewarp/3/t0.55", 0x9eca0f14f7cb2d95),
|
||||
("timewarp/3/t1.23", 0x48493cd23ed32a5f),
|
||||
("timewarp/3/t0.8", 0x9eca0f14f7cb2d95),
|
||||
("timewarp/4/t0.55", 0x91cbdc02063b9105),
|
||||
("timewarp/4/t1.23", 0x6060a22b299bc92d),
|
||||
("timewarp/4/t0.8", 0x91cbdc02063b9105),
|
||||
("timewarp/5/t0.55", 0xc2e2170269f47324),
|
||||
("timewarp/5/t1.23", 0x3cea3a307e21500d),
|
||||
("timewarp/5/t0.8", 0xc2e2170269f47324),
|
||||
("timewarp/6/t0.55", 0xe55ce2acace7ba15),
|
||||
("timewarp/6/t1.23", 0x6a90b9e251de6d15),
|
||||
("timewarp/6/t0.8", 0xe55ce2acace7ba15),
|
||||
("timewarp/7/t0.55", 0x54020055b7d248c6),
|
||||
("timewarp/7/t1.23", 0x48d89e15e1f7801c),
|
||||
("timewarp/7/t0.8", 0x628bc4aba205a8a8),
|
||||
("timewarp/8/t0.55", 0x467f6294e2c06d6c),
|
||||
("timewarp/8/t1.23", 0xfd442392677e46ad),
|
||||
("timewarp/8/t0.8", 0xc26b69bf0e79c9c3),
|
||||
("timewarp/9/t0.55", 0xd2fddb3350b55277),
|
||||
("timewarp/9/t1.23", 0x16807a7efa8f989a),
|
||||
("timewarp/9/t0.8", 0xb6a045bcaccdc2a2),
|
||||
("timewarp/10/t0.55", 0xa86ae0542d872015),
|
||||
("timewarp/10/t1.23", 0x86dba3262d03f3d5),
|
||||
("timewarp/10/t0.8", 0xfc37965f9c2e51d5),
|
||||
("timewarp/11/t0.55", 0x240ee936695325a8),
|
||||
("timewarp/11/t1.23", 0x7fe2ff24fedcd3f1),
|
||||
("timewarp/11/t0.8", 0xd57ed4c5bfca415e),
|
||||
("timewarp/12/t0.55", 0xad462efd17ecf4be),
|
||||
("timewarp/12/t1.23", 0xd05b6e67e92eaf90),
|
||||
("timewarp/12/t0.8", 0xcc3f297acfa6b646),
|
||||
("timewarp/13/t0.55", 0x80821631b420f5fc),
|
||||
("timewarp/13/t1.23", 0x69ef153147214217),
|
||||
("timewarp/13/t0.8", 0xe81297c3aa0752fe),
|
||||
("timewarp/14/t0.55", 0x79ff11a84d24d2f4),
|
||||
("timewarp/14/t1.23", 0x54fccecd7a87efb5),
|
||||
("timewarp/14/t0.8", 0x0055f9cce950e80f),
|
||||
("timewarp/15/t0.55", 0x193233cd7098d460),
|
||||
("timewarp/15/t1.23", 0x0171866bfbe232b3),
|
||||
("timewarp/15/t0.8", 0x5a15d4a6e85931d7),
|
||||
("timewarp/16/t0.55", 0x0d4df26b38ca39a0),
|
||||
("timewarp/16/t1.23", 0x7502f65ccf41ce0e),
|
||||
("timewarp/16/t0.8", 0x39b6e04e7935b0fe),
|
||||
("timewarp/17/t0.55", 0x99ae36e79014f5dc),
|
||||
("timewarp/17/t1.23", 0xa844571a39e97251),
|
||||
("timewarp/17/t0.8", 0x2e6961e16f50eec6),
|
||||
("timewarp/18/t0.55", 0x9d6d36c8d9303a6e),
|
||||
("timewarp/18/t1.23", 0x63794786e758ad00),
|
||||
("timewarp/18/t0.8", 0x2bc9775fc6f5723e),
|
||||
("timewarp/19/t0.55", 0x11c1925988c75ab0),
|
||||
("timewarp/19/t1.23", 0x19c13bccca289b25),
|
||||
("timewarp/19/t0.8", 0x7f5ec6ec4c3a2aeb),
|
||||
("timewarp/20/t0.55", 0x386ca6db13d4675b),
|
||||
("timewarp/20/t1.23", 0xaee266701f5f9936),
|
||||
("timewarp/20/t0.8", 0x3cea3a307e21500d),
|
||||
("timewarp/21/t0.55", 0x21f0abd02bad8359),
|
||||
("timewarp/21/t1.23", 0xe8c75365a1d6505a),
|
||||
("timewarp/21/t0.8", 0x3ee1c9c17c7760a1),
|
||||
("timewarp/22/t0.55", 0xdc518b5e0fc85047),
|
||||
("timewarp/22/t1.23", 0xdc518b5e0fc85047),
|
||||
("timewarp/22/t0.8", 0xdc518b5e0fc85047),
|
||||
];
|
||||
Reference in New Issue
Block a user