[sharing is fun] Fluid simulation on the GPU
Attached is a Max patch that implements a simple fluid simulation using gen – jit.gl.pix. The simulation runs on the GPU and improves speed comparing to the MSA Fluid java version.
In this exemple, the fluid is controlled using an optical flow shader (from Andrew Benson) applied on the live camera image. The source colors are given by a background "mask" image; you can also create static obstacles by sending an obstacle mask texture (dynamic obstacles that takes into account obstacle velocities are not implemented in this exemple).
Boundary Conditions are managed within a 1 pixel border that is added to the source textures and removed before displaying the simulation : if you choose a resolution of 320×240, the real size of the simulation is 322×242.
The fluid algorithm uses 20 Jacobi iterations (40 will be better); this part of the algorithm is very heavy on frame rate and the most efficient (and inelegant) solution I’ve found was to put 20 jit.gl.pix modules in series. If some jitter gurus know a better way to do iteration, or to improve the efficiency of this exemple, I will be happy to update this patch.
: I have fixed a bug into the patcher, fluid_gpu1.zip is the correct one
this is genuinely awesome. will study. thanks.
Very impressive and nice.
Only problem is that on my MBP Retina, Max UI freezes when I open the camera (but the patch keeps on running, so I can see the fluids in jit.window).
Thanks for sharing.
wow very cool, tanks man !
Sweet Jesus that’s awesome!
Wonderful, thanks a lot!
Demonstrates the power of the Jitter dance !!!
Thanks and respect