Skip to content

research: state-of-the-art alternatives to super-sample for visual quality in 2D wave PDE (Wave2d / WaveFx) — define research bot + search catalog #3111

Closed

Description

@zackees

Problem framing

fl::WaveSimulation2D (and the WaveFx effect on top of it) currently produces visual quality by brute force: simulate at a k× higher-resolution internal grid, run k time-steps per displayed frame, then downsample. With the current implementation in src/fl/math/wave/wave_simulation.cpp.hpp:

mMultiplier = static_cast<u32>(factor);
u32 w = width  * mMultiplier;
u32 h = height * mMultiplier;
mSim = fl::make_unique<WaveSimulation2D_Real>(w, h, speed, dampening);
mExtraFrames = u8(factor) - 1;  // run mExtraFrames + 1 updates per displayed frame
SuperSample Cells Updates/frame Total work multiplier
NONE (1×) 1× 1 1× (baseline)
2X 4× 2 8×
4X 16× 4 64×
8X 64× 8 512×

Most users running WaveFx at SUPER_SAMPLE_2X or _4X are paying 8–64× the scalar baseline cost almost entirely to get an anti-aliasing-like averaging effect on the output, plus a side benefit of reduced 5-point-stencil anisotropy (already partially addressed by #3104's opt-in 9-point isotropic Laplacian). That's a very expensive way to anti-alias.

Research question: What does the math / CS / embedded-graphics state of the art look like for keeping a real-time 2D wave PDE running at the native LED grid resolution (1× cells, 1 update per displayed frame) while matching the perceived visual quality of a 2–4× super-sampled scalar simulation? Specifically:

  1. Anti-aliasing without super-sampling. Screen-space filtering, temporal anti-aliasing, MIP-style downsample of intermediate state — what is the actual visual cost of decoupling AA from the time integration?
  2. Higher-order spatial discretizations. Compact O(h⁴) / O(h⁶) stencils, mass-lumping, modified-equation corrections — can these match super-sample quality at the same grid resolution?
  3. Better time integration. ADI (alternating-direction implicit), operator splitting, larger stable CFL via implicit/semi-implicit schemes — can each step do more work?
  4. Spectral / pseudospectral methods. FFT-based propagation eliminates numerical dispersion but introduces O(N log N) cost — viable on ESP32 / Teensy 4 grid sizes (≤ 64×64)?
  5. Lattice Boltzmann methods (LBM) for wave equations — different formulation, potentially more cache-friendly, comparable cost per cell.
  6. Procedural / non-PDE alternatives. Gerstner waves, FFT ocean waves (Tessendorf), sum-of-sines, additive sinusoid fields — give up physical-PDE correctness, gain O(1)-per-cell-per-frame independent of grid size. May be the right answer for LED art specifically.
  7. Adaptive mesh refinement / sparse grids. Most of the grid is near-zero amplitude most of the time — focus compute on active wave fronts only.
  8. Fixed-point precision tradeoffs. Current code is Q15. Would Q7 or Q8 be enough for visual purposes on small grids? Less memory pressure, faster on AVR.

The deliverable from this research is a definitive recommendation document — not code — comparing approaches with embedded-feasibility scores, citation lists, and a short-list of "land this next" candidates that can then be filed as focused implementation issues (the way the original audit #3073 / #3098 produced #3092–#3097).


Research bot persona

Role: "Embedded LED real-time wave PDE research analyst"

Mission: Survey academic literature, graphics-industry technical articles, and open-source implementations for techniques that improve visual quality or reduce cost of 2D wave-equation simulation in the constraints that FastLED operates under.

Constraints to score every candidate against:

Constraint Why it matters
Native platforms: AVR (Uno), ESP8266, ESP32 / S3 / C6, Teensy 3.x / 4.x, RP2040, LPC8xx Target hardware for FastLED users
Grid sizes: typically 8×8 to 100×100, occasionally up to 256×256 on ESP32+ Real-world LED matrix sizes
Frame rate target: 30–60 fps Smooth animation
RAM budget: from 2 KB (AVR) to 512 KB (ESP32-S3 PSRAM) for the grid Hard limit on grid size + buffers
No FPU on most targets — integer / fixed-point preferred Floating-point is software on AVR/M0
No external libs allowed — no FFTW, no Eigen, no OpenCV Library footprint matters
Visual quality is a perceptual judgment, not RMSE This is art, not science

Skills the bot should bring:

  • Numerical analysis of finite-difference / finite-element / spectral / LBM methods.
  • Real-time graphics literature (game-industry, demoscene, shader-toy).
  • Embedded systems pragmatism — knows when "the math is beautiful but the constant factor kills it".
  • Ability to read a method paper and estimate cycles-per-cell on a Cortex-M4 by inspection.

Output format (per candidate):

### <Method name>
- **Family:** [higher-order stencil / implicit / spectral / LBM / procedural / AA filter / AMR / other]
- **Visual quality vs SUPER_SAMPLE_4X baseline:** [worse / comparable / better]
- **Cost vs 1× scalar baseline (cycles per cell per displayed frame):** [exact figure or band]
- **RAM overhead:** [bytes per cell, plus per-grid overhead]
- **Embeddability score (1–5):**
  - AVR: ?
  - Cortex-M0 (RP2040 / Teensy-LC): ?
  - Cortex-M4/M7 (Teensy 3.x/4.x): ?
  - ESP32 / S3 / C6: ?
- **Key citations:** [paper / article / SIGGRAPH talk]
- **Reference implementations:** [open-source repos]
- **Risk / open question:** [the one thing that might kill this in our context]

End the document with a prioritized short-list of 3–5 candidates worth implementing next, with one-line rationales.


Search-term catalog (organized by approach family)

The bot should use these as starting points, follow citations, and check the last 10 years of literature plus seminal older works.

A. Anti-aliasing decoupled from time integration

  • temporal anti-aliasing wave equation
  • TAA real-time wave simulation
  • screen space anti-aliasing PDE visualization
  • MIP-map output finite difference simulation
  • low-pass filter wave field rendering
  • dithering Q15 wave amplitude visualization
  • subpixel anti-aliasing scalar field rendering

B. Higher-order spatial stencils (the family §5 / #3104 only scratched)

  • compact high-order finite difference Laplacian
  • isotropic Laplacian stencil 9-point 17-point
  • Patra-Karttunen stencil wave equation
  • Kreiss compact scheme wave equation
  • mimetic finite difference Laplacian
  • discrete exterior calculus Laplacian
  • modified equation analysis 2D wave
  • dispersion-corrected FDTD 2D scalar wave
  • H-shifted stencil O(h^4) wave equation

C. Implicit / semi-implicit time integration

  • ADI alternating direction implicit wave equation
  • Crank-Nicolson 2D wave equation
  • Newmark-beta time integration acoustic
  • unconditionally stable explicit wave equation
  • large-CFL wave equation real-time
  • LIM locally implicit method wave PDE
  • operator splitting 2D wave simulation

D. Spectral / pseudospectral

  • pseudospectral wave equation real-time
  • Fourier collocation 2D wave
  • FFT wave equation embedded ARM
  • cosine transform Dirichlet wave equation
  • Chebyshev pseudospectral wave 2D

E. Lattice Boltzmann (LBM)

  • lattice Boltzmann wave equation
  • LBM scalar wave propagation
  • D2Q5 D2Q9 wave equation lattice Boltzmann
  • lattice gas wave propagation cellular automaton

F. Procedural / non-PDE approximations

  • Gerstner waves real-time GPU
  • Tessendorf FFT ocean waves
  • sum of sines water surface
  • Perlin noise wave field synthesis
  • radial basis function ripple simulation
  • wave packet superposition LED art

G. Adaptive / sparse representations

  • adaptive mesh refinement wave equation
  • sparse grid wave PDE
  • octree wave simulation real-time
  • quadtree wave propagation
  • bounding-box culling wave PDE

H. Fixed-point + low-precision

  • 8-bit fixed point wave equation visualization
  • Q7 acoustic simulation embedded
  • posit numbers wave equation
  • block floating point wave PDE
  • INT8 wave field GPU shader

I. Embedded-graphics state of the art (industry-side)

  • Tiny Code Christmas demo wave effect
  • Shadertoy water ripple optimization
  • OLC wave equation tutorial
  • Inigo Quilez SDF ripples
  • realtime water simulation embedded ARM
  • microcontroller fluid simulation

J. Anti-aliasing-specific filters

  • morphological anti-aliasing MLAA SMAA
  • FXAA temporal stabilization
  • bilateral filter scalar field
  • Gaussian pyramid downsampling wave

What to deliver back to this issue

  1. A research report (post as a comment on this issue or as a separate .md in agents/docs/research/wave_pde_alternatives.md) covering at minimum the top 5 candidates from sections A–J, scored against the embeddability matrix.
  2. A short-list of 3–5 PR-able implementation candidates — each with enough detail that someone can file it as a focused sub-issue and start work without re-doing the research.
  3. Counter-examples / explicit non-recommendations — methods the bot investigated and ruled out, with the reason. This is high-value: saves future researchers from re-walking the same dead ends.
  4. A 1-page comparison table of all candidates investigated, with embeddability scores, cost-per-cell, and visual quality vs the SUPER_SAMPLE_4X baseline.

The bot is allowed to recommend "the current super-sample approach is actually near-optimal for these constraints, here's why" — that's a valid conclusion too.


Why this matters

The closed audit issue #3073 / meta #3098 produced six focused PRs (#3083, #3099, #3101, #3103, #3104, #3105, #3110) of scalar-kernel improvements. They incrementally improved the 5-point/9-point explicit leapfrog scheme by maybe 30–50% on the inner loop. SIMD (#3106/#3107/#3108) might add another 2–8×.

But the super-sample factor is 8×–512×. If the right answer turns out to be "drop super-sample entirely and use screen-space anti-aliasing + a compact higher-order stencil", that's a 10×+ visual-quality-per-cycle improvement — orders of magnitude beyond what SIMD or further scalar tuning can deliver.

This is the research that should happen before anyone writes SIMD code for SuperSample 4X.

History / cross-references

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions