EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Normalize cardinal Wave Warp directions to preserve CPU and GPU parity.
Vikram Bhaskaran31d74e268d9c
diff --git a/crates/effects/src/distort.rs b/crates/effects/src/distort.rsindex 7617fab25..534da8061 100644--- a/crates/effects/src/distort.rs+++ b/crates/effects/src/distort.rs@@ -164,7 +164,10 @@ fn wave_warp(ctx: &EffectCtx, mut b: Buf) -> Buf {let kind = ctx.params.e("waveType");let pin = ctx.params.e("pinning");let seed = ctx.seed ^ 0x3a7e;- let (dx, dy) = (dir.sin(), -dir.cos());+ // Cardinal directions must not acquire a tiny perpendicular slope: at a square-wave+ // boundary cos(90°)'s rounding residue can flip a whole column on CPU but not GPU.+ let axis = |v: f64| if v.abs() < 4.0 * f64::EPSILON { 0.0 } else { v };+ let (dx, dy) = (axis(dir.sin()), -axis(dir.cos()));if !ctx.adjustment {b.pad(h.abs().ceil() as u32 + 1);}diff --git a/crates/gpu/src/fx_distort.rs b/crates/gpu/src/fx_distort.rsindex a62ad6831..ce7133822 100644--- a/crates/gpu/src/fx_distort.rs+++ b/crates/gpu/src/fx_distort.rs@@ -111,7 +111,10 @@ fn wave_warp(e: &mut Enc, ctx: &EffectCtx, mut b: GBuf) -> Option<GBuf> {let dir = ctx.params.f("direction").to_radians();let speed = ctx.params.f("speed");let phase = ctx.params.f("phase").to_radians() + ctx.time * speed * TAU;- let (dx, dy) = (dir.sin(), -dir.cos());+ // Cardinal directions must not acquire a tiny perpendicular slope: at a square-wave+ // boundary cos(90°)'s rounding residue can flip a whole column on CPU but not GPU.+ let axis = |v: f64| if v.abs() < 4.0 * f64::EPSILON { 0.0 } else { v };+ let (dx, dy) = (axis(dir.sin()), -axis(dir.cos()));if !ctx.adjustment {b.pad(e, h.abs().ceil() as u32 + 1)?;}