Cornell CS 468Andrew Butts 1 Implementing Particle Systems CS 468 Spring 2004 Andrew Butts.

Slides:



Advertisements
Similar presentations
Optimizing Flocking Controllers using Gradient Descent
Advertisements

Ordinary Differential Equations
© University of Wisconsin, CS559 Spring 2004
Particle System Design. The Challenge Particle systems vary so much But want some code reuse Option 1: parameterization Option 2: inheritance Option 3:
1Notes. 2Heightfields  Especially good for terrain - just need a 2d array of heights (maybe stored as an image)  Displacement map from a plane  Split.
1Notes. 2 Building implicit surfaces  Simplest examples: a plane, a sphere  Can do unions and intersections with min and max  This works great for.
1Notes. 2 Triangle intersection  Many, many ways to do this  Most robust (and one of the fastest) is to do it based on determinants  For vectors a,b,c.
1Notes  Textbook: matchmove 6.7.2, B.9. 2 Match Move  For combining CG effects with real footage, need to match synthetic camera to real camera: “matchmove”
1Notes  Text:  Motion Blur A.3  Particle systems 4.5 (and 4.4.1, 6.6.2…)  Implicit Surfaces  Classic particle system papers  W. Reeves, “Particle.
MAT 594CM S10Fundamentals of Spatial ComputingAngus Forbes Week 2 : Dynamics & Numerical Methods Goal : To write a simple physics simulation Topics: Intro.
Particle Systems 1 Adapted from: E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012.
Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.
1cs533d-winter-2005 Notes  More optional reading on web for collision detection.
Particle Systems GPU Graphics. Sample Particle System Fire and SmokeWater.
1cs426-winter-2008 Notes  If you’re interested, read Bridson, Hourihan, Nordenstam, “Curl noise for procedural fluid flow”, SIGGRAPH ‘07.
Stable Cloth Animation By Matthew Fisher. Overview Choose Underlying Model Define Equations of State Integrate Equations of State –Deal With Explosions.
1cs426-winter-2008 Notes  Course project: Will be due at the end of the term You can do it in pairs Create an animation that combines an algorithm for.
1cs533d-term Notes  list Even if you’re just auditing!
Haptic Cloth Rendering 6th Dutch-Belgian Haptics Meeting TUDelft, 21 st June 2006 Lode Vanacken Expertise centre for Digital Media (EDM) Hasselt University.
Particle Systems Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University.
1Notes. 2 Time integration for particles  Back to the ODE problem, either  Accuracy, stability, and ease-of- implementation are main issues  Obviously.
1cs426-winter-2008 Notes. 2 Velocity fields  Velocity field could be a combination of pre-designed velocity elements E.g. explosions, vortices, …  Or.
UNC Chapel Hill M. C. Lin Review Particle Dynamics (see transparencies in class)
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Beyond Meshes Spring 2012.
Physically Based Animation and Modeling
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
1 Roller coaster Jernej Barbic, CSCI 480, USC The programming assignment involves creating a 3D roller coaster animation We must model the 3D curve describing.
Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Animation – A broad Brush
Erin Catto Blizzard Entertainment Numerical Integration.
CS559: Computer Graphics Lecture 38: Animation Li Zhang Spring 2008 Slides from Brian Curless at U of Washington.
CDS 301 Fall, 2009 Vector Visualization Chap. 6 October 7, 2009 Jie Zhang Copyright ©
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
CS 638, Fall 2001 Today Project Stage 0.5 Environment mapping Light Mapping.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Numerical Integration and Rigid Body Dynamics for Potential Field Planners David Johnson.
Maths & Technologies for Games Linear Dynamics Particle Based Physics CO3303 Week
Automotive Soiling Simulation Based On Massive Particle Tracing Stefan Röttger Martin Schulz Wolf Bartelheimer Thomas Ertl Visualization and Interactive.
CSC505 Particle Systems. CSC505 Object Representations So far we have represented (rendered) objects with –Lines –Polygons (triangles) –Curves These techniques.
Introduction to Procedural Methods, Particles Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, March.
Hierarchical Modeling
Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan.
Particle Systems (Motion Machines of 2D Objects with Textures) Matthew K. Bowles Advanced Computer Graphics Spring 2004.
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Particle Systems.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Physics for Games Spring 2012.
1 Visiblity: Culling and Clipping Computer Graphics COMP 770 (236) Spring 2009 January 21 & 26: 2009.
Introduction to Particle Simulations Daniel Playne.
Point Sprites Course Information CVG: Programming 4 My Name: Mark Walsh Website: Recommended.
Perpetual Visualization of Particle Motion and Fluid Flow Presented by Tsui Mei Chang.
Particle Systems. Applications Particle systems are broadly defined for: Explosion Cloth Fluid And more… It is integrated into many animation software,
CS274 Spring 01 Lecture 7 Copyright © Mark Meyer Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
More on Particles Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, March 24, 2004.
Game Technology Animation V Generate motion of objects using numerical simulation methods Physically Based Animation.
Advanced Games Development Game Physics CO2301 Games Development 1 Week 19.
Graphics for Games Particle Systems CO2301 Games Development 1 Week 23.
Computer Graphics Imaging Ying Zhu Georgia State University Lecture 29 Soft Bodies and Rigid Bodies.
Ctrl + Z Sucheta Bhatawadekar Sucheta Bhatawadekar Dan L'Hommedieu Dan L'Hommedieu John Scott John Scott Jonathan Perkins Jonathan Perkins Aaron Cardwell.
1 Particle Systems for Games Particle System 3D MIM, hyeon.
Particle Systems Ed Angel Professor Emeritus of Computer Science
© University of Wisconsin, CS559 Spring 2004
Lecture 4: Modeling Mechanical Systems
© University of Wisconsin, CS559 Fall 2004
Motion in Real and Virtual Worlds
CO1301: Games Concepts Lecture 22 Particle Systems
Particle Systems Ed Angel
Computer Animation Algorithms and Techniques
Computer Graphics Lecture 15.
CO Games Concepts Week 22 Particle systems
GPAT – Chapter 7 Physics.
Presentation transcript:

