Fluids in Games. Jim Van Verth Insomniac Games

Similar documents
Adarsh Krishnamurthy (cs184-bb) Bela Stepanova (cs184-bs)

Realtime Water Simulation on GPU. Nuttapong Chentanez NVIDIA Research

Fluid Simulation. [Thürey 10] [Pfaff 10] [Chentanez 11]

Navier-Stokes & Flow Simulation

CGT 581 G Fluids. Overview. Some terms. Some terms

Navier-Stokes & Flow Simulation

CS-184: Computer Graphics Lecture #21: Fluid Simulation II

Navier-Stokes & Flow Simulation

Realistic Animation of Fluids

Smoke Simulation using Smoothed Particle Hydrodynamics (SPH) Shruti Jain MSc Computer Animation and Visual Eects Bournemouth University

Overview of Traditional Surface Tracking Methods

Particle-Based Fluid Simulation. CSE169: Computer Animation Steve Rotenberg UCSD, Spring 2016

Animation of Fluids. Animating Fluid is Hard

CS 231. Fluid simulation

Interaction of Fluid Simulation Based on PhysX Physics Engine. Huibai Wang, Jianfei Wan, Fengquan Zhang

Hardware Accelerated Real-Time Fluid Surface Simulation

Realistic Animation of Fluids

Real-Time Volumetric Smoke using D3D10. Sarah Tariq and Ignacio Llamas NVIDIA Developer Technology

2.7 Cloth Animation. Jacobs University Visualization and Computer Graphics Lab : Advanced Graphics - Chapter 2 123

Dynamical Simulation 1: Particle Systems and ODEs

More Animation Techniques

Shape of Things to Come: Next-Gen Physics Deep Dive

Interactive Fluid Simulation using Augmented Reality Interface

CUDA. Fluid simulation Lattice Boltzmann Models Cellular Automata

Constraint fluids in Sprinkle. Dennis Gustafsson Mediocre

PHYSICALLY BASED ANIMATION

Real-time haptic display of fluids

Divergence-Free Smoothed Particle Hydrodynamics

Acknowledgements. Prof. Dan Negrut Prof. Darryl Thelen Prof. Michael Zinn. SBEL Colleagues: Hammad Mazar, Toby Heyn, Manoj Kumar

Interactive Fluid Simulation Using Augmented Reality Interface

Fluid Simulation. Dhruv Kore, Giancarlo Gonzalez, and Jenny Sum CS 488: Introduction to Computer Graphics Professor Angus Forbes

Preliminary Spray Cooling Simulations Using a Full-Cone Water Spray

Mass-Spring Systems. Last Time?

Computer animation for fluid simulation of a high viscous fluid melting

Solidification using Smoothed Particle Hydrodynamics

Topics in Computer Animation

CUDA/OpenGL Fluid Simulation. Nolan Goodnight

NVIDIA. Interacting with Particle Simulation in Maya using CUDA & Maximus. Wil Braithwaite NVIDIA Applied Engineering Digital Film

CNM 190, pt 2 Advanced Digital Animation Lec 03 : Art Direction on Madagascar / Effects 1

Physically Based Simulation and Animation of Gaseous Phenomena in a Periodic Domain

Fast Particle Neighbor Searching for Unlimited Scene with Fluid Refraction Improvement

Lagrangian methods and Smoothed Particle Hydrodynamics (SPH) Computation in Astrophysics Seminar (Spring 2006) L. J. Dursi

Water. Notes. Free surface. Boundary conditions. This week: extend our 3D flow solver to full 3D water We need to add two things:

A Novel Approach to High Speed Collision

AN ADAPTIVE SAMPLING APPROACH TO INCOMPRESSIBLE PARTICLE-BASED FLUID. A Dissertation WOO-SUCK HONG

3D Simulation of Dam-break effect on a Solid Wall using Smoothed Particle Hydrodynamic

Particle Systems. Lecture 8 Taku Komura

Simulation of Swirling Bubbly Water using Bubble Particles

Simple and Fast Fluids

Post Mortem: GPU Accelerated Effects in Borderlands 2

A Particle Cellular Automata Model for Fluid Simulations

Ship in a Bottle. 1 Modeling and Rendering the Water. Saket Patkar and Bo Zhu

MOTION CONTROL FOR FLUID ANIMATION: FLOW ALONG A CONTROL PATH

Coastal impact of a tsunami Review of numerical models

FLUID SIMULATION. Kristofer Schlachter

Theodore Kim Michael Henson Ming C.Lim. Jae ho Lim. Korea University Computer Graphics Lab.

Robust Simulation of Sparsely Sampled Thin Features in SPH-Based Free Surface Flows

Creating Flood Effects in Uncharted 3. Eben Cook VFX Naughty Dog

CS5610 Final Project : Realistic Water Simulation with opengl

