0% found this document useful (0 votes)
21 views

Water S

The document discusses different approaches for real-time water simulation, including 2D and 3D techniques. It covers grid-based methods like using the fast Fourier transform and solving shallow water equations, as well as particle-based approaches like wave particles and SPH shallow water simulation. The document provides examples and compares the pros and cons of each approach.

Uploaded by

Valentino
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Water S

The document discusses different approaches for real-time water simulation, including 2D and 3D techniques. It covers grid-based methods like using the fast Fourier transform and solving shallow water equations, as well as particle-based approaches like wave particles and SPH shallow water simulation. The document provides examples and compares the pros and cons of each approach.

Uploaded by

Valentino
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 93

1

Realtime Water Simulation on GPU

Nuttapong Chentanez
NVIDIA Research

2
3

Overview
• Approaches to realtime water simulation

• Hybrid shallow water solver + particles

• Hybrid 3D tall cell water solver + particles

• Future

3
4

Realtime Water Simulation

“2D” “3D”

4
“2D” Simulations
• Water represented by height above an
underlying terrain

5
6

“2D” Simulations
• Grid
NVIDIA DirectX 11, Island Demo Hilko et al. 09 Brodtkorb A. R. et al. 11,

FFT Wave sim Shallow water sim


Pipe sim

• Particle

Yuksel et. al. 07 Solenthaler et al. 11

Wave Particle Shallow water SPH

6
7

“2D” grid
• Water depth (and terrain
Z

height) stored in 2D array

• Water depth is updated in


each time step

7
8

FFT
• Fast Fourier Transform (FFT)
• Represent waves as sum of sinusoids
• Wave length, speed, amplitude from
statistical models
• Update height and derivatives in
frequency domain
• Use iFFT to transform back to spatial
domain for rendering

8
9

FFT

NVIDIA DirectX 11, Island Demo

9
10

FFT
• Pros
• Fast
• Great results for ocean wave, open water

• Cons
• No interaction with objects
• No boundary

10
11

Wave equation / Pipe model


• Wave equation
• Assumptions: Water surface is a height field,
velocity constant vertically, water is shallow,
pressure gradient is vertical, ignore non-linear
terms
• Discretize temporally and spatially
• Result in water height stored in 2D array +
update rules

11
12

Wave equation / Pipe model

Hilko et al. 09, “Real-Time Open Water Scenes with Interacting Objects”

12
13

Wave equation / Pipe model


• Pipe model
• Water heights stored in 2D array
• Neighbors are connected by pipe
• Flow rate in pipes updated by heights
• Heights changed by flow rate

13
14

Wave equation / Pipe model

Stava et al. 08, “Interactive Terrain Modeling Using Hydraulic Erosion”

14
15

Wave equation / Pipe model


• Pros
• Still fast
• Interaction with objects
• Boundary

• Cons
• No vortices
• No large flow
• Not unconditionally stable

15
16

Shallow water equation


• Assumptions: Water surface is a height field,
velocity is constant vertically, water is shallow,
pressure gradient is vertical, with non-linear term
• Discretize temporally and spatially
• Result in water height + velocity stored in 2D
array + update rules

16
17

Shallow water equation

Brodtkorb A. R. et al. 11, “Efficient Shallow Water Simulations on GPUs: Implementation, Visualization, Verification, and Validation”

17
18

Shallow water equation


• Pros
• Still fast
• Interaction with objects
• Boundary
• Vortices

• Cons
• Not unconditionally stable
• No splash, foam, spray

18
19

Wave Particles
• Particle based wave simulation
• Each particle stores a waveform
• Particles form wave front

Yuksel et. al. 07, “Wave Particles”

• Either bounce off or leave domain boundary

19
20

Wave Particles

Yuksel et. al. 07, “Wave Particles”

20
21

Wave Particles
• Pros
• Interaction with objects
• Open boundary is easy
• Unconditionally stable

• Cons
• Still require grid for rendering
• No vortices
• No large flow

21
22

SPH Shallow Water Simulation


• Use Smoothed Particles Hydrodynamics (SPH) to solve
shallow water equation
• Particles store mass and velocity
• Kernels are centered around particles

SPHERIC - SPH European Research Interest Community

• Volume computed by summing kernel values


• Density = Mass / Volume interpreted as height

22
23

SPH Shallow Water Simulation

Solenthaler et al. 11, “SPH Based Shallow Water Simulation”

23
24

SPH Shallow Water Simulation


• Pros
• Interaction with objects
• Open boundary is easy
• Vortices and Flow

• Cons
• Still require grid for rendering
• Not unconditionally stable
• Still no 3D effect!

24
25

