Realtime Fluid Flow - Wow!
Written by Mike James   
Sunday, 05 May 2013

It is worth seeing this video of realtime simulated water flow. It isn't perfect, but it is very good, and what can you say but "wow" when you watch all that simulated water sloshing about!

There are two distinct approaches to creating any simulation in computer graphics.

You can take the accurate physics and try and implement it as accurately as possible.

You can attempt to find a process that matches the real physics closely enough so that they human eye can't really see the difference. 

For example, you can attempt to render a 3D scene with highly accurate ray tracing that follows all of the laws of optics or you can adopt a simplified shading model such as Phong shading. It's not accurate but it usually looks good and it is a lot faster than accurate ray tracing. 

When it comes to physics engines we have the same problem. Accurate dynamics or some fast approximation that is good enough. 

Fluid flow is difficult, very difficult. A fluid is a physical entity that obeys an equation of fluid flow - usually the Navier-Stokes equation.  This is a time-consuming equation to use in implementing a simulated fluid flow. It can be done and it is the approach the physicists and CGI special effects take in creating simulated water. The problem is that this takes a lot of computation and it makes a realtime approach impossible. 

 

lighthousesea

 

Of course, if you look really carefully at a fluid then eventually what you see is a set of particles moving under nothing more complicated than Newton's laws.

So why not just make a particle approximation?

The problem is that the particles in a fluid obey some constraints that are very difficult to model using the usual "particle with mass moving under a force" method. They have to move to keep the density and pressure in the liquid constant - the fluid has to be incompressible. 

This is where the Position Based dynamics comes in. Instead of modeling the constraints by introducing suitable forces, you allow the particles to move as if they were free and then impose the constraints directly to correct the motion. This approach has been used on solid motion but now Miles Macklin and Matthias Muller at NVIDIA  have applied it to fluid flow and the result is a fast and impressive simulation. 

The results, using hundreds of thousands of particles, look a lot like water flowing and by "surfacing" the particles to make them look like a smooth flowing surface, the effect is even more impressive.

As you watch this video keep in mind that this is in real time running on a GPU in a standard PC. 

 

 

Some of the simulations are shown as raw particles so you can see how they move. The "surfaced" simulations are where the particles vanish and the liquid looks a lot more like water.  

So how good is it?

To most the water seems a little to viscous, but this is all the more impressive if you are going to use it in a game. There are one or two moments in the simulation where things don't appear quite right, but as far as most viewers are concerned it does seem to be good enough.  Good enough for a game, perhaps, but of course this is not an accurate physics simulation and it isn't trying to be.

Perhaps even more impressive is when you put the fluid mechanics together with some fracture mechanics, i.e. in plain English when a fish tank breaks:

 

  

Expect to get wet in future games.

 

More Information

Position Based Fluids

Introduction to Position Based Fluids

Related Articles

Tearable Cloth In JavaScript

3D Teapot Classic Using Pure DHTML

Interactive Fluid Simulation in WebGL

New face animation algorithm

The sands of time - simulated

OpenGL 3D fluid simulation (video)

OpenGL GPU Smoke simulation

 

To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, FacebookGoogle+ or Linkedin,  or sign up for our weekly newsletter.

 

espbook

 

Comments




or email your comment to: comments@i-programmer.info

 

Banner


Extend NGINX With The New JavaScript Module
28/10/2024

Inject middleware functionality into NGINX with the expressive power of Javascript. NGINX JavaScript or NJS for short is a dynamic module under which you can use scripting for hooking into the NGINX e [ ... ]



Flutter Forked As Flock
05/11/2024

One of developers who worked on the Flutter team at Google has created an open-source form of the framework. Matt Carroll says Flock will be "Flutter+", will remain constantly up to date with Flutter, [ ... ]


More News

 

 

Last Updated ( Saturday, 11 August 2018 )