Cornell CS 468Andrew Butts 1 Implementing Particle Systems CS 468 Spring 2004 Andrew Butts

Cornell CS 468Andrew Butts 2 What’s going on? Just integrate the particle equations of motion. P’ = V V’ = A = F/m All the fun is in computing F… And in rendering!

Cornell CS 468Andrew Butts 3 Simulation Loop PA 4 Requires this loop: Initialize/Emit particles Run integrator (evaluate derivatives) Update particle states Render Repeat!

Cornell CS 468Andrew Butts 4 System states Every particle has a state s s = (position, velocity, mass, age, color, …) p and v are the only ones that must vary with time The entire system state is S S = (p1, v1, p2, v2, p3, v3, …) Each p and v is a 3-vector Can think of S as just a vector in 6n dimensions P, V, A, and F are 3n-vectors

Cornell CS 468Andrew Butts 5 System states 2.5 ways to implement Particle object array Intuitive. Store all particle attributes in one place Only need to deal with Particle objects Clean implementation if we pick just one integration scheme System state array Store 6n vector S as an array of doubles Simplifies the integrator interface Or transform back and forth

Cornell CS 468Andrew Butts 6 Integration How do we implement an integrator? Write a black-box that works on any G function Takes an initial value G at time t, a function G’(value, time) and timestep h. Returns G(t+h). The integrator can be completely separate from the particle representations. If your system has complex forces, repeated G’ evaluations become the bottleneck

Cornell CS 468Andrew Butts 7 Integration Euler Method S(t+h) = S(t) + h*S’( S(t), t ) What’s S’ ? S’ = (P’, V’) = (V, A) = (V, F/m) Simple to implement Requires only one evaluation of S’ Simple enough to be coded directly into the simulation loop Error is O(h)

Cornell CS 468Andrew Butts 8 Integration Midpoint Method S(t+h) = S(t) + h*S( S m, t+h/2) S m = S(t) + 0.5h * S’( S(t), t ) A little less simple… Must compute S’ twice Must keep temporary system state arrays Error is O(h 2 )

Cornell CS 468Andrew Butts 9 Integration Numerical Explosion Can combat error with smaller timesteps at additional computational cost Plagues “stiff” systems with forces prone to oscillation Why’s it called explosion? Demo! (Andrew’s Euler cloth explooodes!) Implicit integration schemes deal with stiff systems Are somewhat painful to implement

Cornell CS 468Andrew Butts 10 The Derivative Function How to implement the S’ function Want V and A Know V is just the particle’s current velocity A = F/m. Evaluate forces here.

