Fast Hydraulic Erosion Simulation and Visualization on GPU
Fast Hydraulic Erosion Simulation and Visualization on GPU
Xing Mei1 Philippe Decaudin2 Bao-Gang Hu1
1. CASIA (China) 2. INRIA (France)
Pacific Graphics’07
2
Outline
■ Introduction■ Hydraulic Erosion■ Existing Methods
■ Hydraulic Erosion on GPU■ Method Overview■ Simulation Steps■ Multi-pass Implementation on GPU
■ Results
■ Conclusion & Future Work
3
Introduction- Hydraulic Erosion
■ ProcessWater flow takes away (dissolves) the soil
and relocates (deposits) it somewhere else
■ EffectChanges terrain appearance
Creates interesting geo-morphological structures
Gullies Eroded landscape on Maui Island
4
■ Enhance realism
■ A useful complement to fluid simulation
Topographical changes affect the water flow
[Chiba’98]
Introduction- Erosion Simulation (Why?)
[Beneš’06]
5
■ Procedural [Kelly’88, Prusinkiewicz’93] Ad hoc rules with fractal terrain generation Fast and efficient; No water flow involved
Limited control on the erosion results
■ Physically Based Simulation
[Musgrave’89, Chiba’98, Neidhold’05…] Simulation on already-existing terrains Controllable Erosion Process, but computationally expensive
4 fps on 256x256 grids [Neidhold’05]
5 fps on 300x300 grids [Beneš’07]
Limited for interactive applications
Introduction- Existing Methods
6
■ A novel hydraulic erosion simulation method
Effectiveproduces the important features in the erosion process Gullies, water catchments, deposited sediment…
EfficientWell mapped to GPU
Interactive frame rates for large size terrains
Erosion on GPU- Motivation
7
■ 5 steps in one cycle of the simulation
Terrain
water
Rainfall & River Source Water Movement
Erosion
Deposition
Sediment Transportation
DepositedSediment
Catchment
Evaporation
(1) Water Increment(2) Water Movement (flow simulation)
(3) Erosion or Deposition(4) Sediment Transportation
(5) Evaporation
Erosion on GPU- Method Overview
Water Height -
8
■ Layers of 2D arrays
■ Each step should update the cell data in parallel
No scattering operations on the data array involved
cell
Erosion on GPU- Data Structure
Arrays
Terrain Height -
d
b
Suspended Sediment s Outflow flux
Velocity
),,,( BTRL fffff
),( yx VVV
cell
9
■ Two kinds of sources
River sources – fixed location, radius, intensity
Raindrops – random location, radius, intensity
Erosion on GPU(1) Water Increment
tKd r Water increment
10
■ Possible Models? GPU friendly
Grid-based methods > Lagrangian methods Efficient
Shallow water model > 3D Navier-Stokes Equation Suitable for Erosion-Deposition
Velocity field is necessary
■ Previous models on shallow water framework Simplified Newtonian physics model [Neidhold’05]
hard to parallelize Kass&Miller’s implicit method [Beneš’07]
many iterations over the grid, not efficient for large size terrain
■ Our choiceThe Virtual Pipe model [O’Brien’95]
Erosion on GPU(2) Water Movement (Flow Simulation)
11
■ Virtual Pipe Model■ Water is exchanged between cells through virtual pipes
■ How much water exchanged through each pipe?
Flux – accelerated by the hydrostatic pressure difference
P0
P0
Cell
Erosion on GPU(2) Water Movement (Flow Simulation)
LF
BF
RF
TF
P1 P2
Two-Step Process1.Update Flux2.Update Water Height
A simple explicit method
12
■ Two “problems” about the original model
Erosion on GPU(2) Water Movement (Flow Simulation)
Cell LF
BF
RF
TF 1. Staggered gridwater height (d) – cell centerflux (F) – cell border
2. Non-negative water updateA scaling back processscattering operations are involved
Both are not GPU-friendly
13
■ Adaptation to the original model ■ the outflow flux for each cell
■ Flux (F) and outflow flux (f)
■ Water height update (d)
- send away the outflow flux
- collect inflow flux from neighbours
Outflow flux
Cell(x,y)
Inflow flux
Erosion on GPU(2) Water Movement (Flow Simulation)
Lf
Bf
Rf
Tf0,,,
),,,(
BTRL
BTRL
ffff
fffff
)( outin fftd
),1(),( yxfyxfF RLL
LF
14
■ Non-negative water update
Erosion on GPU(2) Water Movement (Flow Simulation)
Outflow flux
Cell
Inflow flux
Lf
Bf
Rf
Tf
dftK out
)( outin fftd
0 outin ftftddd
omitted, strengthened condition inft
0 outftd
a scaling factor K limiting the outflow flux
15
■ 3-step process Update outflow flux Update water height Update (horizontal) velocity field
From Flux (f) to Velocity (V)
■ No-Slip Boundaries
set outflow flux to 0 for boundary cells
■ Limitation for time step ]1,0[,),max(
y
V
x
Vt
yx
Erosion on GPU(2) Water Movement (Flow Simulation)
fdAtV xx Cell
X
Boundarycell
0Lf
16
Sediment transport capacity
Current suspended sediment
How to compute for each cell ?
We adapt a classic model from soil science [Julien’85]
CS
S
CS CS ErosionDeposition
C
Erosion on GPU(3) Erosion & Deposition
)sin( VKC c
17
■ Suspended sediment (S) is advected by the velocity field
■ Many GPU-friendly schemes to solve the equation Stable semi-Lagrangian method [Stam’99]
Upwind differencing scheme
More mass-conservative methods such as BFECC [Kim’05, Selle’07]
0
SVt
S
),(),( tvytuxSyxS ttt
Erosion on GPU(4) Sediment Transportation
(advection dominated, no diffusion considered)
18
■ General computation framework on GPU [Harris’03, Owens’07]To update a 2D array in parallel:
■ Multi-pass process
Initialization
3
2
1
),(
),,,(
,,
TVVV
Tfffff
Tsdb
yx
BTRL
(1) Water Increment
(2) Flow Simulation
(3) Erosion-Deposition
(4) Sediment transport
(5) Evaporation
Outflow
Water Height
Velocity
Simulation
Visualization
VS: Vertex TexturePS: Phong Lighting
Erosion on GPU- Multi-pass Implementation on GPU
pack datainto textures
draw a screen-aligned quad
update texture in pixel shader
19
Results
■ Platform: Pentium IV 2.4GHz + 2Gb RAM + Nvidia 8800 GTX
512x512 grids for video demos
water
suspended sediment in the flow
deposited sediment
“PG scene” in the rainVideo
20
Results
■ Deposited sediment in a basin
The bottom of the basin is flattened by the deposited sediment
Video
24
Results
■ Performance results for the final example at different grid size
403
186
59
16 40
50
100
150
200
250
300
350
400
450
256x256 512x512 1024x1024 2048x2048 4096x4096
Cycles per second
Cycles per second
Interactive frame rates for terrain up to 1024x1024!
1 cycle = 1 simulation + 1 visualization
25
Results
■ ST, VT, CT at different grid size
2.48 5.3816.95
62.5
248.47
1.28 2.9710.31
40
155.89
1.29 2.38 6.6522.88
91.22
0
50
100
150
200
250
300
256x256 512x512 1024x1024 2048x2048 4096x4096
ST(ms)
VT(ms)
CT(ms)
ST : Simulation TimeVT : Visualization TimeCT : Cycle Time = ST + VT
1. ST, VT, CT scales well with grid size ~ linear with # of cells
2. VT takes more time for large size terrain
3. Further Improvements
26
Conclusion & Future Work■ A novel simulation method for hydraulic erosion
■ Effective – proper model selection and adaptation for each step
Produces dynamic erosion process and realistic results■ Efficient - well designed for complete GPU implementation
Interactive frame rates for large size terrain
■ Future work■ Further improvements on models:
Fluid solver - Limitation for time step
Erosion Model - Little erosion on flat terrain■ Extension to non-height-field scene
(general 3D objects, structures with caves)■ More erosion process – thermal weathering, wind erosion…
27
Thanks!
More info on
http://evasion.imag.fr/Publications/2007/MDH07/