Fluid Animation
-
Upload
jermaine-burke -
Category
Documents
-
view
41 -
download
1
description
Transcript of Fluid Animation
![Page 1: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/1.jpg)
Fluid Animation
CSE 3541 By: Matt Boggus
![Page 2: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/2.jpg)
Overview
• Procedural approximations
• Mathematical background
• Computational models for representing fluids
• Using the computational models– Forces– “Stable fluids” by Stam
![Page 3: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/3.jpg)
Real-time fluids
• Goals:– Cheap to compute– Low memory consumption– Stability– Plausibility– Interactivity
• Simulate the effect, not the cause
![Page 4: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/4.jpg)
Real-time fluids
• Procedural water– Unbounded surfaces, oceans
• Particle systems– Splashing, spray, puddles,
smoke, bubbles, rain
• Heightfield fluids– Ponds, lakes, rivers
![Page 5: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/5.jpg)
Procedural water – cos wave
• Visualization of parameter changes using graphing calculator
![Page 6: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/6.jpg)
Superimposed linear waves
Normal vector displacement Height displacement
![Page 7: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/7.jpg)
Heightfield fluid
• Function u(x,y) gives height at (x,y)
• Store height values in an array u[x,y]
![Page 8: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/8.jpg)
Can this wave be represented using a heightfield?
![Page 9: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/9.jpg)
Setting and updating heightfield fluids
• Methods– Pressure or height differences between cells– Collision detection and displacement
• Additional considerations– When updating, a second heightfield may be used
to preserve the values from the previous frame– Handle boundary cases differently
![Page 10: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/10.jpg)
Pressure/Height differences
Initialize u[i,j] with some interesting functionInitialze v[i,j]=0loop
v[i,j] += (u[i-1,j] + u[i+1,j] + u[i,j-1] + u[i,j+1])/4 – u[i,j]v[i,j] *= 0.99u[i,j] += v[i,j]
endloopClamp at boundary
![Page 11: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/11.jpg)
Example videos
• Real-Time Eulerian Water Simulation– Grid based – https://www.youtube.com/watch?v=Jl54WZtm0QE
• SPH based real-time liquid simulation– Particle based– https://
www.youtube.com/watch?v=6CP5QvfuD_w
![Page 12: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/12.jpg)
Fluid Models
Grid-based (Eulerian) d is density
Particle-based (Lagrangian)
Hybrid Animate the particles “Collect” particles to compute density
d d dd
d d dd
d d dd
d d dd
![Page 13: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/13.jpg)
Navier-Stokes Equation
• Momentum equation
• Incompressibility
ut = k2u –(u)u – p + f
u=0
Change in velocity
Diffusion/ Viscosity
Advection Pressure Body Forces
u: the velocity fieldk: kinematic viscosity
![Page 14: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/14.jpg)
Diffusion/Viscosity Force • Limit shear movement of particles in the liquid• The momentum between the neighbour particles
are exchanged
Pp
Ppn
exchpnpn
exchpp
exch
pnp
i
n
n i
pnppnexch
PPP
PPPP
PPdkv
dk
tPPdkvP
exchanced momentum:
pn and p of momentum:, particle processed thefrom distance :
(Gaussian)function gA weightin :()tcoefficien viscosity:
)(2
))((
1
![Page 15: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/15.jpg)
Adhesion ForceAttract particles to each other and to other
objects (similar to gravitational force)
The adhesion force between (left) honey-honey, (middle) honey-ceramic and (right) non-mixing liquid
![Page 16: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/16.jpg)
Advection Force
Velocity grid
![Page 17: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/17.jpg)
Pressure force
![Page 18: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/18.jpg)
Pressure force
![Page 19: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/19.jpg)
Friction Force
tt fvv ˆ
• Dampen movement of particles in contact with objects in the environment
• Scale down the velocity by a constant value
![Page 20: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/20.jpg)
Rendering particles
![Page 21: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/21.jpg)
Heightfield mesh particle collection
Step 2. For each u[i,j], determine which particles are closet to it(bounding box collision test)
Step 1. Zero out all u[i,j]
Alternative Step 2. For each particle, determine which (i,j) it is closest to(translate position half a cell, then floor it)
![Page 22: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/22.jpg)
Case Study: A 2D Fluid Simulator
• Incompressible, viscous fluid• Assuming the gravity is the only external force • No inflow or outflow • Constant viscosity, constant density
everywhere in the fluid
![Page 23: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/23.jpg)
Stable Fluids – overview of data
Velocity grid Density grid
Move densities around using velocity grid and dissipate densities
Move velocities around using velocity grid and dissipate velocities
Walkthrough: http://www.dgp.utoronto.ca/~stam/reality/Talks/FluidsTalk/FluidsTalkNotes.pdfSource code: http://www.autodeskresearch.com/publications/games
![Page 24: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/24.jpg)
Additional readings
• Fluid Simulation for Computer Animation (SIGGRAPH course)
• The original stable fluids paper• An update to the stable fluids work
• Fast Water Simulation for Games Using Height Fields (GDC talk)
![Page 25: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/25.jpg)
ADDITIONAL SLIDES
![Page 26: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/26.jpg)
Heightfield mesh creation and cell iteration
• Covered earlier with terrains
![Page 27: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/27.jpg)
Heightfield or Heightmap terrain data
2D greyscale image Surface in 3D space
Images from http://en.wikipedia.org/wiki/Heightmap
![Page 28: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/28.jpg)
Heightfield mesh creation and cell iteration
u[x,y] ; dimensions n by n
![Page 29: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/29.jpg)
Heightfield mesh creation and cell iteration
Quad[i,j] such that i = 0, j = 0; Vertices are U[0,0], U[1,0], U[1,1], U[0,1] U[i,j], U[i+1,j], U[i+1,j+1], U[i,j+1]
![Page 30: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/30.jpg)
Heightfield mesh creation and cell iteration
Inner loop iterates over i, the x coordinate Last quad: i=5 (i = n-1)
![Page 31: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/31.jpg)
Heightfield mesh creation and cell iteration
Outer loop iterates over j, the y coordinateLast row: j=5 (j = n-1)
![Page 32: Fluid Animation](https://reader036.fdocuments.us/reader036/viewer/2022062502/56813207550346895d985aad/html5/thumbnails/32.jpg)
Smoothing
• For every grid cell u[i,j], set it to average of itself and neighbors
• Implementation concerns:– A. looping order– B. boundary cases– C. both– D. none