“2D” Simulations
• Generally fast
• Interaction with solids
• Used in many games NVIDIA DirectX 11, Island Demo Hilko et al. Brodtkorb A. R. et al. 11,
FFT Wave sim Shallow water sim
Pipe sim

• But no 3D effects
• Can get away with Yuksel et. al.
Wave Particle
Solenthaler et al. 11
Shallow water SPH

good procedural
approaches!

25
26

“3D” Simulations
• Grid

Long B. and Reinhard E. Keenan C. et al. 2007

Discrete Sine/Cosine Regular Grid


Transform

• Particles

NVIDIA GF100 Fluid Demo NVIDIA PhysX Fluid Demo

SPH

26
27

3D grid
• Water states stored in 3D array
• Velocity
• Distance to surface
• Density
• etc.

• States are updated in each time step

27
28

Discrete Sine/Cosine Transform


• Use cosine and sine transform
• Instead of FFT
• To be able to enforce boundary condition

• Do physics in frequency domain

• Transform back to spatial domain

28
29

Discrete Sine/Cosine Transform

Long B. and Reinhard E. 09 ,”Real-Time Fluid Simulation Using Sine/Cosine Transforms”

29
30

Discrete Sine/Cosine Transform


• Pros
• Relatively fast
• Unconditionally stable

• Cons
• No interaction with object
• Box shape domain
• No small scale details for coarse grid

30
31

Regular grid
• Commonly used in offline production simulation
• Store water states in dense 3D grid
• Solve fluid dynamics PDE by discretizing spatially
and temporally
• States in the next time step determined by state
in the current time step and external forces
• “Brute Force”

31
32

Regular Grid

Keenan C. et al. 2007, “Real Time Simulation and Rendering of 3D Fluids”

32
33

Regular Grid
• Pros
• Good result
• Unconditionally stable

• Cons
• Box shape domain
• Very computationally intensive
• Mass loss
• No small scale details for coarse grid

33
34

SPH Simulation
• Use Smoothed Particles Hydrodynamics (SPH) to solve
fluid dynamic PDE
• Particles store mass, velocity,
• Kernels are centered around particles

Mueller et al. 03, “Particle-Based Fluid Simulation for Interactive Applications”

• Reconstruct surface from particle or


render particles directly

34
35

SPH Simulation

NVIDIA PhysX Fluid Demo

35
36

SPH Simulation

NVIDIA GF100 Fluid Demo

36
37

SPH Simulation
• Pros
• Arbitrary domain
• Interaction with object
• No mass loss

• Cons
• Noisy surface
• Not unconditionally stable

37
38

“3D” Simulations
• At high resolution,
produce great results
• Widely used in
movie industry
Long B. Keenan C.

Discrete Sine/Cosine Regular Grid


Transform

• Can’t afford to do
large scene with small NVIDIA GF100 Fluid NVIDIA PhysX Fluid

scale details SPH

26

38
39

Overview
• Approaches to realtime water simulation

• Hybrid shallow water solver + particles

• Hybrid 3D tall cell water solver + particles

• Future

39
40

Shallow water equation

• Missing
• Splashes
• Sprays
• Small Waves
• Foams

• Use particles!

Brodtkorb A. R. et al. 11, “Efficient Shallow Water Simulations on GPUs: Implementation, Visualization, Verification, and Validation”

40
41

Shallow Water Solver + Particles

• Large bodies of water


• Pond, River, Beach, Open Ocean

• Small scale details


• Splashes, Sprays, Small Waves, Foams

41
42

Shallow Water Solver + Particles

Chentanez N. and Mueller M. 2010, “Real-time Simulation of Large Bodies of Water with Small Scale Details”

42
43

Shallow Water Equations


• Simplify from 3D Fluid Equation to 2D
• Water depth, h
• 2D velocity, v
• Terrain height, H
Z

• Discretized with staggered grid


• Cell center :
• Store h and H
• X-Face and Z-Face :
• x and z component of v X

43
44

Particles Simulation
• Particles sources
• Waterfalls
• Terrain height discontinuity,
create spray and splash

• Breaking waves
• When wave about to overturn,
create spray and splash

44
45

Particles Simulation
• Particles sources
• Falling splash
• Create spray and foam

• Solid interaction
• Create spray and splash

45
46

Waterfall
• We treat a face as a waterfall face if
• Terrain height change is greater than a
threshold and
• Water height in the lower cell has not yet
reached the terrain height in the higher cell

46
47

Waterfall
• Particles generation

• Sample uniformly within red dotted box


• Total mass should be the same as mass flow
across the face
• Velocity found by interpolation
• Jitter initial position and velocity

47
48

Waterfall

48
49

Adding small scale waves


