Forums > Jitter

[sharing is fun] Fluid simulation on the GPU


JMC
August 14, 2014 | 2:06 am

Hello,

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.

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

enjoy!

JMC

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

  • This topic was modified 3 weeks by  JMC.
  • This topic was modified 3 weeks by  JMC.

August 14, 2014 | 3:33 am

this is genuinely awesome. will study. thanks.



pry
August 14, 2014 | 3:19 pm

Hi JMC,

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.

pry


August 14, 2014 | 3:32 pm

wow very cool, tanks man !


August 15, 2014 | 8:42 am

wonderful!


August 15, 2014 | 11:39 am

Sweet Jesus that’s awesome!



Ste
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)