Cornell CS 468Andrew Butts 11 Forces A = F/m Particle masses won’t change But need to evaluate F at every time step. The force on one particle may depend on the positions of all the others

Cornell CS 468Andrew Butts 12 Forces Typically, have multiple independent forces. For each force, add its contribution to each particle. Need a force accumulator variable per particle Or accumulate force in the acceleration variable, and divide by m after all forces are accumulated

Cornell CS 468Andrew Butts 13 Forces Example forces Earth gravity, air resistance Springs, mutual gravitation Force fields Wind Attractors/Repulsors Vortices

Cornell CS 468Andrew Butts 14 Forces Earth Gravity f = -9.81*(particle mass in Kg)*Y Drag f = -k*v Uniform Wind f = k

Cornell CS 468Andrew Butts 15 Forces Simple Random Wind After each timestep, add a random offset to the direction Noisy Random Wind Acts within a bounding box Define a grid of random directions in the box Trilinear interpolation to get f After each timestep, add a random offset to each direction and renormalize

Cornell CS 468Andrew Butts 16 Forces Attractors/Repulsors Special force object at position x Only affects particles within a certain distance Within the radius, distance-squared falloff if |x-p| < d v = (x-p)/|x-p| f = ±k/|x| 2 * x else f = 0 Use the regular grid optimization from lecture

Cornell CS 468Andrew Butts 17 Emitters What is it?! Object with position, orientation Regulates particle “birth” and “death” Usually 1 per particle system More than 1 can make controlling particle death inconvenient

Cornell CS 468Andrew Butts 18 Emitters Regulating particles At “birth,” reset the particle’s parameters Free to set them arbitrarily! For “death,” a few possibilities If a particle is past a certain age, reset it. Keep an index into the particle array, and reset a group of K particles at each timestep. Should allocate new particles only once! Recycle their objects or array positions.

Cornell CS 468Andrew Butts 19 Emitters Fountain Given the emitter position and direction, we have a few possibilities: Choose particle velocity by jittering the direction vector Choose random spherical coordinates for the direction vector Demo

Cornell CS 468Andrew Butts 20 Rendering Spheres are easy but boring. Combine points, lines, and alpha blending for moderately interesting effects. Render oriented particle meshes Store rotation info per-particle Keep meshes facing “forward” along their paths Can arbitrarily pick “up” vector

Cornell CS 468Andrew Butts 21 Rendering Render billboards Want to represent particles by textures Should always face the viewer Should get smaller with distance Want to avoid OpenGL’s 2d functions

Cornell CS 468Andrew Butts 22 Rendering Render billboards (one method) Draws an image-plane aligned, diamond-shaped quad Given a particle at p, and the eye’s basis (u,v,w), draw a quad with vertices: q0 = eye.u q1 = eye.v q2 = -eye.u q3 = -eye.v Translate it to p Will probably want alpha blending enabled for smoke, fire, pixie dust, etc. See the Red Book for more info.

Cornell CS 468Andrew Butts 23 Simulation Loop Recap A recap of the loop: Initialize/Emit particles Run integrator (evaluate derivatives) Update particle states Render Repeat! Particle Illusion Demo

Cornell CS 468Andrew Butts 24 Resources The Big One Numerical Recipes - more on integration ParticleIllusion Demos Physically Based Modeling Notes m2001/index.htmlhttp:// m2001/index.html

Cornell CS 468Andrew Butts 25 Adaptive Stepsize Goal: improve stability without destroying performance Define a measure for “step success” Springs: Has any spring stretched more than 10% during this step? If the step was unsuccessful, Roll back and try with half the stepsize Else if the last 2 steps were successful, Try doubling the stepsize

Cornell CS 468Andrew Butts 26 Particle-Object Collision Detection With very simple objects, this is easy Plane: Test the sign of (x-p) n Box: Check six planes! Jon Moon’s Head: Cast ray from p to some outside point. If it intersects Jon Moon an odd number of times, p is inside. Relies on having a CLOSED object! Should accelerate intersection with a grid or octree

Cornell CS 468Andrew Butts 27 Collision Response If the step carried a particle into an object, A few possibilities: Accurate: Solve for t at impact and roll the simulation back. –Must process collisions in chronological order –Might iterate forever! Hack: Don’t even bother rolling back! Teleport the particle to the surface of the object Add a response force Bounce, slide…