Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Introduction to Position Based Fluids (physxinfo.com)
273 points by choult on April 24, 2013 | hide | past | favorite | 77 comments



If you have an iPad I highly recommend getting LiquidSketch. It's a great puzzler about getting pools of liquid into the right place, and the liquid effect is stunning. It moves exactly as expected, has surface tension, splits and recombines etc - but the really stunning element is colour mixing. When two groups of different colours combine the mixing of them is just utter convincing, and beautiful. Amazing how this was all done on a lowly iPad.



When you say "on a lowly iPad", bear in mind that the latest (4th-gen) iPad has a dual core 1.4 GHz chip plus a GPU capable of 14.4 GFLOPs. It's actually a pretty powerful machine.


You still cannot compare it with the GPU from the OP rendering, that does 3000 GFLOPS (GTX 680).


I can however compare it to the famous Cray 2 supercomputer, capable of 1.9GFLOPS.

Remember when we were promised we'd someday have supercomputers in our pockets? We do.

Well, ok, fairly big pockets in the case of the iPad, but still, you get my point.


We also were promised real-time raytracing if we ever got to that point. What's the hold-up?


Real time raytracing is vary doable and high quality, it's just we got really good at rasterisation. Consider a 2012 demo http://www.youtube.com/watch?v=h5mRRElXy-w it's cool and all but what seperates it from rasterisation is fairly subtle and the computing costs are rather high.


Thanks for sharing this. I'm actually really excited; raytraced scenes have a "solid" feel to them that rasterized ones simply can't get.


The number of rays needed to realistically model raytraced objects turned to be much higher than we ever expected, as far as I know.


The expected display resolution probably changed too.


You can totally do real-time raytracing. I wrote my first raytracer a couple of weeks ago — http://canonical.org/~kragen/sw/aspmisc/my-very-first-raytra... — and it gets about 4fps on simple scenes on my netbook, despite being the product of only a few hours of work. If you use a GPU and/or SSE and/or a faster CPU, you should easily hit full-motion video.

My netbook is probably half the speed of an iPad.

It would be fun to put together a custom OS-less AMI to raytrace partial frames in realtime on EC2. 20 instances spun up in a few hundred milliseconds could do pretty substantial real-time raytracing.


Real-time raytracing is easy, if you can live with one or maybe two bounces.


Alternately, do lots of bounces with fewer rays, decrease the total dynamic range, and add a consistent noise/grain filter. Realistic raytraced night-vision :)


The CPU pulls tens of GFLOPs in single precision, too (and > 5 GFLOPs double precision!) It’s at least as powerful as any desktop you are likely to have had a decade ago.


What a charming little game. Just watching the video was strangely relaxing.


Now I finally wish I had an iPad. Waiting on the mini retina...I guess


I had the same concern, but after having a mini for a while, I can tell you that I don't notice the lack of retina resolution at all. They hold their value really well too - I highly recommend just getting one now and selling it once retina comes out.


Impressive for real-time, but nowhere near realism one can get with Naiad or Realflow and a proper renderer. For example: https://vimeo.com/37536300


The only uncanny valley effect here is that the water doesn't wet anything - everything is perfect Teflon. So it's hard to judge whether the movement of the water is perfectly realistic, because I keep looking at the transitions. If I don't look at surfaces, it seems very convincing.


The color is also not right. But the animation seems almost flawless otherwise.


Oh, you people with fully functional color vision are always complaining about this kind of thing. I'll just stand over here with Van Gogh.


Really? The color's not right? Not all liquids are the same color. Hell, not all water is the same color. But the GP is right when the water doesn't wet anything, it's kinda eerie.

EDIT: Having said that, water simulation is HARD.


I think the point is that water is only technically blue; in small quantities like those simulated, its appearance is mostly the effect of refraction and scattering and all that fun stuff, which is a whole new can of worms. So they add some blue (or green) partly to make it more obvious what's going on, but partly to cover up for the optics not being quite right.

You can see it especially in the last demo in the video. When the water spreads across the floor, it looks a little like a puddle of blue dye is diffusing into the water, and it's hard to tell how it would look if the water were more realistically transparent.


Every once in a while you can see a "pice of water" that should be smaller but is limited by the size of the underlying spheres.


Also I think a cube of water at 1:50 that holds its shape until it hits a rabbit does not reflect how a real water would behave. But overall I find this simulation very compelling.


Jaw-dropping? Maybe. Realistic? Nope.

