Fluid Solver for QC

I would like to ask if it would be possible to make a Fluid Solver for QC? This could be used for simulating fluids, gases and other natural phenomena. I have put together some literature about various implementations - hope that is of interrest.

I think that having a fluid solver in QC would open up a wide range of amazing visual possibilities.

GPUGEMS article http://http.developer.nvidia.com/GPUGems/gpugems_ch38.html

Code samples GL implementation and literature from Nvidia (GPGPU Fluid and Superflow): http://developer.download.nvidia.com/SDK/9.5/Samples/gpgpu_samples.html

Jos Stem's papers ("A Simple Fluid Solver based on the FFT" recomended) http://www.dgp.toronto.edu/people/stam/reality/Research/pub.html

Online Example as Java applet http://www.multires.caltech.edu/teaching/demos/java/stablefluids.htm

iPhone application from Autodesk: http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=295089687

What do you think about?

gtoledo3's picture
Re: Fluid Solver for QC

Boy this is something that comes up quite a bit... and I am the main culprit!

The thing about fluid sim, is that you have to really stop and thing about what "fluid sim" means. How many different "ways" are there to have an impression of "fluid", and what do they really entail?

For example, the "look" of doing a water glsl shader with a rock bed background is TOTALLY different than achieving the look of pouring water. The look of some of the 2D feedback/accumulator stuff you post is also totally different than either of those two situations... and many times tends to just work in 2D. It can "look" 3D, but oftentimes, you can't really "rotate" and have all of the "fluid" rotate with it.

The particle tools can do some decent "pouring water" sim stuff. The caveat is that to get those lush particle sims like you see done with offline render on vimeo, you need a zillion particles. As is, it's hard to get those kind of particle counts in QC and have things be stable, or even be able to look at your file in any way to edit it before you render. Somewhere I posted a thing of Chris's particle tools collider example with a gaussian as an input image. THAT's not a bad emulation technique, because a gaussian tends to look like a drop of water in that setting... and it keeps you from having to generate a zillion particles to achieve realtime "fluid" look. I've also done a few spherical glass looking orb png's with a bit of color- that is another thing that is good for emulating rain or pouring fluid when used with particle tools.

The GL Logic op can do a little thing on certain setting/with certain combos, that make things look "crystalline". Sometimes that can be useful for getting the effect of ice of liquid.

The "feedback/pushing image" around stuff is already pretty doable. It looks like Vade is porting something that works with the Apple accumulator patch to do some of that "pushing stuff around" thing that the applet you link to does. I have a feeling it can be done now even without another plugin, but I haven't tried that particular effect. Using the accumulator with images/textures/CI patches can do a bit of this.

In my long winded way, what I am leading to is that "fluid simulation" encompasses a variety of techniques, there's not one magic bullet.

s.rozsa's picture
Re: Fluid Solver for QC

hey george! You are reaching for the stars again :-) No i am not talking about "fluid simulation" but just as the topic says about a "fluid solver". To be more exactly about a 2d grid based fluid solver (FFT) as discribed by Stam or Mick West (http://cowboyprogramming.com/2008/04/01/practical-fluid-mechanics/ example C++ code available on the site)... This are basically 2d grid based approaches to simulate the flow/buyouancy etc. in fluids. The appearance is somehow similar to that what you can see in that new video of Vade. (Here is BTW: a very nice implementation in Processing: http://www.escapemotions.com/experiments/processing/fluid_fire/applet/in...)

The image accumulator in QC would be great to visualize such a solver. I am imagining an implementation of the FS as a kind of "filter" with different settings for viscosity, speed, buyoancy etc. and with some other inputs for an image and for manipulation (x/y for mouse or for a structure like OSC or TUIO). The flow would distort the image and we could send that to the accumulator...

I know that you can fake a lot right now with some CIfilters like distorsion etc. - but that is a fake and really not convincing.

As for particles etc.: George i am quite experienced in all this non-realtime 3d graphics and simulations (i'm doing this job more than 20 years now - boy i'm getting old...). We are working here with Max and Maya, but are using sometimes also RealFlow for fluid/gasous stuff if we want to achiev something like you can see in the attached picture... I know that particle based simulation is very expensive. I would not fiddle with that in QC right now - but i'm hoping that Snow Leopard will bring there some new impulses (OpenCL, CUDA etc.)... If you are going toward GPGPU, you will notice that realtime sim with particles is getting cheaper and cheaper. Look at this realtime example with 0.5M particles: http://developer.download.nvidia.com/CUDA/CUDA_Zone/multimedia/Cars_with... There are also a LOT of very interresting demos done on the GPU. So i would not go for particles right now in QC ;-)

As a side note: the FFT 2d grid can be also extended in the 3rd dimension - but that's another thing - i would be absolutely amazed to see that in 2d.

Oh and yes: talking about that Water-Sim i have started with: well take the results of such a fluid-solver, convert that in greyscale and use it as an input for a GLSL shader of the kind i have posted - now you have a very convincing wave simulation...

Or look at that very exciting fire like dace simulation of Memo: that would be impossible without a fluid solver...

Or take the imageflow plugin and put in that as a manipulator in the fluid solver :-)

