Download presentation
Presentation is loading. Please wait.
1
Fluid Animation CSE 3541 By: Matt Boggus
2
Overview Procedural approximations Mathematical background
Computational models for representing fluids Using the computational models Forces “Stable fluids” by Stam
3
Real-time fluids Goals: Simulate the effect, not the cause
Cheap to compute Low memory consumption Stability Plausibility Interactivity Simulate the effect, not the cause
4
Real-time fluids Procedural water Particle systems Heightfield fluids
Unbounded surfaces, oceans Particle systems Splashing, spray, puddles, smoke, bubbles, rain Heightfield fluids Ponds, lakes, rivers
5
Procedural water – cos wave
y = A cos (2 * pi * x / T) Visualization of parameter changes using graphing calculator
6
Superimposed linear waves
Normal vector displacement Height displacement
7
Heightfield fluid Function u(x,y) gives height at (x,y)
Store height values in an array u[x,y]
8
Can this wave be represented using a heightfield?
9
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
10
Pressure/Height differences
Initialize u[i,j] with some interesting function Initialze v[i,j]=0 loop 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.99 u[i,j] += v[i,j] endloop Clamp at boundary Algorithm from Fast Water Simulation for Games Using Height Fields Linked at end of slides
11
Example videos Real-Time Eulerian Water Simulation
Grid based SPH based real-time liquid simulation Particle based
12
Fluid Models Grid-based (Eulerian) d is density
Particle-based (Lagrangian) Hybrid Animate the particles “Collect” particles to compute density
13
Navier-Stokes Equation
Momentum equation Incompressibility ut = k2u –(u)u – p + f Change in velocity Diffusion/ Viscosity Advection Pressure Body Forces u: the velocity field u=0 k: kinematic viscosity
14
Diffusion/Viscosity Force
Limit shear movement of particles in the liquid The momentum between the neighbour particles are exchanged Pp Ppn
15
Adhesion Force Attract 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
16
Advection Force Velocity grid
17
Pressure force Pressure figure from Huamin Wang’s 3541 slides
18
Pressure force
19
Friction Force Dampen movement of particles in contact with objects in the environment Scale down the velocity by a constant value
20
Rendering particles Figure from
21
Heightfield mesh particle collection
Step 1. Zero out all u[i,j] Step 2. For each u[i,j], determine which particles are closet to it (bounding box collision test) Alternative Step 2. For each particle, determine which (i,j) it is closest to (translate position half a cell, then floor it)
22
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
23
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: Source code:
24
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)
25
Additional Slides
26
Heightfield mesh creation and cell iteration
Covered earlier with terrains
27
Heightfield or Heightmap terrain data
2D greyscale image Surface in 3D space Images from
28
Heightfield mesh creation and cell iteration
u[x,y] ; dimensions n by n
29
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]
30
Heightfield mesh creation and cell iteration
Inner loop iterates over i, the x coordinate Last quad: i=5 (i = n-1)
31
Heightfield mesh creation and cell iteration
Outer loop iterates over j, the y coordinate Last row: j=5 (j = n-1)
32
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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.