animation of fluids. animating fluid is hard… too complex to animate by hand –surface is...

47
Animation of Fluids

Upload: geoffrey-patterson

Post on 12-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 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!

Animation of Fluids

Page 2: 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!

Animating Fluid is Hard…

• Too complex to animate by hand– Surface is changing

very quickly– Lots of small details– In short, a nightmare!

• Need automaticsimulations…

Page 3: 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!

Ad-Hoc Methods

• Some simple algorithmsexist for special cases– Mostly waves…

• What about water glass?

• Too much work to comeup with empirical algorithmsfor each case…

Page 4: 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!

Physically-Based 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 mass-spring systems

Page 5: 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!

Current State-of-the-art in CG

• Marker-And-Cell (MAC) Method– fedkiw_fluid\glass00.avi– fedkiw_fluid\splash-640.avi

• Smoothed Particle Hydrodynamics (SPH)– muller_particles\sph.avi– muller_particles\pool.avi

Page 6: 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!

Applications

• Mostly Hollywood– Shrek– Antz– Terminator 3– Many others…

• Games

• Engineering…

Page 7: 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!

Fluid Dynamics

(with as little math as possible)

Page 8: 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!

What do we mean by ‘Fluid’?

• liquids or gasses

• Mathematically:– A vector field u (represents the fluid velocity)– A scalar field p (represents the fluid pressure)– fluid density (d) and fluid viscosity (v)

Page 9: 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!

Vector Fields

• 2D Scalar function:– f(x,y) = z – z is a scalar value

• 2D Vector function:– u(x,y) = v – v is a vector value

• v = (x’, y’)

• The set of valuesu(x,y) = v is called avector field

Page 10: 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!

Fluid Velocity == Vector Field

• Can model a fluid as a vector field u(x,y)– u is the velocity of the fluid at (x,y)– Velocity is different at each point in fluid!

• Need to compute change in vector field

Page 11: 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!

Conceptual Leap

• Particle Simulation:– Track particle positions x = (x,y)– Numerically Integrate: change in position

• Fluid Simulation :– Track fluid velocities u = (u,v) at

all points x in some fluid volume D– Numerically Integrate: change in velocity

dt

dx

dt

du

Page 12: 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!

Equations of Fluid Dynamics

• Navier-Stokes Equation:

– Non-linear Partial Differential Equation– Models fluid transport – Derived from Newton’s second law

• conservation of momentum – all the forces go “somewhere”

• Mass-Conservation condition:– If we have a liter of water at the beginning of the solution, we have

a liter at the end…

Page 13: 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!

Change in Velocity

• Derivative of velocity with respect to time

• Change in velocity, or acceleration– So this equation models acceleration of fluids

Page 14: 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!

Advection Term

• Advection term– Force exerted on a particle

of fluid by the other particlesof fluid surrounding it

– How the fluid “pushes itself around”

Change inVelocity

Page 15: 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!

Particle Advection

Video

Page 16: 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!

Diffusion Term

• Viscosity constant controls velocity diffusion

• Essentially, this term describes how fluid motion is damped

• Highly viscous fluids stick together– Like maple syrup

• Low-viscosity fluids flow freely– Gasses have low viscosity

AdvectionChange inVelocity

Page 17: 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!

Weather: Advection & Diffusion

• “Jet-Stream”

Page 18: 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!

Pressure Term

• Pressure follows a diffusion process– Fluid moves from high-pressure

areas to low-pressure areas

• Moving == velocity– So fluid moves in direction of

largest change in pressure– This direction is the gradient

DiffusionAdvectionChange inVelocity

p = 0.5

p = 1p = 0

Time…

Page 19: 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!

Weather: Pressure

• “Fronts” are the boundaries between regions of air with different pressure…

• “High Pressure Zones” will diffuse into “Low Pressure Zones”

Page 20: 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!

Fluid Example

• Fast moving fluid is “pulled” towards slower-moving fluid

Page 21: 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!

Body Force

• Body force term represents external forces that act on the fluid– Gravity– Wind– Etc…

DiffusionAdvectionChange inVelocity Pressure

Page 22: 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!

Summary

• And 1 liter == 1 liter constraint:

• Need to simulate these equations…

DiffusionAdvectionChange inVelocity Pressure

Page 23: 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!

Intermission

• Smoke– fedkiw_octree\smoke_octree.avi

• Fire– fedkiw_fire\flammable.avi

Page 24: 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!

Implementation Overview

Page 25: 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!

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

Page 26: 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!

Solution: Discretization

• Create regular grid

Page 27: 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!

Solution: Discretization

• Create regular grid

• Discretize fluid into grid cells

Page 28: 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!

Solution: Discretization

• Create regular grid

• Discretize fluid into grid cells

• Track single velocityvector in eachgrid cell

Page 29: 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!

Simulation Step

• “Solve” Navier-Stokes equation for each grid cell to compute change in velocity:

finite-difference Diffusion and Pressure terms are linear systems of equations

Body Force is just like mass-spring systems

fuuuu

pd

vt

1)()(

non-linear Advection term is difficult. Can finite-difference, but is not robust…

Page 30: 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!

Free Surface Tracking with Marker Particles

• Want higher-resolution surface for rendering

• Add a bunch of particles

• Passively Advect thembased on fluid velocity

Page 31: 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!

So the rest is easy, right?

• No

• Still have to enforce mass-conservation constaint:

• Standard equation does not take boundary conditions into account– Boundary conditions are things like walls, fluid/air

boundaries, rubber duckies, and so on– Have to ‘hack’ the equations…this is hard…

• Numerical Stability is elusive…

Page 32: 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!

Intermission 2

• Melting– carlson_melting\bunnyside.mpg

• Rigid Body + Fluid– carlson_rigidfluid\rigidfluid.avi

Page 33: 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!

Problems with Fluid Simulation

Page 34: 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!

Surface Resolution…

Page 35: 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!

Weird Behavior….

Page 36: 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!

Water or Vegetable Oil?

• fedkiw_fluid\glass00.avi

• Oh, and it’s very, very slow– 7 minutes

per frame forwater glass…

Page 37: 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!

Hard to Control

• Animators want to control fluid behavior

• Fluid simulation has a lot of free variables

• There has been limited success so far…

Page 38: 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!

Numerical Stability

Page 39: 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!

Maya Fluid Effects

Page 40: 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!

What does fluid effects support?

• Naver-Stokes-based Fluids:– Smoke– Clouds– Explosions– Fire– “Goo” type-stuff

• Ad-Hoc / Mass-Spring fluids:– Oceans– Ponds

Page 41: 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!

Fluid Effects Algorithms

• Unconditionally Stable Navier-Stokes simulation– Means they never explode, even with large timesteps – Jos Stam, “Stable Fluids”, SIGGRAPH 99

• Do not preserve volume very well– Ok for smoke– Problematic for water glass…– Gets worse w/ larger timestep

Page 42: 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!

Maya Smoke

• Smoke demo

Page 43: 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!

Maya Fire

• Looks like smoke…

Page 44: 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!

More Fluid Effects Demos

Page 45: 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!

Maya Ocean

• 2D height field – no crashing waves

• Can attach ‘bouyant’ objects

Page 46: 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!

Maya Pond

• 2D height field– No splashing

• Mass-spring system

• Bouys, Boats, Wakes

• Can run in real-time

Page 47: 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!

Fin

(questions?)