CS-C3100 Computer Graphics Fall 2017 Jaakko Lehtinen Markus Kettunen Dynamical Simulation 1: Particle Systems and ODEs 1 Futuremark Corp., used with permission
Types of Animation Keyframing Procedural Physically-based Particle Systems (today) CERN Smoke, water, fire, sparks, etc. Usually heuristic as opposed to simulation, but not always Mass-Spring Models (Cloth) Thursday Continuum Mechanics (fluids, etc.), finite elements Not in this class Rigid body simulation Not in this class 2
Types of Animation: Physically-Based Assign physical properties to objects Masses, forces, etc. Also procedural forces (like wind) Simulate physics by solving equations of motion Rigid bodies, fluids, plastic deformation, etc. Realistic but difficult to control v 0 m g 3
Control 4
Directable Simulation Relatively new field that aims to produce simulations that obey user-specified constraints Add as-small-as-possible fictitious forces to simulation to nudge it towards artist/td needs Lots of cool stuff! See e.g. http://www.cs.huji.ac.il/labs/cglab/projects/ tdsmoke/ 5
Types of dynamics Point 6
Types of dynamics Point Rigid body Animation by Mark Carlson 7
Types of dynamics Point Rigid body Deformable body (include clothes, fluids, smoke, etc.) Mark Carlson 8
Today We Focus on Point Dynamics Lots of points! Particle systems Borderline between procedural and physicallybased 9
Particle Systems Overview Emitters generate tons of particles Sprinkler, waterfall, chimney, gun muzzle, exhaust pipe, etc. Image Jeff Lander http://www.particlesystems.org/ 10
Particle Systems Overview Emitters generate tons of particles Describe the external forces with a force field E.g., gravity, wind Image Jeff Lander http://www.particlesystems.org/ 11
Particle Systems Overview Emitters generate tons of particles Describe the external forces with a force field Integrate the laws of mechanics (ODEs) Makes the particles move Image Jeff Lander http://www.particlesystems.org/ 12
Particle Systems Overview Emitters generate tons of particles Describe the external forces with a force field Integrate the laws of mechanics (ODEs) In the simplest case, each particle is independent Image Jeff Lander http://www.particlesystems.org/ 13
Particle Systems Overview Emitters generate tons of particles Describe the external forces with a force field Integrate the laws of mechanics (ODEs) In the simplest case, each particle is independent If there is enough randomness (in particular at the emitter) you get nice effects sand, dust, smoke, sparks, flame, water, Image Jeff Lander http://www.particlesystems.org/ 14
Demo Simple waterfall Each particle affected by gravity Simple obstacle geometry (spheres) Braindead rendering (screen-aligned transparent quads) 15
Demo Simple waterfall Each particle affected by gravity Simple obstacle geometry (spheres) Braindead rendering (screen-aligned transparent quads) Could add animated textures and some sounds Note: No interaction between particles. It s not a fluid simulation! But then again, it took under an hour to code up. 16
Real-Time Particles Demo 3DMark03 by Futuremark Corp. Explosions, vapor trails, muzzle flashes are particles Futuremark Corp., used with permission 17
Generalizations Next Lecture Mass-spring and deformable surface dynamics surface represented as a set of points forces between neighbors keep the surface coherent Image Witkin & Baraff Image Michael Kass 18
Cloth Video Selle. A, Su, J., Irving, G. and Fedkiw, R., "Robust High- Resolution Cloth Using Parallelism, History-Based Collisions, and Accurate Friction," IEEE TVCG 15, 339-350 (2009). 19
Generalizations Müller et al. 2005 It s not all hacks: Smoothed Particle Hydrodynamics (SPH) A family of real particle-based fluid simulation techniques. Fluid flow is described by the Navier-Stokes Equations, a nonlinear partial differential equation (PDE) SPH discretizes the fluid as small packets (particles!), and evaluates pressures and forces based on them. Jos Stam 20
SPH Example Predictive-Corrective Incompressible SPH. Barbara Solenthaler, Renato Pajarola. ACM Transactions on Graphics (SIGGRAPH), 2009 21
Meshless Techniques Most simulation techniques work on either regular grids or meshes constructed from triangles/tets PDEs defined on space are discretized on the grid. Regular 3D grid Irregular 2D grid Images: Wikipedia 22
Meshless Techniques Most simulation techniques work on either regular grids or meshes constructed from triangles/tets In contrast, so-called meshless methods do not require the underlying space to be discretized Instead, represent things using points (particles!) They can still be well-founded : SPH is an example. Another example: Point-Based Animation of Elastic, Plastic and Melting Objects (Müller, Keiser, Nealen, Pauly, Gross, Alexa, SCA 2004) Müller et al. 23
Can Model Everything using Particles! Unified Particle Physics for Real-Time Applications (NVIDIA) video 24
Take-Home Message Particle-based methods can range from pure heuristics (hacks that happen to look good) to real simulation Basics are the same: Things always boil down to integrating ODEs! Also in the case of grids/computational meshes Andrew Selle et al. 25
Questions? 26
What is a Particle System? Collection of many small simple pointlike things Described by their current state: position, velocity, age, color, etc. Particle motion influenced by external force fields and internal forces between particles Particles created by generators or emitters With some randomness Particles often have lifetimes Particles are often independent Treat as points for dynamics, but rendered as anything you want http://en.wikipedia.org/wiki/image:particle_emitter.jpg 27
Simple particle system: sprinkler PL: linked list of particle = empty; Image Jeff Lander 28
Simple particle system: sprinkler PL: linked list of particle = empty; spread=0.1;//how random the initial velocity is colorspread=0.1; //how random the colors are Image Jeff Lander 29
Simple particle system: sprinkler PL: linked list of particle = empty; spread=0.1;//how random the initial velocity is colorspread=0.1; //how random the colors are For each time step Image Jeff Lander 30
Simple particle system: sprinkler PL: linked list of particle = empty; spread=0.1;//how random the initial velocity is colorspread=0.1; //how random the colors are For each time step Kill particles that are too old Generate new particles p=new particle(); p->position=(0,0,0); p->velocity=(0,0,1)+spread*(rnd(), rnd(), rnd()); p.color=(0,0,1)+colorspread*(rnd(), rnd(),rnd()); PL->add(p); Image Jeff Lander 31
Simple particle system: sprinkler PL: linked list of particle = empty; spread=0.1;//how random the initial velocity is colorspread=0.1; //how random the colors are For each time step Kill particles that are too old Generate new particles: loop p=new particle(); p->position=(0,0,0); p->velocity=(0,0,1)+spread*(rnd(), rnd(), rnd()); p.color=(0,0,1)+colorspread*(rnd(), rnd(),rnd()); PL->add(p); For each particle p in PL p->position+=p->velocity*dt; //dt: time step p->velocity-=g*dt; //g: gravitation constant glcolor(p.color); glvertex(p.position); Image Jeff Lander 32
Simple particle system: sprinkler PL: linked list of particle = empty; spread=0.1;//how random the initial velocity is colorspread=0.1; //how random the colors are For each time step Kill particles that are too old Generate new particles: loop p=new particle(); p->position=(0,0,0); p->velocity=(0,0,1)+spread*(rnd(), rnd(), rnd()); p.color=(0,0,1)+colorspread*(rnd(), rnd(),rnd()); PL->add(p); For each particle p in PL p->position+=p->velocity*dt; //dt: time step p->velocity-=g*dt; //g: gravitation constant glcolor(p.color); glvertex(p.position); Image Jeff Lander 33
Corresponding Waterfall Demo Code 34
Where do particles come from? Created by generators or emitters Can be attached to objects in the model Given rate of creation: particles/second record t last of last particle created create n particles. update t last if n > 0 http://www.particlesystems.org/ Create with (random) distribution of initial x and v if creating n > 1 particles at once, spread out on path 35
Code from Waterfall Demo 36
Particle Controls In production tools, all these variables are timevarying and controllable by the user (artist) Emission rate, color, velocity distribution, direction spread, textures, etc. etc. All as a function of time! Example: ParticleFX (Max Payne Particle Editor) Custom editor software You can download it (for Windows) and easily create your own particle systems. Comes with examples! This is what we used for all the particles in the game 37
Emitter Controls Again, reuse splines! Controls from ParticleFX by Remedy Entertainment 38
Emitter Controls Again, reuse splines! Controls from ParticleFX by Remedy Entertainment 39
Particle Lifetimes Initialize particle age to 0 at emission Keep track of its age over simulation Use particle age to Remove particles from system when too old Change color or animate texture (flame, puff of smoke) Change transparency (old particles fade) Perhaps also remove particles that are offscreen Careful with this, it only works if the camera is static! 40
Rendering and Motion Blur Often not shaded (just emission, think sparks) But realistic non-emissive particles needs shadows, etc. Most often, particles don t contribute to the z-buffer, i.e., they do not fully occlude stuff that s behind Rendered with z testing on (particles get occluded by solid stuff) Draw a line for motion blur ( x, x+v dt ) Or an elongated quad with texture Metal Gear Solid by Konami 41
Rendering and Motion Blur Metal Gear Solid by Konami 42
Rendering and Motion Blur Often use texture maps (fire, clouds, smoke puffs) Called billboards or sprites Always parallel to image plane Futuremark Corp., used with permission 43
Image from Sameboat 44
Particle Systems Entirely on GPU (it s a link) 45
Questions? Next, dynamics: how the system evolves 46