Forums > Jitter

[sharing is fun] Fluid simulation on the GPU

August 14, 2014 | 2:06 am


Attached is a Max patch that implements a simple fluid simulation using gen – 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.

To create this example, I’ve started from Philip Rideout exemple, based on the Mark Harris article from GPU Gems 1. I would thanks Rajan Craveri that shared these links with me.

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 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.



[edit]: I have fixed a bug into the patcher, is the correct one

  • This topic was modified 2 months by  JMC.
  • This topic was modified 2 months by  JMC.

August 14, 2014 | 3:33 am

this is genuinely awesome. will study. thanks.

August 14, 2014 | 3:19 pm


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.


August 14, 2014 | 3:32 pm

wow very cool, tanks man !

August 15, 2014 | 8:42 am


August 15, 2014 | 11:39 am

Sweet Jesus that’s awesome!

August 20, 2014 | 12:34 am

Wonderful, thanks a lot!

August 22, 2014 | 3:22 pm

Demonstrates the power of the Jitter dance !!!

Thanks and respect

Viewing 8 posts - 1 through 8 (of 8 total)