My2c

PreviewAttachmentSize
elements.jpg
elements.jpg357.46 KB
sea_and_sky.jpg
sea_and_sky.jpg367.26 KB

jersmi's picture
Re: Fluid Solver for QC

Well, between Vade's port to QC of the jitter optical flow patch and now this fluid solver request, i see the tools i wish i had (and wish i knew how to make...)

gtoledo3's picture
Re: Fluid Solver for QC

Oh, ok understood then. It's a very attractive look that's for sure. Thanks for posting all of the links as well.

gtoledo3's picture
Re: Fluid Solver for QC

SOMEONE named s.rozsa must be a very happy person right now :o) Or, at least mildly more so.

s.rozsa's picture
Re: Fluid Solver for QC

gtoledo3 wrote:
SOMEONE named s.rozsa must be a very happy person right now :o) Or, at least mildly more so.

Huch? Did i missed something? I was away over the weekend and had indeed 2 sunny calm days - so i'm really quite happy... But that's surely not waht you mean - or :-)

gtoledo3's picture
Re: Fluid Solver for QC

http://002.vade.info/?page_id=28

At least it's a bit of the equation :o)

s.rozsa's picture
Re: Fluid Solver for QC

thanks george :-) Impressive stuff again what Vade is doing. But unfortunately not an FS behind the scene ;-)

gtoledo3's picture
Re: Fluid Solver for QC

This first day that the plugin came out I messed with it for a bit. I can definitely recommend playing with an old school image mask/sample hold setup... eg., sample the background while your out of frame (I have to reach over and make sure my arm doesn't get into the picture), then I set up another chain of subtract blend to make me "pop" out from the background, then I used that as the mask shape.

I don't know if this is making sense? Lol, MORE coffee... been having a hectic couple of days... sooo much stuff to do.

The more time I spend on QC, the more I keep going back to the CI Filters, the hidden patches...stock stuff... and stock animation/special effects techniques, to come up with "new" ideas - finding ways to integrate traditional effects with the QC palette.

Anyway....if you were to put a little particle system or something in a render in image with it hooked up to a mouse, instead of the camera source like the example, and I bet it would start seeming a lot more like a fluid sim, at least the one in that applet :o) I know what you mean though... No "physical forces", but using the kineme particle tools with this is probably an interesting combo to experiment with to make up for that.

dust's picture
Re: Fluid Solver for QC

real time fluid simulation ? real flow = a really long time fluid simulation.

cuda looks cool must be a nvidia upgrade to PhysX ?

i thought QC could do fluid simulations, i could have swore i saw it on the science channel or something.

here some code that might help you building a solver.

http://wiki.dataflow.ws/GlSlang

s.rozsa's picture
Re: Fluid Solver for QC

Hey Dust,

nono, realflow is NOT a realtime simulator. It is used by us in "conventional" CG scenarios, where quality matters... CUDA is a programming language (framework) for using parallel accelerated graphics on the GPU. PhysX (what is a cool physics engine) is/will be integrated in CUDA... But i heard some rumours about QC and PhysX and Snow Leopard ;-))

Thanks for the link. And if you find out something about that science channel article - please report...

dust's picture
Re: Fluid Solver for QC

yeah i know i was making a joke, real flow is a really long time simulator, or takes a really long time time for particles to settle even if your messing with the kill rate it can still take hours days, weeks etc... the results are amazing with real flow. in theory i think you can use kineme 3d as a play back engine for the mesh files that real flow creates. real flow is defiantly amazing, but the more i get into real time graphics the less patience i have with rendering and simulating. digital molecular matter sounds pretty interesting to me but i have yet to try it.

franz's picture
Re: Fluid Solver for QC

