525 points · by nmstoker · 2y ago · 52 comments
Why?
Having thousands of particles, all in need of doing the same operations on them in parallel screams GPU to me. It is just way harder to program a GPU, vs a CPU.
It's like a visual stim toy
I will see if I can bring it to WebAudio.
It's possible to simulate using a grid instead, and that computes pressure very precisely, but it has a downside of adding inaccurate viscosity.
And there are tricks that combine both approaches to balance out the errors.
There are also some large density ratios between the materials which further increased the difficulty, and would also increase the number of pressure projection iterations on a grid. I tried to simulate buoyancy without cheating (e.g. giving different materials different acceleration to gravity)
From the description of "WebAssembly Liquid Simulator" https://www.youtube.com/watch?v=phXwC6HxWEQ
Incredible stuff.
Sometimes for sandbox I feel like 2D can be more fun because people can target particles they interact with better.
Maybe WebXR will be good for the 3D version.