ofxFlowTools: optical flow, fluid dynamics and particles in GLSL

Hi All

I wanted to anounce that after months of work I have finally finished the ofxFlowTools addon.
This addon combines optical flow, fluid dynamics and particles in GLSL.

The beta version was part of ‘Hidden Features’ a dance performance by Antoine July in Dusseldorf. It worked like crazy!

Here is a short introduction video

Hope some of you guys have fun with it!


Wow, very nice! Thanks for sharing!

This looks amazing!

Wow, nice work !
I will have a look on it.

Excellent addon, thanks a lot.
Is there a way to quantify how much of the image changed between two frames ? ftOpticalFlow::getAverageFlow always seem to return 0

That is weird.
Haven’t used that function in a long time though.
I’ll look into it.

Found a bug where the width and height were not set properly.
Fixed now.

just had one problem when compiling in windows + codeblocks

file ftFluidSimulation.h line 77 :

void setDensityFromPressure() {return densityFromPressure.get();}

is returning a value but the function is defined to void,
i guessed it should be a setter like :

void setDensityFromPressure() {densityFromPressure.set();}

but it not sure what parameter to pass, so for a quick fix i just set the function to return a float and it compiled apparently without problems.

you can remove void setDensityFromPressure() {return densityFromPressure.get();} its already apeared in file ftFluidSimulation.h line 96

didnt see that , thanks…

Fixed in src.

Good to know it works under windows. (i did not test that yet)

Yeah ! A very nice fluid/particles system, i’m going to try it ! Thanks man

First test with audience:

1 Like

Updated flowtools to be compatible with OpenGL3.
Also added a Visual Studio example.

There are still some small bugs to work out:
There is a problem with the timeblur using openGL3 in Visual Studio.
And I got problems with blending behaving differently using openGL3 in Xcode.

Any suggestions are welcome.


Nice Addon, seems you put a lot of effort into it.
What was your setup in the video? I assume back projection onto the surfaces. But where are the Cameras?

IR Camera’s were in the front (about 5 meters from the screens and 3 meter high)
IR lights (pars with filters) were above the audience

This looks amazing man, nice work! Can’t wait to play with it :smile:


This addon is great! I compiled and ran the Windows sample using VS14 without any issues.

One question: How do I change the blue (left click) and orange (right click) colors?

I searched through the C++ and shader sources and couldn’t find where these two colors are set…


These colors are created by (first) drawing them into a texture using ftDrawForce and (second) adding this texture to the density of the fluid sim. (line 221:)

fluid.addDensity(flexDrawForces[i].getTextureReference(), strength);

The ftDrawForce has a setForce(ofVec4f(0,0,0,0)) method that sets a the force. If the ftDrawForceType is FT_DENSITY the setforce will behave more or less as ofFloatColor, where x,y,z,w translate to r,g,b,a

You can change this force in the gui of the example, go to:

  1. mouse left button

    • draw full res
    • force

    x = red
    y = green
    z = blue
    w = alpha

You can also change the type of the force here
non = no force
den = density (color)
vel = velocity
tem = temperature
ob = obstacle

Each mouse button has multiple forces connected to it of which the first is in high resolution (draw full res) for use with density (which in this simulation translates to color).
The other two are in the resolution of the simulation (usually a quarter of the full resolution).

OK, great thanks! I’ll test this out…