Title: Computer Animation Particle systems
1Computer Animation Particle systems
- Some slides courtesy of Jovan Popovic Ronen
Barzel
2Animation
- How do we describe and generate motion of object
in the scene?
3Conventional Animation
- Draw each frame of the animation
- great control
- tedious
- Reduce burden with cel animation
- Layer, keyframe, inbetween,
- Example cel panoramas (Disneys Pinocchio)
4Keyframing
- automate the inbetweening
- use spline curves
- good control
- less tedious
- creating a good animation still requires
considerable skill and talent
5Procedural animation
- describes the motion algorithmically
- express animation as a function
- of small number of parameteres
- Example a clock with second, minute and hour
hands - hands should rotate together
- express the clock motions in terms of a seconds
variable - the clock is animated by varying the seconds
parameter
6Physically Based Animation
- Assign physical properties to objects (masses,
forces, inertial properties) - Simulate physics by solving equations
- Realistic but difficult to control
v0
m
g
7Motion Capture
- Usually uses optical markers and multiple
high-speed cameras - Triangulate to get marker 3D position
- Faces or joints
- Captures style, subtle nuances and realism
- You must observe someone do something
8See also
- http//www.pixar.com/howwedoit/index.html
9Questions?
10Keyframing
- Describe motion of objects as a function of time
from a set of key object positions. In short,
compute the inbetween frames.
11What values are keyframed?
- Camera positions and orientations
- Hierarchical controls
- Smile control, eye blinking, etc.
- Keyframes for these higher-level controls
- Skeletal joint angles
- Inverse kinematics
- Endpoint positions
- Skinning
- Muscle parameters, skin parameters,
- Building 3D models and associated controls is a
major componenet of every animation pipeline.
Images from the Maya tutorial
12Example Interpolating Positions
- Given positions
- find curve such that
13Linear Interpolation
- Simple problem linear interpolation between
first two points assuming - The x-coordinate for the complete curve in the
figure
14Polynomial Interpolation
- An n-degree polynomial can interpolate any n1
points. The Lagrange formula gives the n1
coefficients of an n-degree polynomial that
interpolates n1 points. The resulting
interpolating polynomials are called Lagrange
polynomials. On the previous slide, we saw the
Lagrange formula for n 1.
parabola
15Spline Interpolation
- Lagrange polynomials of small degree are fine but
high degree polynomials are too wiggly. Spline
(piecewise cubic polynomial) interpolation
produces nicer interpolation.
16Spline Interpolation
- Reuse tools developed for geometric modeling
Bezier, Hermite, B-Spline, - The parameter u of curve q(u) becomes the current
animation time.
17Interpolating Key Frames
Interpolation is not fool proof. The splines may
undershoot and cause interpenetration. The
animator must also keep an eye out for these
types of side-effects.
18Questions?
19Traditional Animation Principles
- The in-betweening, was once a job for apprentice
animators. Splines accomplish these tasks
automatically. However, the animator still has to
draw the key frames. This is an art form and
precisely why the experienced animators were
spared the in-betweening work even before
automatic techniques. - The classical paper on animation by John Lasseter
from Pixar surveys some the standard animation
techniques - "Principles of Traditional Animation Applied to
3D Computer Graphics, SIGGRAPH'87, pp. 35-44. - See also
20Squash and stretch
- Squash flatten an object or character by
pressure or by its own power - Stretch used to increase the sense of speed and
emphasize the squash by contrast
21Timing
- Timing affects weight
- Light object move quickly
- Heavier objects move slower
- Timing completely changes the interpretation of
the motion. Because the timing is critical, the
animators used the draw a time scale next to the
keyframe to indicate how to generate the
in-between frames.
22Anticipation
- An action breaks down into
- Anticipation
- Action
- Reaction
- Anatomical motivation a muscle must extend
before it can contract. Prepares audience for
action so they know what to expect. Directs
audiences attention. Amount of anticipation can
affect perception of speed and weight.
23Questions?
24Now
Dynamics
25Types of dynamics
- Point
- Rigid body
- Deformable body (include clothes, fluids, smoke,
etc.)
Animation by Mark Carlson
26Today we focus on point dynamics
- But we use tons of points
- Particles systems
27Overview
- Generate tons of particles
- Describe the external forces with a force field
- Integrate the laws of mechanics
- Lots of differential equations -(
- Each particle is described by its state
- Position, velocity, color, mass, lifetime, shape,
etc. - More advanced versions exist flocks, crowds
28What is a particle system?
- Collection of many small simple particles
- Particle motion influenced by force fields
- Particles created by generators
- Particles often have lifetimes
- Used for, e.g
- sand, dust, smoke, sparks, flame, water,
29Videos
- Demos from http//users.rcn.com/mba.dnai/software/
flow/ - flow is a particle animation application under
development by Mark B. Allan and
theReptileLabourProject.Â
30Questions?
31Particle motion
- mass m, position x, velocity v
- equations of motion
- Ordinary Differential Equation
32What is an ODE?
- Ordinary Differential Equation
- Relates value of a function to its derivatives
- Ordinary function of one variable
- Partial Differential Equation (PDE) more
variables
33Standard ODE
- Generic form for first-order ODE
- Note
- typically t is time
- sometimes use Y instead of X, sometimes x
instead of t - names sometimes confusing often
34Why do we care?
- Differential equations describe (almost)
everything - in the world
- physics
- chemistry
- engineering
- ecology
- economy
- weather
-
- Also useful for animation!
- ODEs are fundamental. PDEs build on ODEs
35Solving differential equations
- Analytic solutions to differential equations
- Many standard forms, e.g.
- E.g. x kx !
- But most cant be solved analytically
- 3-body problem
x(t)x0ekt
363 body problem
- 3 punctual masses under the laws of Newtonian
mechanics (gravity) - e.g. the Sun and 2 planets
- No, I do not exclude Pluto
- Cannot be solved analytically
- (related to the geeky term 2-body problem)
37Numerical solutions to ODEs
- Given a function f(X,t) compute X(t)
- Typically, initial value problems
- Given values X(t0)X0
- Find values X(t) for t gt t0
- Also, boundary value problems, constrained
problems,
38Solving ODEs for animation
- For animation, want a series of values
- samples of the continuous function X(t)
- i.e., frames of an animation
39Questions?
40Path through a field
- f(X,t) is a vector field defined everywhere
- E.g. a velocity field
- it may change based on t
41Path through a field
- f(X,t) is a vector field defined everywhere
- E.g. a velocity field
- X(t) is a path through the field
42Higher order ODEs
- E.g., Mechanics has 2nd order ODE
- Express as 1st order ODE
by defining v(t)
43E.g., for a 3D particle
- We have a 6 dimension ODE problem
44For a collection of 3D particles
45Still, a path through a field
- X(t) path in multidimensional state space
- X(t) is an array/vector of numbers.
46Questions?
47Intuitive solution
take steps
- Current state X
- Examine f(X,t) at (or near) current state
- Take a step to new value of X
- Most solvers do some form of this
48Eulers method
- Simplest and most intuitive.
- Define step size h
- Given X0X(t0), take step
- Piecewise-linear approximation to the curve
49Effect of step size
- Step size controls accuracy
- Smaller steps more closely follow curve
- For animation, may need to take many small steps
per frame
50Eulers method inaccurate
- Moves along tangent can leave curve, e.g.
- Exact solution is circle
- Eulers spirals outward
- no matter how small h is
- will just diverge more slowly
51Eulers method unstable
- Exact solution is decaying exponential
- Limited step size
- If k is big, h must be small
52Analysis Taylor series
- Expand exact solution X(t)
- Eulers method approximates
- First-order method Accuracy varies with h
- To get 100x better accuracy need 100x more steps
53Questions?
54Can we do better?
- Problem
- Idea look at f at the arrival of the step and
compensate for variation
f has varied along the step
552nd order methods
- Let
- Then
- This is the trapeziod method,
- AKA improved Eulers method
- Analysis omitted (see 6.839)
56Can we do better?
- Problem f has varied along the step
- Idea look at f at the arrival of the step and
compensate for variation
572nd-order methods continued
- Could also have chosen
- then rearrange the same way, let
- and get
- This is the midpoint method
58Comparison
a
- Midpoint
- ½ Euler step
- evaluate fm
- full step using fm
- Trapezoid
- Euler step (a)
- evaluate f1
- full step using f1 (b)
- average (a) and (b)
- Not exactly same result
- Same order of accuracy
f1
fm
b
59Can we do even better
- You bet!
- You will implement Runge Kutta for assignment 4
- See the Physically-Base Modeling Siggraph course
notes, e.g. at http//www.cs.berkeley.edu/daf/gam
es/webpage/SimList/Papers/physicallyBasedModeling-
sg2002.pdfsearch22physically-based20modeling2
2 - the reference for anythign related to physics and
computer animation
60Questions?
61Particle Animation
- AnimateParticles(n, y0, t0, tf)
-
- y y0
- t t0
- DrawParticles(n, y)
- while(t ! tf)
- f ComputeForces(y, t)
- dydt AssembleDerivative(y, f)
- //there could be multiple force fields
- y, t ODESolverStep(6n, y, dy/dt)
- DrawParticles(n, y)
-
62What is a force?
- Forces can depend on location, time, velocity
- Implementation
- Force a class
- Computes force function for each particle p
- Adds computed force to total in p.f
- There can be multiple force sources
63Forces gravity on Earth
- depends only on particle mass
- f(X,t) constant
- for smoke, flame make gravity point up!
v0
mi
G
64Forces gravity for N-body problem
- Depends on all other particles
- Opposite for pairs of particles
- Force in the direction of pipj with magnitude
inversely proportional to square distance - Fij
G mimj / r2
Pi
Pj
65Forces
damping
- force on particle i depends only on velocity of I
- force opposes motion
- removes energy, so system can settle
- small amount of damping can stabilize solver
- too much damping makes motion like in glue
66Forces spatial fields
- force on particle i depends only on position of i
- arbitrary functions
- wind
- attractors
- repulsers
- vortexes
- can depend on time
- note these add energy, may need damping
67Forces spatial interaction
- e.g., approximate fluid Lennard-Jones force
- Repulsive attractive force
- O(N2) to test all pairs
- usually only local
- Use buckets to optimize. Cf. 6.839
force
distance
68Questions?
69Where do particles come from?
- Often created by generators (or emitters)
- can be attached to objects in the model
- Given rate of creation particles/second
- record tlast of last particle created
- create n particles. update tlast if n gt 0
- Create with (random) distribution of initial x
and v - if creating n gt 1 particles at once, spread out
on path
70Particle lifetimes
- Record time of birth for each particle
- Specify lifetime
- Use particle age to
- remove particles from system when too old
- often, change color
- often, change transparency (old particles fade)
- Sometimes also remove particles that are
offscreen
71Rendering and motion blur
- Particles are usually not shaded (just emission)
- Often, they dont contribute to the z-buffer
(rendered last with z-buffer disabled) - Draw a line for motion blur
- (x, xvdt)
- Sometimes use texture maps (fire, clouds)
72Questions?
73Particle Animation Reeves et al. 1983
Start Trek, The Wrath of Kahn
- Star Trek, The Wrath of Kahn Reeves et al. 1983
74How they did it?
- One big particle system at impact
- Secondary systems for rings of fire.
75Particle Modeling Reeves et al. 1983
- The grass is made of particles
76Other uses of particles
- Water
- E.g. splashes in lord of the ring river scene
- Explosions in games
- Grass modeling
- Snow, rain
- Screen savers
77Questions?
78Collisions
- Detection
- Response
- Overshooting problem (when we enter the solid)
79Detecting collisions
- Easy with implicit equations of surfaces
- H(x,y,z)0 at surface
- H(x,y,z)lt0 inside surface
- So just compute H and you know that youre inside
if its negative - More complex with other surface definitions
80Collision response
N
v
- tangential velocity vb unchanged
- normal velocity vn reflects
- coefficient of restitution
- change of velocity -(1?)v
- change of momentum Impulse -m(1?)v
- Remember mirror reflection? Can be seen as
photon particles
81Collisions - overshooting
- Usually, we detect collision when its too late
were already inside - Solutions back up
- Compute intersection point
- Ray-object intersection!
- Compute response there
- Advance for remaining fractional time step
- Other solutionQuick and dirty fixup
- Just project back to object closest point
backtracking
fixing
82Questions?
83Implementation Particle
- Particles p have attributes that specify mass
p.m, position p.x, and velocity p.v. - Other attributes such as color, particle age, and
other can also be included for more advanced
effects. - For implementation convenience, each particle
will also have a force accumulator p.f that sums
up all forces acting on the particle.
84Implementation Particle Systems
- Particle system is an array of particles.
- It will support numerical integration with the
following methods - Compute dimension of the particle system
- Set current state (positions and velocities)
- Get current state (positions and velocities)
- Compute accelerations f(X, t)
- Integration uses only these four methods to
simulate evolution of a particle system
85Implementation Accelerations
- / compute accelerations and place in f /
- int ComputeAccelerations(ParticleSystem ps,
double f) - int i / particle counter /
- int j / force dimension counter /
- ClearForces(ps) / zero force accumulators
/ - ComputeForces(ps) / accumulate forces /
- for(i0, j0 i lt ps.n i)
- fj ps.pi.v0 / xdot v /
- fj ps.pi.v1
- fj ps.pi.v2
- fj ps.pi.f0/m / vdot f/m /
- fj ps.pi.f1/m
- fj ps.pi.f2/m
-
-
86Implementation Get State
- / gather state from the particles into X /
- int GetState(ParticleSystem ps, double X)
- int i, j
- for(i0, j0 i lt ps.n i)
- Xj ps.pi.x0
- Xj ps.pi.x1
- Xj ps.pi.x2
- Xj ps.pi.v0
- Xj ps.pi.v1
- Xj ps.pi.v2
-
-
87Implementation Set State
- / scatter state from X into particles /
- int SetState(ParticleSystem ps, double X)
- int i, j
- for(i0, j0 i lt ps.n i)
- ps.pi.x0 Xj
- ps.pi.x1 Xj
- ps.pi.x2 Xj
- ps.pi.v0 Xj
- ps.pi.v1 Xj
- ps.pi.v2 Xj
-
-
88Implementation Euler Integration
- void EulerStep(ParticleSystem ps, double dt)
- ComputeAccelerations(ps, f)
- GetState(ps, X0)
- X1 X0 dt f / Euler step /
- SetState(ps, X1)
- ps.t dt / advance time /
-
89Questions?
90More advanced version
- Flocking birds, fish school
- http//www.red3d.com/cwr/boids/
- Crowds
91Flocks
- From Craig Reynolds
- Each bird modeled as a complex particle (boid)
- A set of forces control its behavior
- Based on location of other birds and control
forces
92Flocks
- From Craig Reynolds
- Boid" was an abbreviation of "birdoid", as his
rules applied equally to simulated flocking
birds, and schooling fish.
93Questions?
94Additional references
- http//www.cse.ohio-state.edu/parent/book/outline
.html - http//www.pixar.com/companyinfo/research/pbm2001/
- http//www.cs.unc.edu/davemc/Particle/