Monday, April 29, 2013

PhysX PBF: breakthrough in simulation of water

A decade ago, the state-of-the-art computer simulation of moving water looked like the 0:20-0:40 segment of the Mafia I trailer. In the following years, the progress was relatively modest up to very recently.

PC games have become nearly photorealistic but flowing and splashing liquids are still hard. In some sense, one needs to simulate individual (enlarged) molecules and/or the Navier-Stokes equations – both tasks are difficult when it comes to the required computer power etc.

See also a lighthouse etc. and one more bunny bath.

The video above shows what the simulation of water looks like using the newest technologies. A single graphics card, GTX 580 which you may buy for $350, was used to produce the video in real time.

The video uses NVIDIA's Position Based Fluids: introduction, technical paper, pretty much the same approach that was used to simulate moving clothes and other things. See some examples how Mafia II exploited PhysX (2010).

The simulation with the bunny etc. looks almost perfect and some clever and efficient simulation of legitimate physics – especially a better iterative solver to maintain incompressibility – is responsible for this progress. Some additions are sort of cheating from a physics viewpoint, however. The tension-like filaments don't quite appear because of the right formulae for surface tension; they arise because of a new artificial pressure term that looks good but doesn't seem to be given by the right physics formulae.

Vorticity confinement is a new theme that allows to conserve the energy – which you may pump back to the system.

At any rate, because the water simulation looks almost perfectly realistic and water is among the most difficult things to simulate, we may say that we're pretty much entering the era in which your PC at home has all the required power and cleverness to produce videos of reality that may be indistinguishable from the real reality...

See Google News.

Incidentally, the gas explosion in Prague made it to the #1 event on Google News at some moment. (The explosion was caused either by gas or by Sarah Palin. ;-)) It seems excessive because nothing excessively serious has happened, after all. I should have debated some folks in the National Theater last Thursday but I said no at the end, partly because of preparations to a string/LHC mixed talk (2 hours including many questions) I was giving today in Pilsen. Note that the National Theater has burned twice – in the 19th century – and the Czechs always collected new funds to rebuild it. ;-)

The video above is somewhat more realistic and less sorrow because life didn't stop; this one or this one almost reminds me of my visits to Manhattan shortly after 9/11. You may imagine that I know the place extremely well – I am going around the National Theater almost every time when I visit Prague. There's also the Academy of Sciences where I was doing an exam with Prof Niederle as an undergrad and many other familiar buildings whose windows were broken today. ;-)

I suppose that when everyone can smell gas in the street, it's better to run away – and maybe some employees should try to stop the leak and/or extract the gas from the building in some way. I am no expert. It's not even clear to me whether someone breached his duties in any way – whether the existing regulations are supposed to prevent such events.

Prague is significantly richer than Pilsen but I feel that even the supposedly luxurious neighborhood of the National Theater is still sort of dirty relatively to Pilsen. Is it just me?

BTW Czech president Zeman offered one of his classic witticisms in Austria today. He said he's ready to terminate the expansion of our Temelín nuclear power plant – if Austria rents their Zwentendorf nuclear power plan (that was stopped by a modest 50.5% majority in a late 1970s referendum) – but cheaply. By this joke – which wouldn't necessarily have to be a joke if Austrians were a little bit more pragmatic! – Zeman joined the Start Zwentendorf NGO, a brotherly organization of the Austrian Stop Temelín NGO. ;-)

Maybe I shouldn't promote Temelín and its safety a few paragraphs after comments about a gas explosion in Prague? ;-) But I am really not afraid...


  1. Very impressive! Now that's what mathematics is all about! Religious documentaries about Noah's Ark can now be made even more realistic by using this new high quality simulated water.

  2. Cool videa.

    I immediately recognized the guy appearing in the bath after the bunny by name :-P, he is NOT my friend and the waves should have crushed him ...

  3. Great! How about a fire next? I've always dreamed of having that relaxing video of a slowly burning fireplace replaced with a long simulation of the same, where you fill up with a fresh log from time to time.

  4. Let's say for an iron dumbbell you could assemble it out of relatively small dense spheres with "springs" attaching each of the little balls. Let's say theres a mat object too which is soft so it's made of bigger less massive spheres.

    Do you think such a model would allow the dumbbell falling onto the mat to behave realistically?

    I'd imagine future game programming will require something similar to this where the physics and the graphical objects are essentially one in the same. Having everything made out of tinker toys which are all part of the same physics engine. Etc.

  5. Todays version of bread and circuses? Distracts the masses so they don't notice they aren't real citizens anymore.

  6. you can think of only disadvantages? i think you can think the advantages by yourself.

  7. this is gameplay not movie

  8. Neat, dry water ;) Nothing gets wet.

  9. From Mariano C:

    I tried to comment in your blog, but I had some technical problems (maybe the comment is just in the moderation queue). The simulation is impressive for being real-time (working with GPUs is quite frustrating ), but by running more detailed models you can get results that are even more impressive:

  10. I'm impressed enough already! %~o

  11. That's not even the newest. See this :

    Also there is a newer version of C++ that makes it a lot easier to program for such cards :

    Hunt down a video demonstrating C++ AMP By Herb Sutter. It's worth a viewing. For example :