Visualize this! Michael Gourlay on Fluid Simulation in games

Welcome to another episode of Visualize this! the show where we talk about game development.

My guest today is Michael Gourlay Senior Software Engineer at Electronic Arts, ( lead on Madden). Michael also teaches at University of Central Florida (UCF) Florida Interactive Entertainment Academy (FIEA). Michael spoke with me about Fluid Simulation and its state in games.

As always send me feedback on the content on the site, or any questions you would like answered on the show at You can also follow me on twitter @artigupta

Download High quality MP4

Show news

1. We have added GDC session slides to the Game Performance workshop and How to program for 100 cores on our GDC page. Check them out here
2. New whitepaper on how to optimize your game engine using platform view on Intel GPA 3.0
3. New Download showing a threaded particle system - ticker tape is available at our ticker tape page . Your comments are welcome
4. Chris Skaggs from Soma games started blogging on ISN. His first post is about Augemented reality and what it means to games. Check out his blog and I am sure Chris would love to hear your thoughts on Augmented reality
5. Sean Koehl from Intel labs also blogged about what would be possible with a 3D web

1. What is the state of fluid simulation in games today?
--Most games do not perform fluid simulation. Usually they use particle systems where the particles do not interact with each other. The only game I have worked on that uses anything like a real fluid simulation are NASCAR 2009 (which is no longer made) and MMA (which has yet to be released) -- and both of those use my visual effect system.
--Bioshock, which was famous for its underwater rendering, used a variety of tricks to given the impression of immersion in water, but none involved actual fluid simulation.
--The most popular form in games is Smoothed Particle Hydrodynamics (SPH) which works well for gloppy liquids and it works well for filling containers with sloshing, viscous goo, but it lacks the ethereal delicate motion of fine wisps of smoke or the broad-scale turbulent motion that comes from vorticity (and specifically, from vortex stretching).
-The simulations I published on the Intel Software Network use vorticity as the fundamental quantity and as such it exhibit finer-scale turbulent motion.
2. How does fluid simulation change the game play experience?
--A very few games (such as Plasma Pong and Polluted Planet) integrate fluid simulation into the gameplay mechanic although both are 2D and they only use jet-like or buoyancy mechanics. I have not seen any games that explore the 3D vortical aspect of fluid flow which is, of course, the most interesting aspect since it leads to turbulence. You can't have vortex stretching in 2D -- and therefore can't really have turbulence.
--At this stage, fluid simulation is mostly a "secondary" animation like soft-body physics -- it's eye candy. And it's canned. But we crave more interactive experiences so I anticipate games will start to include more sophisticated fluid simulations to let users become more immersed within our virtual worlds.
3. There are different types of simulations. What are the challenges faced in simulating fluids?
-The biggest challenges to overcome are speed, stability and enduring fine-scale motion. Usually you can pick any two: You can have fast, stable viscous motion, or slow stable fine motion. (Unstable simulations simply explode into nonsense.) So the challenge then is a question of how to obtain all three.
--One possible solution is to throw huge amounts of compute power at the simulation -- such as the GPGPU solutions which have been popular in the past few years. But for games, that simply does not work -- games already use the entire GPU for rendering. No GPU horsepower remains for simulation. But multi-core CPU's are well-suited to the problem.
4. What are some of the techniques that can be used for simulating fluids?
--The categories depend on how you discretize space (that is, how you approximate an infinite continuum with finite discrete resources) and which quantities you use to represent the fluid:
--the two major families of discretization are Eulerian (which usually use a fixed grid to represent values) and Lagrangian (which use mobile particles to represent values).
--The two major families of quantities are Velocity-Pressure (so-called primitive variable formulations which seem to have more intuitive appeal) and Velocity-Vorticity (which I prefer, and once you get past the apparent abstractness of a "vortex" I believe it is not only numerically superior but also more intuitive).
--You can combine these in many ways. I prefer Lagrangian Vortex methods: Lagrangian because particle systems appeal to artists (they're ubiquitous in both cinema and games) and Vortex because it yield more appealing motion more efficiently.
5. How would you optimize the results of these techniques? What tools do you use?
--The first step in any effort to optimize code is to profile. Some profilers instrument the code and aggregate timing data spend in regions of code, and some profilers sample the hardware for information like the program counter, cache misses and branch mispredictions. Both work well together. Intel's VTune is fantastic because it automates the sampling process. VTune provides a huge number of options. Once you get used to its enormity it is a fantastic tool for that chipset.
6. You also mention different methods for computing velocity from vorticity. What are these and where would you recommend the use of each?
--You can get velocity from vorticity using either integral or differential techniques.
--Integral techniques are easier to understand: You imagine each vortex as a source of circulation, much like each electron is a source of an electrical field, or every planet is a source of a gravitational field. The only difference is that where electrons and planets either repel or attract radially, vortices induce a motion that circulates around each vortex. The math is something you could understand with a high-school degree. But the most obvious integral techniques are extremely slow.
-Differential techniques are more abstract and require some mathematical gymnastics involving vector calculus identities. But even the fastest differential algorithms (like multigrid, Gauss-Seidel and successive-over relaxation) are very easy to implement.
7. There is a close relationship between fluid simulation and particle systems. Can you elaborate on why this is important
--I mentioned earlier that you can discretize space using either Eulerian (that is, grid) or Lagrangian (that is, particle) views. They're mathematically equivalent but intuitively quite different. In a Lagrangian view, we model fluids as a collection of parcels (or particles) that carry information such as mass, density, temperature and vorticity. The information itself moves around with the particles. I think most people can probably visualize that -- particles moving around, pushed around by invisible forces.
--Also, ever since the second Star Trek movie, which had the Genesis device. That used an innovative visual effect called a "particle system" which remains popular to this day, in both cinema and games. Visual effects artists use them every day. It's expedient to reuse such a system to create other visual effects. So I created a fluid simualtion where you can plug my algorithms directly into an existing particle system and get much more sophisticated fluid simulation using familiar tools.
8. Given the significantly increased computing power available due to manycore platforms, what changes should we expect in fluid simulation in the next future? In a few years?
--Programmers need to learn how to write algorithms well-suited to execution on multiple cores. I think most computer science students learn about semaphors and mutex locks, but that only explains how to solve race conditions. To employ parallel hardware effectively requires achieving expertise in parallel paradigms, such as the map-reduce idea. Intel Threading Building Blocks enables programmers to use those paradigms without having to worry on the low-level job management trivial.
9. What other practical applications exist for your research?
I spent several years writing and using fluid simulations to solve real-world problems in the ocean and atmophere, and my colleages employed such techniques to sovle problems ranging from aerodynamics, optical properties of turbulence, and even infering the shape of a coastline based on the motion of waves crashing into the surf. Fluid simulation is a vast field with tremendous application. The techinques I advocate for games, however, focus entirely on visual appeal. These particular simulations would have to undergo reformulation and rigorous validation to be useful as scientific or engineering tools.

10 - Question in the live chat : How does Dr Gourlay integrate tools like Vtune and TBB in his class curriculum?
I am always looking for community feedback and questions. You can email them to or provide on twiter @artigupta

You can watch Visualize This! live alternate Tuesdays at noon Pacific on Intel Software Network TV, our new 24/7 interactive video channel. Come chat with us, or browse the On Demand section to see past episodes of our shows.
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.