• Simulation cannot resolve waves with wave length
• Decreasing may not be an option
• Still want small waves with the following properties
• Advected with the velocity field
• Not distorted excessively over time
• Disappear if being stretched too much
• Cheap to compute

49
50

Adding small scale waves


• Algorithm
• Generate texture using FFT simulation

• Advect 3 set of texture coordinates


• Fetch texture and blend to get displacement map
• Regenerate after some time

50
51

Adding small scale waves


• So far, waves will never disappear
• Wave persist even when being stretched a lot
• Can have lava-like look
• Need to suppress in region with too much stretch

Without suppressant With suppressant

51
52

Adding small scale waves


• Measure of deformation
• Use maximum eigenvalue of the Green Strain of the texture
coordinates
• Modulate the final displacement
• With an exponential decay

Without suppressant With suppressant

52
53

Adding small scale waves

53
54

More results

54
55

More results

55
56

Overview
• Approaches to realtime water simulation

• Hybrid shallow water solver + particles

• Hybrid 3D tall cell water solver + particles

• Future

56
57

Grid based 3D water simulation


• Small domain

• Computation increase
with volume of water

• Also want small scale


details
• Splash Keenan C. et al. 2007, “Real Time Simulation and Rendering of 3D Fluids”

• Foam
• Spray

57
58

3D Tall Cell Water Solver + Particles

Chentanez N. and Mueller M. 2011, “Real-Time Eulerian Water Simulation Using a Restricted Tall Cell Grid”

58
59

3D Tall Cell Water Solver + Particles

59
60

3D Tall Cell Water Solver


• States of water
• u - Velocity field
• ϕ - Level Set (Signed distance function)
• Positive inside water
• Negative outside water
• Zero on surface

• Store states on grid points


• Interpolate to get value everywhere
http://en.wikipedia.org/wiki/File:Signed_distance2.png

• Simulation == Rules to update these states

60
61

Discretization
• Tall cell grid
• Each column consist of
• Constant number of regular cells
• One tall cell
• Terrain

61
62

Discretization
∆x
• Tall cell grid
• Heights are multiple of ∆x
• Physical quantities u, ϕ 4∆x
• At cell center for regular cells
• At top and bottom of tall cells
6∆x

62
63

Discretization
• Tall cell grid
• Quantity q at world position(x∆x, y∆x, z∆x)
denoted by q(x, y, z)
• Hide tall cell structure of the grid
“Air value”

Direct lookup

Linear interpolation

“Terrain value”

63
64

Time integration
Extrapolate u to air

64
65

Time integration
Extrapolate u to air

65
66

Time integration
Extrapolate u to air

66
67

Time integration
Extrapolate u to air

67
68

Time integration
Extrapolate u to air

Make ϕ a signed distance function

Because ϕ will no longer be a signed


distance function, as we update the states

68
69

Time integration
Extrapolate u to air

Make ϕ a signed distance function

69
70

Time integration
Extrapolate u to air

Make ϕ a signed distance function

70
71

Time integration
Extrapolate u to air

Make ϕ a signed distance function

71
72

Time integration
Extrapolate u to air

Make ϕ a signed distance function

Move u and ϕ along velocity field u

72
73

Time integration
Extrapolate u to air

Make ϕ a signed distance function

Move u and ϕ along velocity field u

73
74

Time integration
Extrapolate u to air

Make ϕ a signed distance function

Move u and ϕ along velocity field u

Adjust tall cell heights

74
75

Time integration
Extrapolate u to air

Make ϕ a signed distance function

Move u and ϕ along velocity field u

Adjust tall cell heights

75
76

Time integration
Extrapolate u to air

Make ϕ a signed distance function

Move u and ϕ along velocity field u

Adjust tall cell heights

Make u divergence free


The most difficult and
time consuming step

76
77

Particles
• Spray
• Seed particles inside grid cells whose ϕ are positive but small
(near water surface)
• Move them along velocity field u
• After we update ϕ, for each particle
• Check if ϕ at the current location is negative (outside water)
• If so, generate spray particles
• otherwise, ignore
• Move ballistically

• Foam
• Generate when spray particle falls into water
• Move with u, projected to water surface

77
78

More result

Chentanez N. and Mueller M. 2011, “Real-Time Eulerian Water Simulation Using a Restricted Tall Cell Grid”

78
79

Future
• Hybrid 3D + 2D + Particles + Procedural?
• 3D + Particles near camera
• 2D + Particles further away
• 2D even further
• Procedural far from camera

79
80

Future

Thuerey N. et, al, 2006 “Animation of Open water Phenomena with coupled Shallow Water and Free Surface Simulation”

80
81

Future

Thuerey N. et, al, 2006 “Animation of Open water Phenomena with coupled Shallow Water and Free Surface Simulation”

