Procedural Clouds (special release with dots!)
Presentation will cover Clouds! In meatspace (real life) Simulating clouds Rendering clouds Cellular Automata (some) physics
Introducing Clouds Clouds are volumetric :-( dynamic :'-( => problematic
Volumetric Rendering Similar to hair c.f. Erik's presentation Many techniques will mention some later
Simulation Clouds are fluids Navier Stokes Turbulence / Chaos Clouds are 3D
Clouds in current games... Often static and flat painted by artists or photos may be lit dynamically background scenery Some exceptions (Flight Simulators) e.g. Microsoft Flight Simulator
Microsoft Flight Simulator Prebuilt by artist static Bunch of sprites not really volumetric no internal scattering Looks OK though
Clouds in Real Life(tm)
Types of Clouds Cirrocumulus Cirrus cloud Cirrostratus Altostratus Nimbostratus Cumulinimbus and so on...
Types of Clouds Focus on Cumulus clouds
Cloud Formation How are clouds formed in real life? bubbles of heated air start to rise bubbles enter lower pressure regions and expand expansion cools bubbles => relative humidity inside increases phase transition => water vapor turns into droplets We see these droplets as clouds!
Simulation of cloud formation Short video from Mark Harris dissertation Simulates rising vapor using simplified fluid dynamics
Cloud Formation, part II Actually, mechanics not yet undestood how do droplets grow? why do droplets turn into drops (=rain)? Ongoing research e.g. here at Chalmers involves lots of turbolent flows & chaos
Cloud Dynamics Involves Navier-Stokes ρ Dv/Dt = - p + T + f Differential Equations turbulent / chaotic system high Lyapunov coefficient Dedicated field for this: => Computational Fluid Dynamics
Cloud Dynamics Possible to use Navier-Stokes see e.g. Mark Harris dissertation We'll take a different approach Cellular Automata based on a paper by Dobashi et al. Actually used in fluid dynamics sometimes Lattice Boltzmann models Lattice-Gas Cellular Automata
Clouds on a CA Not accurate we don't want to predict the weather! just want to get some nice images... Simple to simulate as you will see soon
Cellular Automata
What is a Cellular Automaton? Simulation on a discreet grid with discreet time steps Each cell has a finite number of states Simple rules describe updates rules only depend on immediate neighbourhood
CA - Examples Conway's Game of Life one of the first CA:s also on title slide 4 simple rules incredible complexity See e.g. Wikipedia
CA Examples - 1D Simplest CA:s Wolfram notation Rule 110 on left Support universality at least some do
Why Cellular Automata Exhibit chaotic behaviour pseudo-random results complex structures => nicer clouds Local rules easy to parallelize computations => good match for GPU (CUDA,...)
Nagel's Method Descibes cloud formation Three boolean variables humijk humidity in cell (i,j,k) actijk activation function cldijk clouds Each variable is one bit
Nagel's Method Rules: humijk(t+1) = humijk(t) &&!actijk(t) cldijk(t+1) = cldijk(t) actijk(t) actijk(t+1) =!actijk(t) && humijk(t) && f(i,j,k) where f(i,jk) depends on the neighbourhood
Nagel's Method f(i,j,k) = acti+1jk(t) acti-1jk(t) acti+2jk(t) acti-2jk(t) actij+1k(t) actij-1k(t) actij+2k(t) actij-2k(t) actijk+1(t) actijk-1(t) actij-2k(t) Asymmetric causes clouds to grow horizontally and upwards can be modified
Nagel's Method, Summary Three variables, two states each Updates depend on state of neighbours our choice causes clouds to boundary condition: grow horizontally and upwards variables are zero outside of the grid Only describes cloud formation!
Extinction Nagel's Method only creates clouds cldijk will never reset to zero! Add extinction probability, p ext may vary depending on location may vary with time Each update check if rand01() if so, reset cldijk < pext
Regeneration Similar problem humijk and actijk will never reset to one Similar solution: add probabilities pact and phum => randomly reset humijk and actijk
Wind Clouds still stay in one place Simulate wind by shifting cells e.g. each update shift cells left Or more formally cldijk(t) = cldi-vjk(t) similarily for other variables v might depend on position
Controlling The Weather We can control the clouds by changing the probabilities (pact, phum and pext) depending on location depending on time Simulate rising pockets of air by elipsoids that move through the grid pact and phum non-zero inside elipsoid pact and phum zero outside elipsoid
Summary, so far We have an algorithm to simulate clouds suitable for GPU computation relatively simple, no horrible math cumulus clouds only Let look at some screenshots...
Screenshot!
Cloud formation
Cloud formation
Cloud formation
Cloud formation
But it's not pretty! Just simulating the clouds Each cell containing clouds drawn as a point sprite with some blending We lack lighting proper Z-order sorting for blending scattering inside the cloud etc.
Also... it's not very fast currently simulated on a CPU maybe 10 FPS (quad core2), 25 FPS (core i7) 98.5% of time spent on updating clouds GPU just twiddles thumbs during that time So it would be interesting to use e.g. CUDA (if one had time to implement that) should map well to GPUs
Screenshots, part II Screenshots from the original paper uses more fancy rendering Implements effects like scattering crepuscular rays ( god rays ) And some atmospheric effects Clouds cast shadows Paper did this in 2000 at interactive frame rates
Screenshots (again)
Screenshots (again)
Conclusion Summary (Key Stuff) Simulate Clouds Cellular Automata Nagel's Method Not predictive Weather Control! References: Y. Dobashi et al, A simple, Efficient Method for Realistic Animation of Clouds, SIGGRAPH2000 K. Nagel, Self-Organizing Criticality in Cloud Formation, Physica A 1992 M. Harris et al, Simulation of Cloud Dynamics on Graphics Hardware, Proc. of Graphics Hardware, 2003...