Not logged in, Join Here! or Log In Below:  
News Articles Search    

Submitted by Chris Killpack, posted on December 07, 2001

Image Description, by Chris Killpack

These two images show my fluid simulator in action. There are over 16000 particles suspended in the liquid. The liquid can be modified by applying external forces with the mouse. The liquid is defined on a 128x128 grid. Unfortunately I had to remove the FPS and other information from the borders of the screenshots in order to get the IOTD to fit. But it runs at just under 30fps on an 800Mhz P3.
  • The top screenshot shows two vortices forming after a single force was applied across the liquid.
  • The lower screenshot shows the fluid velocities at each cell.
  • The simulator solves the Navier-Stokes equations. These equations were defined more than 150 years ago by Claude Navier and George Stokes. These equations express the evolution of the liquid's state over time. That is to say, the equations describe how much the liquid has changed over a discrete period of time, as opposed to defining it's state at an arbitrary time. The problem is that the equations are highly non-linear which makes them incredibly hard to solve accurately and efficiently.

    The solver that I am using was developed by Jos Stam, a researcher at Alias|Wavefront. He originally published a paper entitled "Stable Fluids" at SIGGRAPH 1999. The maths in the paper is very hairy, and the paper assumes a good grounding in fluid dynamics. I have neither a good grounding in maths, or an understanding of fluid dynamics (not beyond drinking anyway)! You can find the SIGGRAPH paper at Stam's website -

    If, however, you make the boundaries of the fluid periodic and remove support for obstacles in the fluid you can simplify several calculations by using the Fourier domain (and it's associated transform the FFT), which allows you to achieve real-time computation. This is the basis of the solver that Stam describes in an article to be published in the Journal of Graphics Tool. That article is available on his website here - In fact he even provides source code for the solver in the article! His source code is what I used to create my solver.

    Jos Stam should take all the credit, I just strapped a user interface and D3D shell onto the front of it!

    I recommend anyway whose is interested in learning about different aspects of computer graphics to at least read the JGT article. In addition I would recommend that people investigate the Fast Fourier Transform. The FFT is a very powerful tool with many uses in computer graphics - generating tiling textures, landscape synthesis, efficient evaluation of the summation of many sin/cos functions, to name but a few.

    Finally - the simulator makes for a great toy, and I have a screensaver version of this in the works. :)

    Chris Killpack

    Image of the Day Gallery


    Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
    Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

    December 07, 2001, 02:51 PM

    THis is definitely very cool to look at. I want to see it in realtime.


    December 07, 2001, 03:08 PM

    Wow. The third implementation of the paper within one week. Maybe I should read it too and see what will happen ;) Anyway, these shoots look cool.



    December 07, 2001, 03:34 PM

    cool I love those things! When can we download the screensaver?

    Stefan Karlsson

    December 07, 2001, 04:16 PM

    now that was one hell of an ugly iotd


    December 07, 2001, 04:30 PM

    I thought the top image was two black holes at first. Looks mighty interesting, would love to see a demo.


    December 07, 2001, 05:21 PM

    very very cool, would love to see the screensaver

    William Dahlberg

    December 07, 2001, 05:40 PM

    Liquid is neat!
    Cool stuff you got there!


    December 07, 2001, 06:42 PM

    Interesting - I love that kind of stuff...

    Note, however, it seems to be covered by a patent now. This from Gamasutra:

    "Patents were awarded to Jos Stam and Duncan Brinsmead, for inventing a method of producing fluid-like animations using a rapid, stable Navier-Stokes solver"


    December 07, 2001, 08:26 PM

    I'm not sure what the patent covers, but its not the fundamentals of
    the fluid solver. Jos has discovered the the key to his "stability"
    is a method that has been used (and published) by scientists doing
    weather simulations since the 60's or 70's. It is only recently
    that Jos rediscovered it and applied it to computer graphics.

    I attended a talk by Jos last year and he was encouraging everybody
    to use and explore his method -- I don't think it is very restricted.
    I wrote my own implementation from the Siggraph 99 paper.

    The method approximately solves the Navier-Stokes equations... you
    couldn't write a science paper about it, but it is good enough to
    make cool swirls for games. Definitely check out the real-time
    display... it works great.

    John Hoffman

    December 07, 2001, 08:34 PM

    Jeez!! I HATE it when patents are granted for such general scientific research. Imagine if chemical separation techniques (i.e., distillation) were patented. It would inhibit development in chemistry just like it will inhibit development in computer graphics. Am I overreacting?



    December 07, 2001, 09:50 PM

    I think the purpose of this IOTD was more to show the technique than to make people go "ooh, pretty"


    December 07, 2001, 09:51 PM

    wow, those do look like black holes

    Jonathan Blow

    December 07, 2001, 11:57 PM

    Well... have fun not being able to legally use this code in the future. The technique is patented now. USA! USA!!!


    December 08, 2001, 04:24 AM


    This reminds me of some software I saw three years ago,
    at the CeBit fair in Germany. The russian companies and
    universities shared one big booth. And at one table they
    were demonstrating a software for Navier-Stokes

    This software ran on a standard PC and did a 2D
    simulation of the full Navier-Stokes equations in real
    time. And in a fairly high resolution, too. They did not
    use finite elements but subdivided the surface.

    Does your software do the full equations or a simplified
    variant? How fast is it?

    Warren Marshall

    December 08, 2001, 04:55 AM

    I agree. All a patent like this does is insure that nobody will use the technique in commercial products and the idea will slip into obscurity. Sad.

    Unless they have some hugely profitable use for it or something, in which case the patent is probably smart from a business point of view.

    But I agree, patents on general research are ridiculous.

    James Matthews

    December 08, 2001, 09:30 AM

    A patent doesn't always mean you can't use it. Mark Tilden patented many ideas behind BEAM robots, but didn't care who used them (to a certain extent)...anyway, for those of you interested, I looked up the links at the USPTO:

    The two of them also have another patent:'jos+stam'&OS="jos+stam"&RS="jos+stam"

    Anyway, hope those links work...they're kinda long.



    December 08, 2001, 01:01 PM

    Copyrights I can understand, since programming is like writing, but patenting a solution in programming is like patenting a solution in mathematics. Imagine if Taylor patented his Taylor series....


    zed zeek

    December 08, 2001, 02:49 PM

    ive seen a couple of demos of this but they all seem to be in 2d. is this method valid also for a 3d representation of water?

    Chris Killpack

    December 08, 2001, 03:29 PM

    The fact that it's patented doesn't really bother me - I'm not sure there is currently a better way of protecting research. What bothers me is how Alias|Wavefront will enforce that patent.

    In light of this technique being patented I will not continue to work on the screensaver. I am in the process of understanding Stam's SIGGRAPH 1999 paper and will eventually get around to implementing it simply because I am curious about fluid mechanics and see it as a good programming challenge.

    Thanks for the feedback.



    December 08, 2001, 04:07 PM

    You aught to implement a simple flat shading method to help show the effect...shouldn't be too hard, though on the otherhand, it will slow down the FPS...I'm not sure how slow or fast it would end up being.


    December 10, 2001, 08:55 AM

    Patents aren't good.

    They prohibit use and further research. If they don't want other people using their research then they shouldn't publish a paper on it.

    This thread contains 21 messages.
    Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.