Many fluid simulations run slowly. Games need fast solutions, even if at the cost of accuracy.
Fluid simulations can be slow for many reasons, including these:
- Flow treated as incompressible imposes a divergence-free condition which requires a global solution to enforce that condition.
- Solutions can be unstable.
Making them stable requires either explicitly high viscosity or unintentionally incorporates very high "numerical" viscosity from implicit solvers,
which degrades details and makes the simulation look muddy.
- Techniques that try to compensate by artificially injecting detail just looks like noise instead of the beautiful filamentary wisps that characterize fluid flow.
- Traditional approaches to satisfying boundary conditions require global solutions and often entail imposing constraints on the shape of the simulation domain. Simulations that can handle complicated boundary conditions (such as arbitrary shapes or expanding boxes) typically employ sophisticated and computationally expensive techniques, such as dynamic regridding or level set methods.
These problems have solutions. Mesh-free algorithms simulate interactions between particles. These techniques lack numerical diffusion and preserve detail. Naive direct computations of such interactions require a computational complexity of O(N^2). Approximate methods such as fast-multipole and treecode can consume O(N log N) operations. But games need faster techniques.
Real-time simulations exploit the embarrassingly parallel nature of the fluid simulation algorithms. Some use massively parallel graphics processing units (GPU's). While these simulations to indeed run in real time, they rob video games of an important resource, which is the ability to render complex and compelling virtual environments and characters. Games require solutions that use CPU resources for simulation and leave GPU resources for rendering.
This vortex particle simulation solves these problems.
It's used in professional software like Red Giant Trapcode Suite 15, including Red Giant Trapcode Particular and Red Giant Trapcode Form.
I explain below how it works, in 21 articles, with demo videos and source code, all free.
A fluid simulation for video games should satisfy these requirements:
- Fast; The simulation should run in real-time: 30 frames per second or faster.
- Controllable; Effects artists should be able to author effects, and influence or steer flow.
- Detailed; Flow should retain fine details such as wisps since they are aesthetically pleasing.
- Flexible; Fluid region should be able to expand to any size and any shape, with open or closed boundaries.
- Scalable; The simulation should work for large and small effects.
- Plausible; Results should have the ability to appear natural and not appear distractingly artificial.
- Beautiful; Results should appear aesthetically pleasing.
- Accessible; The implementation should be affordable to write and easy to understand.
- Robust; The implementation should be easy to modify and tune without introducing numerical instabilities.
- Interactive; The fluid should interact with other entities, including user-controlled, moving or stationary.
- Parallelizeable; The simulation code should exploit multiple cores when they are available.
- The simulation should handle multiple immiscible fluids such as water with air, combustion (fuel, plasma and exhaust).
- The simulation should work with 2D or 3D flows.
My choice of simulation uses a vortex particle method: Particles representing small vortices (called "vortons") induce a velocity field which in turn moves the vortons.
Tracking vortons means the fluid lacks numerical viscosity that erodes detail in simulations that use grid-based methods. Also, a relatively small number of vortons induces a pleasingly chaotic velocity field which drives a much larger number of passive tracer particles used for rendering. Effects authors can control the number of vortons independently from the number of tracers, thereby separately controlling simulation and rendering resolution.
Grid-free particle methods such as the one these simulations employ only need particles in regions where the flow behaves "interestingly", which is near vortices. Vortices induce fluid motion. They also represent a (potentially very high resolution) velocity gradient which implies that a grid-based solution would require twice or more the resolution in each direction so for example to simulate the same flow in a grid-based simulation would require 2x2x2=8 times as many grid points -- and that assumes vortices densely populate the entire grid, which is unlikely. Furthermore, grid-free methods can conform to any shape without expensive regridding techniques.
This simulation provides multiple velocity-from-vorticity solvers: A direct solver provides a gold-standard exact (but slow) velocity calculation for comparison with other methods. Some simplify far-field interactions by using integral methods, either treecode or a novel "monopole" approach. Another uses a multigrid Poisson differential solver. Yet another uses a treecode to compute vector potential at boundaries and a Poisson solver elsewhere, yielding the best of both approaches: speed, high quality and flexibility.
In one incarnation, the algorithm exploits nearest-neighbor information, and incidentally includes a new approximate dynamic nearest neighbor tracking algorithm that runs in linear time. In the nearest-neighbor incarnation, the simulation approximates spatial gradients by comparing properties of each particle with that of its neighbors.
In another incarnation, the simulation transfers quantities from particles to a grid where spatial gradients are computed, then updates the source particles.
Vortex stretching and tilting plays a crucial role in the cascade from laminar to turbulent flow. For visual effects, authors can inject pseudo-turbulence a priori. This simulation includes vortex stretching and tilting by computing spatial gradients of velocity, but games may elect to omit those terms if they inject turbulence artificially.
To handle stratified fluids and multiple fluids with different densities the simulation must handle baroclinic generation of vorticity. In principle that requires knowing both density and pressure gradients, but this simulation assumes pressure gradients come from hydrostatic equilibrium. The simulation includes a combustion model which generates heat that feeds the baroclinic generator to create fire and smoke plumes.
A particle strength exchange (PSE) approach facilitates computing viscous and thermal diffusion, thereby avoiding a need to compute high-order spatial gradients using a grid.
Effects authors can control flows using two methods: They can tune fluid flow parameters and they can use traditional particle operations such as commonly occur in visual effects packages, like emit, wind, grow and kill.
- My real-time fluid simulations
- Fluid simulation of smoldering using vector potential from vortex particles
- Vorton Combustion
- Red Giant Trapcode Suite 15 with NEW fluid dynamics
- Curve ball
- Blue sinks, red floats
- Explanation / Campfire / Airfoil / Dragon, Bunny, Skull, Beach ball / Turbine
- Galaxy of Dots
- Ballistic Mayhem
- Atomic Vortex Ring
Intel Software Network and Gamasutra: Fluid Simulation for Video Games (series of articles)
- Part 1: Introduction to Fluid Dynamics (Intel archive) (Gamasutra) (Venture Beat) (GitHub)
- Part 2: Simulation Techniques (Intel archive) (Gamasutra) (GitHub)
- Part 3: Vorton (Vortex Particle) Simulation (Intel archive) (GitHub)
- Part 4: Fluid-Body Interaction (Intel archive)
- Part 5: Profiling and Optimization (Intel archive)
- Part 6: Differential Velocity Solvers (Intel archive)
- Part 7: Particle Operations (Intel archive)
- Part 8: Baroclinicity - Fluid Buoyancy (Intel archive)
- Part 9: Body Buoyancy (Intel archive)
- Part 10: Thermal Effects (Intel archive)
- Part 11: Combustion (Intel archive)
- Part 12: Jerkstrophy (Intel archive)
- Part 13: Convex Obstacles (Intel archive)
- Part 14: Convex Containers
- Part 15: Smoothed Particle Hydrodynamics
- Part 16: Hybrid VPM-SPH
- Part 17: Fluid Surface Identification (Intel archive)
- Part 18: Fluid Surface Rendering (Intel archive)
- Part 19: From Vorticity through Vector Potential to Velocity (Intel archive)
- Part 20: Assigning Vector Potential at Boundaries (Intel archive)
- Part 21: Recapitulation (Intel archive)
- 2010 July: Fluid-body Simulation using vortex particle operations: International Conference on Computer Graphics and Interactive Techniques, Los Angeles, California, Session: Animation, article 8, 2010.
- 2009 August: High Performance Graphics (HPG) 2009, New Orleans, Louisiana
- 2009 March: Game Developers Conference (GDC) 2009, San Francisco, California
- 2008 August: International Conference on Computer Graphics and Interactive Techniques archive, ACM SIGGRAPH 2008, Los Angeles, California, SESSION: Animation, Article No. 5.
-
2019 Dec 5: Frozen II VFX that uses my fluid sim in Red Giant Trapcode Suite 15 Particular 4
-
2019 Apr 27: Port of VorteGrid to WebAssembly and WebGL by Julien de Charentenay
-
2019 Jan 16: Red Giant Trapcode Suite 15.0.1 update with Particular 4.0.1 and Form 4.0.1 with improvements to fluid simulation.
-
2019 Jan 15: AQUAMAN Underwater Effects using Red Giant Trapcode Suite with Particular made with my fluid simulation. "The speed is phenomenal," says Daniel Hashimoto, who also gushes about the various vortex operators.
-
2018 Oct 30: Red Giant adopted my fluid model into their Trapcode Suite 15 , Particular 4 and Form 4 products for Adobe After Effects.
-
2016 Nov 08: Fluid Simulation for Video Games, part 21: Recapitulation .
-
2016 Jun 22: Fluid Simulation for Video Games, part 20: Assigning Vector Potential at Boundaries .
-
2016 Apr 22: Fluid Simulation for Video Games, part 19: From Vorticity through Vector Potential to Velocity . Video .
-
2014 Sep 9: Fluid Simulation for Video Games, part 18: Fluid Surface Rendering
-
2013 Oct 8: Fluid Simulation for Video Games, part 17: Fluid Surface Identification
-
2013 May 1: Fluid Simulation for Video Games, part 16: VPM-SPH Hybrid
-
2013 Jan 30: Fluid Simulation for Video Games, part 15: Smoothed Particle Hydrodynamics
-
2012 Aug 15: Fluid Simulation for Video Games, part 14: Containers
-
2012 May 16: Fluid Simulation for Video Games, part 13: Convex Obstacles
-
2012 Mar 15: Fluid Simulation for Video Games, part 12: Jerkstrophy
-
2011 Dec 15: Fluid Simulation for Video Games, part 11: Combustion
-
2011 July 8: Fluid Simulation for Video Games, part 10: Thermal effects
-
2011 Mar 22: Fluid Simulation for Video Games, part 9: Body Buoyancy
-
2011 Jan 28: Reddit linked to Intel vorton fluid sim articles.
-
2011 Jan 25: Farsthary (Raul Fernandez Hernandez) added a vorton fluid particle simulation to Blender .
-
2010 Nov 5: Fluid Simulation for Video games: part 8 - Baroclinicity: Fluid Buoyancy
-
2010 July-Sept: Fluid videos: Vorton combustion . Curve ball . Blue sinks, red floats .
-
2010 Aug : Jayeson Lee-Steere ported the vorton fluid sim to iPhone. Runs in real time (by SIGGRAPH standards). First 3D fluid-body simulation on an iPhone? .
-
2010 July: Fluid-body Simulation using vortex particle operations: International Conference on Computer Graphics and Interactive Techniques, Los Angeles, California, Session: Animation, article 8, 2010.
-
2010 Apr 20: Interview on Intel Software Network TV show called Visualize This!
-
2010 Feb 10: Fluid Simulation for Video games: part 7 - Particle Operations for Fluid Motion
-
2010 Jan 21: Fluid Simulation for Video games: part 6 - Differential Velocity Solvers
-
2009 Dec 7: Fluid Simulation for Video games: part 5 - Profiling and Optimization
-
2009 Oct 28: Fluid Simulation for Video games: part 4 - Two-way Fluid-body Interaction
-
2009 Oct 28: Fluid Simulation for Video games on Gamasutra - Part 2
-
2009 Oct 15: Fluid Simulation for Video games on Gamasutra. Part 1
-
2009 Oct 2: Fluid Simulation for Video games: part 3 - Vortex Particle Fluid Simulation (PDF)
-
2009 July 21: Fluid Simulation for Video games: part 2 - Fluid Simulation Techniques (PDF)
-
2009 July 21: Fluid videos: Atomic vortex ring. Ballistic mayhem. Galaxy of Dots.
-
2009 July 7: Fluid Simulation for Video games: part 1 - Introduction to Fluid Dynamics (PDF) (Visual Adrenaline)
-
2009 Jan 20: Fluid Video.
-
2008 Aug 11: Fluid Simulation for Video games: International Conference on Computer Graphics and Interactive Techniques ACM SIGGRAPH 2008 posters. My poster at SIGgraph 2008. See A104, near the top. Poster materials