hi, this might be of some interest: particles fluid solver called SPH Smoothed Particle Hydrodynamic. It is open source, code in C++: http://www.rchoetzlein.com/eng/graphics/fluids.htm

and ported to OF: http://www.vimeo.com/3899908

the latter seeming to be a natural implementation for KnM Particles...

s.rozsa's picture
Re: Fluid Solver for QC

sir - i'm deeply impressed... have to check that out later on XP...

s.rozsa's picture
Re: Fluid Solver for QC

just to refresh this thread a little bit ;-) Memo done it again: a great and performant fluid solver in processing AND also allready with TUIO support. WOW! More on that and sources can be found on: http://www.memo.tv/msafluid_for_processing

To make all that a bit more attractive - her's a short video running Memo's MSAFluids on our MultiTouch table:

gtoledo3's picture
Re: Fluid Solver for QC

Do you feel that to be "fluidy"? The clip above embodies what you are trying to pull off?

This is a nascent clip of something that has ended up looking alot like the thing above that you just posted... this is early on, in black and white, before I started designing the color control params. I've also got more "wooshy/fluidy" going currently.

But, it's all QC.... I feel that QC can DEFINITELY do what is show in the memo clip... I'll try to post some more stuff on that. I plan on releasing it as an app at some point.

s.rozsa's picture
Re: Fluid Solver for QC

hey george, this is a truly amazing composition - as you allways doing! PLEASE - i hope that you don't missunderstanding me: but that's DEFINITELY not what i am talking about. I'm very sure that you can do a LOT of absolutely AMAZING stuff in QC. And i have no doubt in the capabilities of QC on doing great visuals (nor in yours!). But we are talking about two very different points: VFX versus Simulation... Please, please, please: do not confuse a fluid solver with a fluid simulation system 'a la RealFlow :-)) The fluid solver by Memo is just the starting point - you should grab the source and make a few test-runs. Take a look at the particle side of the example sketch and try to imagine what you could do in QC if you would had the FS as an input provider for i.e. particle systems etc... I know my video is crappy - so is better to run the sketch by yourself...

dust's picture
Re: Fluid Solver for QC - van der waal

how would the fluid solver work in QC ? a whole new emulation system would need to be made to work with the solver, unless it is incorporated into kineme particles or something.

if i had the time to make a fluid solver i would make it more generic and use a van der waal approximation. this way you could change the gas constants to act like various gas types. maybe solve with a avogadro constant as well, based on a particular particle count.

i honestly don't know much about physics but i suppose applying what we know to be true in the real world, would make a much more accurate solver.

im not great at actually solving equations but i can convert them to machine language so the machine can solve. actually the van der waal is a pretty easy algorithm to make. now that i am thinking about it maybe it wouldn't be all that hard to put it together with the stam method ????

thats just a thought on how i would approach the problem

gtoledo3's picture
Re: Fluid Solver for QC

Now I have a new challenge...

jersmi's picture
Re: Fluid Solver for QC

gtoledo3 wrote:
Now I have a new challenge...
hehehe. are you sharing any secrets?

psonice's picture
Re: Fluid Solver for QC

Just to be clear: fluid solver != fluid like effects. A fluid solver should behave like a real liquid, and flow around objects with turbulence etc. It's a pretty hard effect to actually do I think, and you'd probably need a plugin for it with QC.

Some decent realtime fluid solvers from the demoscene:

http://www.demoscene.tv/prod.php?id_prod=12813 (around 1/3 through - good quality particle based 2d fluids moving around a maze) http://www.demoscene.tv/page.php?id=172&lang=uk&vsmaction=view_prod&id_p... (around 3/4 through (smoke) and at the end (liquid) 3d fluid/smoke simulation, in a box with explosions. I seem to remember smash saying it's rendered on the GPU as slices, but I can't remember how off-hand. It needs a pretty powerful GPU, and it's probably pretty hardcore to code it...)

gtoledo3's picture
Re: Fluid Solver for QC

...flow around objects?

psonice's picture
Re: Fluid Solver for QC

Looks like simple collision, rather than real fluid dynamics. Try firing your particles into an empty box, see if it fills up with waves and splashes, then pours over the sides.. that's flowing around objects ;)

gtoledo3's picture
Re: Fluid Solver for QC

Wah, wah, double wah.

lol...

Yep, getting it to fill in a bowl isn't really the hard part. I'm still unsatisfied with the "texture".

I should have posted my first clips, it's in a bowl. I tweaked it "past" the good point I guess...