81
82

Future
• Hybrid 3D + 2D + Particles + Procedural?
• 3D + Particles near camera
• 2D + Particles further away
• 2D even further
• Procedural far from camera

• Dynamic LOD
• Best quality within budget

82
83

Q&A

Thank you very much!

83
84

References
• Tessendof SIGGRAPH Course 99, “Simulating Ocean Wave”
• Enright et al. SIGGRAPH 02, “Animation and Rendering of Complex Water Surfaces”
• Mueller et al. SCA 03, “Particle-Based Fluid Simulation for Interactive Applications”
• Thuerey N. et, al, SCA 06 “Animation of Open water Phenomena with coupled Shallow Water and Free
Surface Simulation”
• Keenan C. et al. GPU Gems III 07, “Real Time Simulation and Rendering of 3D Fluids”
• Yuksel et. al. SIGGRAPH 07, “Wave Particles”
• Stava et al. SCA 08, “Interactive Terrain Modeling Using Hydraulic Erosion”
• Hilko et al. Eurographics workshop on natural phenomena 09, “Real-Time Open Water Scenes with
Interacting Objects”
• Long B. and Reinhard E. I3D 09 ,”Real-Time Fluid Simulation Using Sine/Cosine Transforms”
• Chentanez N. and Mueller M. SCA 10, “Real-time Simulation of Large Bodies of Water with Small
Scale Details”
• Brodtkorb A. R. et al. Computer & Fluid 11, “Efficient Shallow Water Simulations on GPUs:
Implementation, Visualization, Verification, and Validation”
• Chentanez N. and Mueller M. SIGGRAPH 11, “Real-Time Eulerian Water Simulation Using a
Restricted Tall Cell Grid

84
85

Math

∂u 2
= −u · ∇u − ∇p + µ∇ u + f
∂t
∇·u=0

85
86

3D Tall Cell Water Solver


• Solve Inviscid Euler Equations

∂u f ∇p
= −(u · ∇)u + −
∂t ρ ρ

• Subject to ∇·u=0

• Inside region φ < 0


∂φ
= −u · ∇φ
∂t

86
87

3D Tall Cell Water Solver


• Solve Inviscid Euler Equations
Change in velocity
∂u f ∇p
= −(u · ∇)u + −
∂t ρ ρ

• Subject to ∇·u=0

• Inside region φ < 0


∂φ
= −u · ∇φ
∂t

87
88

3D Tall Cell Water Solver


• Solve Inviscid Euler Equations
Velocity moves itself
Change in velocity
∂u f ∇p
= −(u · ∇)u + −
∂t ρ ρ

• Subject to ∇·u=0

• Inside region φ < 0


∂φ
= −u · ∇φ
∂t

88
89

3D Tall Cell Water Solver


• Solve Inviscid Euler Equations
Velocity moves itself External force such as gravity
Change in velocity
∂u f ∇p
= −(u · ∇)u + −
∂t ρ ρ

• Subject to ∇·u=0

• Inside region φ < 0


∂φ
= −u · ∇φ
∂t

89
90

3D Tall Cell Water Solver


• Solve Inviscid Euler Equations
Velocity moves itself External force such as gravity
Change in velocity
∂u f ∇p
= −(u · ∇)u + − Pressure gradient
∂t ρ ρ

• Subject to ∇·u=0

• Inside region φ < 0


∂φ
= −u · ∇φ
∂t

90
91

3D Tall Cell Water Solver


• Solve Inviscid Euler Equations
Velocity moves itself External force such as gravity
Change in velocity
∂u f ∇p
= −(u · ∇)u + − Pressure gradient
∂t ρ ρ

• Subject to ∇·u=0 Incompressibility


- What come in must go out

• Inside region φ < 0


∂φ
= −u · ∇φ
∂t

91
92

3D Tall Cell Water Solver


• Solve Inviscid Euler Equations
Velocity moves itself External force such as gravity
Change in velocity
∂u f ∇p
= −(u · ∇)u + − Pressure gradient
∂t ρ ρ

• Subject to ∇·u=0 Incompressibility


- What come in must go out

• Inside region φ < 0 Implicit function that represent water body

∂φ
= −u · ∇φ
∂t

92
93

3D Tall Cell Water Solver


• Solve Inviscid Euler Equations
Velocity moves itself External force such as gravity
Change in velocity
∂u f ∇p
= −(u · ∇)u + − Pressure gradient
∂t ρ ρ

• Subject to ∇·u=0 Incompressibility


- What come in must go out

• Inside region φ < 0 Implicit function that represent water body

∂φ Implicit function moved


= −u · ∇φ by water velocity

∂t

93

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy