openframeworks addon. Combines 2D fluid simulation, optical flow and more using GLSL shaders. Works best with live camera input.
C++ Makefile
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
example cleanup Aug 10, 2016
src hue activated May 16, 2017
.gitignore pi 120 shader Aug 16, 2016
LICENSE Update LICENSE Sep 15, 2015 Update Apr 11, 2016
ofxaddons_thumbnail.png thumbnail added Apr 18, 2014


openframeworks addon. Combines 2D fluid simulation, optical flow and more using GLSL shaders. Works best with live camera input.


  • This version of the addon was created using OSX 10.11 and OF 0.9.3 (OF 0.8.4 version can be found in branches)
  • The addon should work on older versions of OSX, Windows and Linux.
  • dependent on ofxGui.
  • A discrete graphics card is recommended. (thanx to shenberg it is not longer bound to nVidia cards


For my interactive installations I was always attracted to fluid simulations. In the past I used the QuartzComposer fluid simulation, which I rewrote to openCL in Quartz Composer ( ). Due to QC instability issues, especially with openCL (huge memory leaks) I decided to use my kernels in openframeworks using ofxMSAOpenCL. This worked quite nice (, but the process was quite difficult and debugging was a pain in the behind. When I was searching for alternatives, I started using ofxFX and ofxFluid, this convinced my to rewrite my openCL kernels to openGL shaders.

The addon is meant for developers who like to use fluid simulation in combination with a live camera input to create psychedelic live visuals. This is the reason i added optical flow and a simple mask, based on this flow. To understand the different stages of the fluid solver I wanted to be able to visualise all these stages. This meant i had to add a couple of extra draw buffers at the cost of a small performance hit. For optimization it will be more rewarding to work on the internal formats of the ofFbos. I was sad to discover there is only a limited amount of formats available. I ended up using GL_RGBA32F for most buffers where GL_RGBA16F would probably do as well. Even better would be to use GL_RG16F. Most shaders I use are quite simple, so I expect the performance bottlenecks to be the fetching of the textures by the shaders. I also wanted to have some simple draw functions for testing and completion. This turned out to be more time consuming than I expected, simple being the problem here. To complete the addon (what is a fluid sim without particles?) I added experimental GLSL particle engine.

Have fun!


This addon started out as an expansion to ofxFluid by Patricio Gonzalez Vivo also using his ofxFX. While working on it it turned into a separate addon.

The Fluid shaders are adapted from various sources. Unfortunately I can't remember all, but the most important ones:

The Optical Flow Shader is based on a Quartz Composer patch, but was also inspired by ofxMIOFlowGLSL by Princemio

My interest in, and knowledge of, fluid simulation was hugely inspired by the work of Memo Akten. Thanx!



  • Add help screen to the example
  • Comment the code


  • Add Turing patterns: Beautiful!
  • Enhance mask to only use colours from the movement (not the background)

last but not least:

  • Create 3D fluid sim

(c) 2014 Matthias Oostrik