A Simple Fluid Solver based on the FFT

The 3D DSC in Fluid Simulation

Particle-based Fluid Simulation

Efficient Tridiagonal Solvers for ADI methods and Fluid Simulation

Comparison between incompressible SPH solvers

Homogenization and numerical Upscaling. Unsaturated flow and two-phase flow

Chapter 3: Computer Animation Reminder: Descriptive animation. Procedural animation : Examples. Towards methods that generate motion?

Parallel GPU-Based Fluid Animation. Master s thesis in Interaction Design and Technologies JAKOB SVENSSON

Three Dimensional Numerical Simulation of Turbulent Flow Over Spillways

CIBSE YEN CFD Presentation. Joseph Berthoud

The Immersed Interface Method

Adaptive Particles for Incompressible Fluid Simulation (Technical Report tamu-cs-tr )

2D numerical simulation of ocean waves

Overview. Applications of DEC: Fluid Mechanics and Meshing. Fluid Models (I) Part I. Computational Fluids with DEC. Fluid Models (II) Fluid Models (I)

Volcanic Smoke Animation using CML

FINITE ELEMENT MODELING OF THICK PLATE PENETRATIONS IN SMALL CAL MUNITIONS

An Adaptive Sampling Approach to Incompressible Particle-Based Fluid

Permeable and Absorbent Materials in Fluid Simulations


Simulating Bubbles Michael Running Wolf 4/1/05. Introduction

Surface Tension in Smoothed Particle Hydrodynamics on the GPU

Tutorial 23: Sloshing in a tank modelled using SPH as an example

Aurélien Thinat Stéphane Cordier 1, François Cany

Ocean simulation and rendering in War Thunder. Tim Tcheblokov, NVIDIA

Lagrangian and Eulerian Representations of Fluid Flow: Kinematics and the Equations of Motion

IMPROVED WALL BOUNDARY CONDITIONS WITH IMPLICITLY DEFINED WALLS FOR PARTICLE BASED FLUID SIMULATION

Smoothed Particle Hydrodynamics on GPUs

Institutionen för systemteknik

6 Fluid. Chapter 6. Fluids. Department of Computer Science and Engineering 6-1

Fluid Solver built in Houdini

Lattice Boltzmann with CUDA

Flow Structures Extracted from Visualization Images: Vector Fields and Topology

Continued Investigation of Small-Scale Air-Sea Coupled Dynamics Using CBLAST Data

Abstract. Introduction. Kevin Todisco

Example 13 - Shock Tube

Interactive 2D Screen Space Fluids with Shaders

Position-Based Viscoelastic fluid simulation

Parallelization study of a VOF/Navier-Stokes model for 3D unstructured staggered meshes

Accelerating Fluids Simulation Using SPH and Implementation on GPU

Transfer and pouring processes of casting by smoothed particle. hydrodynamic method

Level set methods Formulation of Interface Propagation Boundary Value PDE Initial Value PDE Motion in an externally generated velocity field

Transcription:

Fluids in Games Jim Van Verth Insomniac Games www.insomniacgames.com jim@essentialmath.com

Introductory Bits General summary with some details Not a fluids expert Theory and examples

What is a Fluid? Deformable Flowing Examples Smoke Fire Water

What is a Fluid?

What is a Fluid?

What is a Fluid?

Fluid Concepts Fluids have variable density (Density field)

Fluid Concepts Fluids flow (Vector field)

Fluid Concepts Need way to represent Density (x) Velocity (u) Sometimes temperature

Fluid Concepts Our heroes:

Fluid Concepts Our heroes: Navier

Fluid Concepts Our heroes: Navier Stokes

Fluid Concepts Their creation: " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f

Fluid Concepts Their creation: " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f THE END!

Fluid Concepts Their creation: " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f SERIOUSLY -- WHAT DOES THIS MEAN?

Fluid Concepts Want change in velocity field

Fluid Concepts Want change in velocity field

Fluid Concepts Want change in velocity field

Fluid Concepts Want change in velocity field

Fluid Concepts What affects it?

Fluid Concepts What affects it? External Forces

Fluid Concepts What affects it? Viscosity

Fluid Concepts What affects it? Advection

Fluid Concepts What affects it? Pressure

Fluid Concepts Back to Navier-Stokes " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f

Fluid Concepts Brief notational diversion " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f

Fluid Concepts Brief notational diversion " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f Gradient (vector along partial derivative)

Fluid Concepts Brief notational diversion " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f Divergence (real derivative of vec. field)

Fluid Concepts Brief notational diversion " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f Laplacian (divergence of gradient)

Fluid Concepts Brief notational diversion " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f Advection operator (transport of flow)

Fluid Concepts Back to Navier-Stokes " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f Change in Velocity

Fluid Concepts Back to Navier-Stokes " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f Advection

Fluid Concepts Back to Navier-Stokes " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f Pressure

Fluid Concepts Back to Navier-Stokes " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f Viscosity

Fluid Concepts Back to Navier-Stokes " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f External Forces

Fluid Concepts Back to Navier-Stokes " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f HOLD ON THERE BUCKO

Fluid Concepts Back to Navier-Stokes " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f WHAT S THIS ONE?

Fluid Concepts Back to Navier-Stokes " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f Mass Conservation

Fluid Concepts In principle then, Navier-Stokes is " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f

Fluid Concepts In principle then, Navier-Stokes is " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f THE END!

Fluid Concepts But not really, of course

Fluid Concepts But not really, of course Little tiny detail of implementation

Computational Fluid Types Grid-based/Eulerian (Stable Fluids) Particle-based/Lagrangian (Smoothed Particle Hydrodynamics) Surface-based (wave composition)

Grid-Based Store density, temp in grid centers

Grid-Based Velocity (flow) from centers as well Could also do edges

Grid-Based How do we use this? " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f

Grid-Based Jos Stam devised stable approximation: Stable Fluids, SIGGRAPH 99

Grid-Based How do we use this? " u = 0 Must maintain #u #t = $(u ")u $ 1 % "p + &" 2 u + f

Grid-Based How do we use this? " u = 0 Idea: compute #u #t = $(u ")u $ 1 % "p + &" 2 u + f

Grid-Based How do we use this? " u = 0 Idea: compute #u #t = $(u ")u $ 1 % "p + &" 2 u + f

Grid-Based How do we use this? " u = 0 Idea: compute #u #t = $(u ")u $ 1 % "p + &" 2 u + f then project to 0 div field

Grid-Based How do we use this? End up with "u "t = P(#(u $)u + %$ 2 u + f)

Grid-Based How do we use this? Easy "u "t = P(#(u $)u + %$ 2 u + f)

Grid-Based How do we use this? Sparse linear system "u "t = P(#(u $)u + %$ 2 u + f)

Grid-Based How do we use this? Sparse linear system "u "t = P(#(u $)u + %$ 2 u + f)

Grid-Based How do we use this? Non-linear ugh "u "t = P(#(u $)u + %$ 2 u + f)

Grid-Based Updating advection General idea:

Grid-Based Updating advection General idea: look at current position

Grid-Based Updating advection General idea: follow flow to prev. position

Grid-Based Updating advection General idea: get velocity there

Grid-Based Updating advection General idea: assign to current position

Grid-Based Overview Update velocities based on Forces, then Advection, then Viscosity Project velocities to zero divergence Update densities based on Input sources Velocity Diffusion (similar to viscosity, sometimes not used) Draw it

Rendering Grid-Based Build level surface

Rendering Grid-Based Determining color, transparency

Issues Limited space Water splashes get lost Can be computationally expensive Dampens down But stable

Implementation Little Big Planet Death smoke Bubble pop Other smoke effects Hellgate: London GDC09 NVIDIA demo

Smoothed Particle Hydrodynamics Approximate fluid with small(er) set of particles

SPH Velocities at particles provide flow

SPH Idea: treat as particle system

SPH Idea: treat as particle system Determine forces

SPH Idea: treat as particle system Determine forces Update velocities, positions

SPH Weighted average gives density (smoothing kernel)

SPH Can also use kernel to get general velocity

SPH Usually center at particle

SPH Specify width by h h

SPH Specify vector from other particles by r r h

SPH Example kernel h

SPH Common kernel W poly 6 (r,h) = 315 $ (h 2 # r 2 ) 3 % 64"h 9 & 0 0 ' r ' h otherwise

SPH Common kernel W poly 6 (r,h) = 315 $ (h 2 # r 2 ) 3 % 64"h 9 & 0 0 ' r ' h otherwise Clamps to zero at boundary

SPH Common kernel W poly 6 (r,h) = 315 $ (h 2 # r 2 ) 3 % 64"h 9 & 0 0 ' r ' h otherwise Clamps to zero at boundary Uses length squared

SPH General SPH rule A S (x) = " m A j j j # j W (r $ r j,h)

SPH General SPH rule A S (x) = " m A j j j # j W (r $ r j,h) Particle mass

SPH General SPH rule A S (x) = " m A j j j # j W (r $ r j,h) Quantity at particle j

SPH General SPH rule A S (x) = " m A j j j # j W (r $ r j,h) Density at particle j

SPH General SPH rule A S (x) = " m A j j j # j W (r $ r j,h) Weighting function

SPH Computing density " S (x) = # m " j j W (r $ r j,h) " j j

SPH Computing density " S (x) = # m j W (r $ r j,h) j

SPH Local pressure p i = k" i k is gas constant

SPH Local pressure p i = k" i k is gas constant Can be unstable, so

SPH Local pressure (alternative) p i = k(" i # " 0 ) No effect on gradient, more stable

SPH Back to Navier-Stokes " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f

SPH Back to Navier-Stokes " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f Have fixed # particles and mass, so

SPH Back to Navier-Stokes " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f Have fixed # particles and mass, so mass is automatically conserved

SPH Back to Navier-Stokes " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f Advection automagically handled by particle update, so

SPH Back to Navier-Stokes " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f Advection automagically handled by particle update, so

SPH Simplifies to " u = 0 #u #t = $(u ")u $ 1 % "p + &" 2 u + f

SPH Simplifies to " dv dt = #$p + µ$ 2 u + "f

SPH Functional breakdown " du dt = #$p + µ$ 2 u + "f

SPH Functional breakdown " du dt = #$p + µ$ 2 u + "f Change in velocity

SPH Functional breakdown " du dt = #$p + µ$ 2 u + "f Pressure

SPH Functional breakdown " du dt = #$p + µ$ 2 u + "f Viscosity

SPH Functional breakdown " du dt = #$p + µ$ 2 u + "f External forces

SPH Compute densities, local pressure Generate forces on particles External Pressure Viscosity Update velocities, positions Render

SPH Pressure f i pressure = "#p(r i )

SPH Pressure f i pressure = " m p j j j # j $W (r i % r j,h)

SPH Pressure f i pressure = " m p j j j # j $W (r i % r j,h) Asymmetric, so

SPH Pressure f i pressure = " m p i + p j j j 2# j $W (r i % r j,h) Ensures 2-particle interaction equal

SPH Pressure kernel Problem: gradient of poly6 kernel is zero at origin

SPH Pressure kernel Problem: gradient of poly6 kernel is zero at origin

SPH Pressure kernel W spiky (r,h) = 15 $ (h # r) 3 % "h 6 & 0 0 ' r ' h otherwise

SPH Viscosity f i viscosity = µ" 2 v(r i )

SPH Viscosity f viscosity i = µ " m v j j $ 2 W (r i % r j,h) # j j

SPH Viscosity f viscosity i = µ " m v j j $ 2 W (r i % r j,h) # j Also asymmetric, so j

SPH Viscosity f viscosity i = µ " m v j # v i j % 2 W (r i # r j,h) $ j j Ensures 2-particle interaction opposite

SPH Viscosity kernel W viscosity (r,h) = 15 $ # r 3 & 2"h 3 2h + r2 3 h + h % 2 2r #1 '& 0 0 ( r ( h otherwise

SPH Rendering Marching cubes (using smoothing kernel) Blobs around particles/splatting

SPH Implementations Takahiro Harada Kees van Kooten (Playlogic) NVIDIA PhysX Rama Hoetzlein* (SPH Fluids 2.0) Takashi AMADA* * Source code available

SPH Issues Need a lot of particles Computing level surface can be a pain Can be difficult to get stable simulation

SPH Improvements Spatial hashing Variable kernel width CFD/SPH Hybrid CFD manages general flow SPH splashes

Surface Simulation Idea: for water, all we care about is the airwater boundary (level surface) Why simulate the rest? This is what Insomniac R20 system does

R20 Done by Mike Day, based on Titanic water Basic idea: convolve sinusoids procedurally * = Much cheaper to multiply in frequency domain and do FFT (assuming periodic)

R2O Review Sinusoid in spatial domain

R2O Review Can represent as magnitude+phase in frequency slot

R2O Review Requires periodic function FFT

R2O Review Multiple sinusoids end up at multiple entries FFT

R2O Wave speed dependant on wavelength

R2O Wave speed dependant on wavelength

R2O Wave speed dependant on wavelength

R2O Wave speed dependant on wavelength

R2O Wave speed dependant on wavelength I.e. phases update at different rates AKA dispersion

R2O General procedure Start with convolved data in (r,!) form Update phase angles for each sinusoid Angular velocity*dt Dependent on frequency Do inverse FFT to get spatial result

R2O FFT kernel limited to 32x32 Combine multiple levels via LOD height field scheme Gives high detail close to camera

R2O Interactive waves Just adding in splashes looks fake Instead, do some more FFT trickery so all our work occurs in the same domain Non-periodic, so have to manage edges Gives nice dispersion effects

R2O Rendering Rendered as height field mesh Add normal map for detail Cube map/frame buffer map for reflections Distortion effect for refractions

R2O Nifty video

References Jos Stam, Stable Fluids, SIGGRAPH 1999 Mattias Müller, et. al, Particle-Based Fluid Simulation for Interactive Applications, SIGGRAPH Symposium on Computer Animation 2003 Jerry Tessendorf, Simulating Ocean Water, SIGGRAPH Course Notes. http://www.insomniacgames.com/tech