Preview and work in progress: I'm building a FluidSimulation for FastLED

StefanPetrick

Well-known member
The first tests are pretty promising. On an ESP32 it runs (without any optimisation yet) already with >30 fps on a 48x32 WS2812 matrix. So on a Teensy 4 + high res LED matrix this will fly. I guess we'll end up with a float-FPU version for Teensy and ESP32S3 and with a seperate fixed point version for MCUs without FPU.

It is a 2D Navier Stokes solver and I'm really impressed that this works at all on an MCU. It is a cell based solver which simulates advection and diffusion of a newtonian fluid. This can create mesmerazing procedural animations. Depending on the parameters settings stuff like dye in water, oil, smoke flow can be visualized.

Here a plain and simple real world LED example:


Here some simulation screen grabs:

(Please note, that the smoke flows around the letters - they work as obstacles for the flow.)




The current code can be found here.

Here the Reddit post.

Here some discussion around it.

To be continued. Consider this to be an early preview. Later it will become part of the FastLED library.
While talking about it: FlowField is already part of FastLED.

Reddit post + Video.


https://www.youtube.com/shorts/3AAFi8B1Ygs
 
Last edited:
Very cool, thank you for sharing! Please say something about your simulation approach! Incompressible approximation or are you using a spectral method?

I use a grid-based Eulerian pipeline: diffuse, project, advect, project again

It is an approximation in the sense that the project step enforces an approximately divergence-free velocity field.

And what's your framerate and matrix size?
 
Today I build something more complex - I'm simulating a coupled system of flow, heat, and smoke.

The flow moves heat and smoke
the heat creates flow
cooling heat creates smoke
and the renderer maps those fields into a flame appearance.

 
Hi guys, I’m not sure whether you enjoy these updates or find them a bit too frequent. But I’m sharing them because feedback from potential users — and even silent lurkers — genuinely helps shape the project. It tells me what to improve, which features are interesting, and where this could evolve next.

So please feel warmly invited to ask questions, comment, criticize, suggest ideas, or just share impressions. I really mean it.

Latest update from the C++ port by Jeff Holman:


Right now, an ESP32-P4 is reaching around 25 fps on a 64×48 WS2812 matrix with 20 solver iterations. This is going far better than I could have imagined.

And this Reddit video is a short narrated walkthrough showing some of the debug views I use to monitor the solver’s internal state during development.

Here one of the latest simulator runs:

 
Last edited:
Today I explored a more artistic way of visualizing the solver data. Since the velocity field is already being calculated internally anyway, I reused it as a brightness mask for the final render output. Add a bit of saturation and brightness boost on top — and this is the result:


It’s not meant to look “realistic” — it’s meant to simply look beautiful.

Meanwhile, the C++ port is continuing to make good progress, and pixel throughput has now improved to around 30 fps on a 64×48 WS2812 matrix. I'll report in detail in a separate post how we optimized the solver.
 
Back
Top