I work in a group with scientists whose sole job is to solve the Navier-Stokes equations. Now that's realistic.


Perhaps you could elaborate on this. I do agree that the title and video give slightly more credit than is due based on the current state of fluid dynamics knowledge. However do you mean your group is searching for closed-form solutions to NS or are you generating approximate numerical solutions (CFD)?


Approximate solutions are found computationally.

Non-trivial closed-form solutions are hopeless. Existence of solutions is a little less hopeless. Existence of solutions over small time horizons has been proven. This is all in three space dimensions.

There is a theorem stating that if global-time solutions exist and are unique, then computationally computed approximate solutions are 'good'. Moreover, they get better as you refine the computational domain.


Is finite element method good enough? Can you provide a concrete example where approximation is not good enough.


Special approximations called 'Galerkin approximations' converge.

Finite element methods are a special case of Galerkin methods. Finite element methods are good enough.


At this time NS solutions are all approximate, but there's a huge gulf between plausible-looking fluids (as in story), and fluids with pressure, velocity distributions accurate enough for analysis (to design an airplane). And within the latter there are further demarcations depending on the type of fluid analysis, where errors manifest as extremely subtle (pressure looks slightly high, vortices dissipate too quickly or too slowly) and judging the best algorithm for a problem becomes almost an art.


You must just be a hoot at parties


Oh, you haven't the slightest.

:)


I am SQA Engineer for Autodesk Simulation CFD and our recent 2014 version has free surface modeling: https://www.youtube.com/watch?v=WNKHf937Qt0. It does make pretty pictures but as you mentioned solving navier-stokes equations can get complicated :)


Beautiful. Those boundary conditions must suck!


I think the nVidia real-time ray tracing demo is more impressive: http://www.youtube.com/watch?v=w9SH8xlgzoI&feature=playe...

Primarily because of the distortion of the visuals through the water. This simulation fakes it somewhat, which you can see with the distortion being somewhat blocky.


This should lead to much more interesting interactions with water in games, because now it has actual physical properties instead of just being something pretty to look at. Watching the water flow out of the aquarium makes me think that water is about to become a real active part of the game environment. Very cool.


I remember Super Mario Sunshine was much lauded in the games press because of what it did with water and the effects. I absolutely loved the game but you don't really hear much about it any more.


When I look at this water, it feels as though the volume of water is the size of like an acre. Is this to exaggerate the effect or is this a limitation of our current modeling capability?


Yeah, what you're referring to is the fact that surface tension is not scale invariant. In other words: dew can only be made of smallish droplets, not large ones.

I think the reason you see that is that they don't really simulate surface tension, but use a rather crude trick [0]. My uneducated guess is that in oder to achieve water that looks ok at small scales they would have to increase the size of the particles to the point it doesn't look smooth anymore.

[0] equation (14) of http://mmacklin.com/pbf_sig_preprint.pdf


> Yeah, what you're referring to is the fact that surface tension is not scale invariant. In other words: dew can only be made of smallish droplets, not large ones.

You completely blew my mind there! I'd never noticed that before.

Does the size of a dew drop relate to the size of the particles? i.e. can we estimate the size of water molecules just by looking at the maximum dew drop size?


Wait wait wait. I was talking about the particles in this particular simulation.

Surface tension is _not_ a function of the size of water molecules. In fact you can change it quite easily just by adding a little soap.


D'oh, I was being stupid, thanks.


The clip showing the water interacting with breaking glass blew my mind. It may well be a while before we see anything close to that level of realism being incorporated into games though.


True, but technologies like this usually make their way into pre-rendering first, i.e. pre-rendered cutscenes in games, CGI scenes in movies, or fullly animated movies. Although the latter category hasn't seen much in the way of realism, mostly due to uncanny valleyness.


This isn't prerendered - it's real time. Prerendered water (as seen in movies) looks far more realistic than this. Check out the Naiad link someone posted above.

This is great for real time though. It's using a form of SPH which is far easier to adapt for GPUs, and can crunch through those particle-particle interactions.

High end offline water sims would use a different algorithm (usually FLIP), maybe run for several days to sim a few seconds and occupy 10's of Gb of memory.

If anyone's interested, download a copy of Houdini Apprentice for free and have a play.


This is pretty much state-of-the-art game water (as of 2013):

http://youtu.be/65slGvDLmIE


I disagree. Games like Uncharted 3 have had much more sophisticated water simulations where water is an active part of the environment. Another example would be Hydrophobia. Crysis 3 is pretty much just slapping a heightmap onto a water surface, but it's no surprise that they take the easy route there since water is not an integral part of the experience in anyway. Crysis 3 is about shootin' men and robots that look like men, not about interacting with physically simulated water.

