Animation of Fluids Animating Fluid is Hard Too complex to animate by hand Surface is changing very quickly Lots of small details In short, a nightmare! Need automatic simulations
AdHoc Methods Some simple algorithms exist for special cases Mostly waves What about water glass? Too much work to come up with empirical algorithms for each case PhysicallyBased Approach Look to Fluid Dynamics Long history. Back to Newton Equations that describe fluid motion Use numerical methods to approximate fluid equations, simulating fluid motion Like massspring systems
Mostly Hollywood Shrek Antz Terminator 3 Many others Games Engineering Applications Fluid Representation Want to simulate motion of some fluid body fluid is represented by a vector field Two problems: Need to compute change in vector field (using Navier Stokes equation) Need to track fluid position
Solution: Discretization Create regular grid Solution: Discretization Create regular grid Discretize fluid into grid cells 4
Solution: Discretization Create regular grid Discretize fluid into grid cells Track single velocity vector in each grid cell Equations of Fluid Dynamics NavierStokes Equation: Nonlinear Partial Differential Equation Models fluid transport Derived from Newton s second law conservation of momentum all the forces go somewhere MassConservation condition: If we have a liter of water at the beginning of the solution, we have a liter at the end 5
Gradient of the velocity field= 0 Conservation of Mass u = 0 u t = Fluid Basics 1 ρ 2 ( u ) u ν u p f Fluid Basics Time derivative of velocity field Think acceleration u t a u = 0 u t = 1 ρ 2 ( u ) u ν u p f
Change in Velocity Derivative of velocity with respect to time Change in velocity So this equation models acceleration of fluids Advection Term Change in Velocity Advection term Force exerted on a particle of fluid by the other particles of fluid surrounding it How the fluid pushes itself around
Particle Advection Diffusion Term Change in Velocity Advection Viscosity constant controls velocity diffusion Essentially, this term describes how fluid motion is diffused or damped Highly viscous fluids stick together Like maple syrup Lowviscosity fluids flow freely Gases have low viscosity
Pressure Term Change in Velocity Advection Diffusion Fluid moves from highpressure areas to lowpressure areas p = 0 p = 1 So fluid moves in direction of largest change in pressure Time This direction is the gradient p = 0.5 Body Force Change in Velocity Advection Diffusion Pressure Body force term represents external forces that act on the fluid Gravity Wind Etc
u = 0 u t = Body Force Can be or represent anything Used for gravity or to let animator stir 1 ρ 2 ( u ) u ν u p f
NavierStokes How do we solve these equations? u = 0 u t = 1 ρ 2 ( u ) u ν u p f Operator Splitting u = 0 u t = 1 ρ 2 ( u ) u ν u p f
1) First solve for a guess of the velocity change holding out pressure term 2) Use this tentative guess to determine velocity field via mass conservation 3) Plug new velocity to solve for pressure 4) Finally use this pressure to determine the actual velocity change Operator Splitting Finding Surfaces 0 0 MAC Grid Level Set
Finding Surfaces Particle Level Sets Modeling complex surfaces (see Fedkiw) Water to solid Melting solids: change viscocity Viscosity varies linearly or quadratically with T
Water to solid Viscoelastic fluids? One additional term to Navier Stokes The strain term Results
Issues: Surface Resolution CS 231 Natural Phenomena Fire, Smoke, Explosions
Natural phenomena why? Scale/Money/Complexity? no Problem Control over animation example: face in smoke Natual beauty of the world around us Natural phenomena where is the research? Modeling starts from engineering and physics principles Graphics require only a subset of effects and only visual accuracy. Thus: precision vs. speed Controls sometimes added for animators Rendering often an issue
Natural phenomena disaster and destruction Explosions Fire Wind Smoke Explosions and modeling of blast waves
Explosions and modeling of blast waves Governing principles and equations Compressible fluid dynamics Heat transfer via conductivity, work from pressure, viscous dissipation, convection Ideal gas laws Explosions and modeling of blast waves First Law of Thermodynamics Change in energy = heat work conduction pressure viscous convection (heat) (work) (work) (E moves)
Explosions and modeling of blast waves Graphical model Voxels for regular grid, as in water simulation Operator splitting solve for ~acceleration/vels without convection Update energy & density w/o convection Recompute vel, energy, and density Update other variables Explosions and modeling of blast waves Rendering model Blackbody radiation used to render fireballs, based on temperature Blast affects index of refraction like in real explosions
Explosions and modeling of blast waves Results Results
Animating fire and flames Animating fire and flames Governing principles and equations Conservation of mass in fuel consumption Conservation of momentum Density change based on solid/gas transitions in fuel, affects velocity
Animating fire and flames Graphical model Fluid modeled again as voxels, imcompressible flow. Include buoyancy forces and vorticity Implicit surface/level set method separates the flame/fire from the surrounding air Animating fire and flames Rendering Rendering fire depends on temperature, internal heat Computed based on incandescence taken from internal energy
Results Results
Animating the effects of wind, gases, and smoke Animating the effects of wind, gases, and smoke Governing principles and equations Again incompressible flow Hydrodynamic primitives combine to create complex flow Hot gas modeled as 3d fluid with temperature propagation
Animating the effects of wind, gases, and smoke Foster Animating the effects of wind, gases, and smoke Fedkiw, Stam, Jensen Added vorticity explicitly From the calculated vorticity, forces are added back into the navierstokes
Animating the effects of wind, gases, and smoke Wind force on an object vt v vn surface (Area = A) Ft = α A vt α, friction constant Fn = A vn Animating the effects of wind, gases, and smoke Graphical model For wind, the visual effects come from objects moving For gas as steam and smoke, use voxel based approach
Animating the effects of wind, gases, and smoke Rendering smoke Scattering based on statistical process Transparency Results
Natural phenomena a recipe for disaster Starting from physical principles Simplify to appropriate level for needed effect Consider animator handles Make pretty pictures