Here are slides from a presentation about Uncharted 3's water:

http://twvideo01.ubm-us.net/o1/vault/gdc2012/slides/1_Visual...

I believe they've talked elsewhere about the complexity of the water sims they did for areas that involved boats and an ocean you could swim through, but I don't have a link handy.


There's a differenece between physical simulation and visualization. The Crysis water looks awesome, even though its behavior is radically simplified. As those slides you linked show, the water in Uncharted is simulated much more thoroughly, but the visualization is pretty hacky.


I've never seen water simulations that can pass the U test. Basically, take a pipe, bend it into a U shape, pour the water in one side, and see if the water levels even out. If it does, then it's a very accurate simulation of water.


I think that's backwards -- if it's a very accurate simulation of water, it will pass the U test, but you can add hacks to make a simple, inaccurate system pass it, too. See, for example, Dwarf Fortress's pressure system: http://dwarffortresswiki.org/index.php/DF2012:Flow#Fluids_un....


I agree, the U test is very hard. I spent many days trying to make a working 2D approximation with cellular automata, but I couldn't find any way to make the pressure propagation fast enough. The water would eventually level out on both sides of the U, but it took a very long time to do it.


What happens instead in the simulations that fail?


usually the water fills up the bottom part of the U until it reaches the width of the pipe, the only one side fills up (the supply side). So if I fill up the left side of the U pipe, the water forms an L shape. On some simulations, the other side rises, but doesn't really even out.


they seesaw for far longer than is reasonable.


Cool stuff, but the viscosity seemed a bit off (especially noticeable when the glass walls were shot out towards the end), and waves seemed to hold their shape for a bit too long. I wonder how hard that'll be to tweak.



Perhaps it is the most realistic, but I've yet to see a fluid demo, this one included that didn't look like overly "energetic" shampoo.


It's definitely realistic, but sometimes it seems just a little off. There are times when it seems to "clump" up like a solid would when you have water particles thrown in the air. I'm not sure if that's my own bias or the uncanny valley effect at play here.


I noticed that too; seems like it might be a matter of making the particles smaller.


This reminds me of a much older open source game where two players controlled liquids and the aim was to engulf the other liquid. I can't remember the name of the game, though.


liquidwar?


Yes! What a funny game.


Somehow, I felt wow. I am able to appreciate this because of the number of applications it holds - Tsunami simulation, Bridge and dam construction. And real-time? Full points!


Artistic water simulation and scientific/engineering fluid simulation tend to be mutually exclusive in that they optimize for different objectives. Typically, a solution in one domain is ill-suited for the other. For instance, the "Stable Fluids" trick leads to desirable artistic properties (fluid behavior more closely matches stage direction = active energy input) at the expense of systematic inaccuracy (total energy is biased downward) that would be undesirable in an engineering context.

If this technique worked equally well in both domains it would go from "impressive" to "miracle". In the meantime, we can certainly applaud it for the things it does do well!


Particle generators like this have been used in Hollywood for quite awhile, I bet you would have never have guessed it was CGI though.


The difference being that this demonstration is real-time.


Thank you for clearing that up, now this is actually impressive, although I would imagine it would require a ton of GPU & CPU power.


PhysX is aimed at running on current generation 'consumer grade' gaming hardware, so think a GPU you can get for $200 (if not less). It works out of the box on all of NVIDIA's modern graphics cards.

Of course, you do have the problem of what to do when the water sim uses up all the available GPU compute power and bandwidth - not much left to render, in that case...


".074 Bitcoins worth"


honestly, after watching the demonstration video, there is nothing in the video that i haven't seen in numerous hollywood films or games before. am i missing something? would someone care to explain what i should be looking for?


I've never seen water simulation with this degree of complexity in games. I've seen it in prerendered video sequences, but when you sit and look at a lake or river in an Elder Scrolls game (or similar), it is usually much more simplified -- or has a flow which is modeled to look pretty.

The difference here is that it's showing interaction between the water particles and things that they impact on: characters, boundaries, piers, and behave in a more realistic way than games have previously had.


Yeah, that does it. We live in a computer simulation.


Does anyone here know what technology stack this is implemented in/with/on?


C/C++/nVidia (formerly Ageia, formerly Novodex) PhysX.


That is so god-like! I give up I do not want to program anymore.


very cool




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: