Particle Systems - University of...

41
Particle Systems Computer Animation and Visualisation Lecture 10 Taku Komura

Transcript of Particle Systems - University of...

Page 1: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Particle Systems

Computer Animation and Visualisation

Lecture 10

Taku Komura

Page 2: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Overview

• Particle System – Modelling fuzzy objects

– Modelling fire

– Modelling liquid

– Modelling cloth, hair

– Integration : – Euler

– Verlet integration

– implicit integration,

– Rigid body dynamics by particle systems

Page 3: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Particle Systems

• Modelling objects by a number of small particles

• We can model fuzzy objects such as – fire,

– fireworks

– clouds,

– smoke,

– water, etc.

• But we can also model

– cloth

– hair

– rigid objects

Page 4: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Particle System

• Initially developed by Reeves to create scenes for Star Trek II.

http://www.youtube.com/watch?v=13b7TSiidaM&feature=channel_page

Reeves ’83,’85

Page 5: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Particle Dynamics

• A particle's position in

each succeeding frame

can be computed by

its velocity

• This can be modified

by an acceleration

force for more complex

movements, e.g.,

gravity simulation.

xnew

=xold

+voldΔt

vnew

=vold+aΔt

ma=F

Page 6: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Particle Attributes

Each new particle has the following

attributes:

– initial position

– initial velocity (speed and direction)

– initial size

– initial color

– initial transparency

– shape

– lifetime

Page 7: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Modelling fuzzy objects with

particle system For each frame of an animation sequence the following

steps are performed:

1. New particles are generated

2. Each new particle is assigned its own set of attributes

3. Any particles that have existed for a predetermined time are destroyed

4. The remaining particles are transformed and moved according to their dynamic attributes

5. An image of the remaining particles is rendered

Page 8: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Spawning Particles

• Particles are generated using stochastic

methods.

• The designer controls the mean number and

variance.

• number of particles generated :

−1.0≤rand()≤1.0

N partsF =Nmean +rand ()⋅Variance

a uniformly distributed random number

Page 9: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Modelling Fire

- Define an emitter circle

- The particles are launched in a random direction within a predefined range

𝒙 = 𝒙𝒎𝒆𝒂𝒏 + 𝑟𝑎𝑛𝑑() × 𝒙𝒗𝒂𝒓

𝒗 = 𝒗𝒎𝒆𝒂𝒏 + 𝑟𝑎𝑛𝑑() × 𝒗𝒗𝒂𝒓

Page 10: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Modelling Fire (2)

- Forces are added to the particles such that they move towards the goal position

- The goal is controlled randomly to add wobbling effect

goal[0][0] = 7*sin(rand()%360*PI/180); goal[0][2] = 7*cos(rand()%360*PI/180); goal[0][1] = getRandomValue(25,5);

https://www.youtube.com/watch?v=7LbtpmFSKF4&list=UU0ITEfzrLiblxtsImEfE08w&index=3

Page 11: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Modelling Fire (3)

- The color is adjusted such that they are bright when close to the centre and darker when farther away

http://www.youtube.com/watch?NR=1&feature=endscreen&v=gS_koVukVzE

Page 12: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Modelling Water • To model liquid, the interactions between the

particles must be taken into account

• Interactions produce forces

• Three kinds of forces – adhesion forces

– viscosity forces

– friction forces

Page 13: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Adhesion Force Attract particles to each other and to other

objects

The adhesion force between (left) honey-honey, (middle)

honey-ceramic and (right) non-mixing liquid

Page 14: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Viscosity Force

• Limit shear movement of particles in the liquid

• The momentum between the neighbour particles

are exchanged

Pp Ppn

Pexch

=v⋅k (d

pn)( P

p−P

pn)Δt

2∑n=1

nk (d i)

v : viscosity coefficient

k () : A weighting function (Gaussian )

di: distance from the processed particle

Pp

,Ppn

: momentum of p and pn

Pexch

: momentum exchanced

Pp=P

p+P

exch

Ppn=P

pn−P

exch

Page 15: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Friction Force

– Dampen movement of particles in contact with objects in

the environment.

– Simply scale down the velocity by a constant value

– Or we can compute the penetration depth, and adjust the

force according to the depth (explained later)

vv f=ˆ

Page 16: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Rendering liquid • There are two categories of methods for rendering liquid

– rendering individual particles, or

– rendering the surface of the entire liquid

• Rendering individual particles works well for modelling waterfalls or spray

• A surface rendering will give a more accurate description but is generally much slower

http://www.youtube.com/watch?v=n5lOjME8B6M http://www.youtube.com/watch?v=isXNkTiiAYQ

Page 17: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Rendering Liquid by Blobs (metaballs)

• Create an implicit function similar to the electron density maps

• We can define the surface where F(x,y,z)=0 Blinn ‘92

D ( x , y , z )=∑i

biexp(−a

ir

i)

r i=√( x− xi )2+( y− y i )

2+( z−zi )

2

( xi, y

i, z

i) : the center of the particle i

F ( x , y , z )=D ( x , y , z )−T

Page 18: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Advantages of simulating fuzzy

objects by particle systems

• Complex systems can be created with little

human effort.

• The level of detail can be easily adjusted.

– If a particle system object is in the distance, then it

can be modelled to low detail (few particles)

– If it is close to the camera, then it can be modelled

in high detail (many particles)

Page 19: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Level-of-Detail

– A particle in low resolution can correspond to a

set of particles in high resolution

– The position and velocity of the particle in low

resolution becomes the means of the positions

and velocities of the high resolution set

Page 20: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Cloth Simulation

• Need to generate animations of cloth of the

characters appearing in the games

• Can use particles for this purpose

Page 21: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Cloth

• We model the cloth by mass-spring

models (particles connected with

springs)

– Mass pulled by the interconnecting

springs

Page 22: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Hair

• Linear set of particles

• Length structural force

• Deformation forces proportional to the angle between segments

http://www.youtube.com/watch?v=gj2UdZ-G0vg&feature=related

Page 23: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Integration for Simulation

• Computing the new position and velocity

from the current ones using the force

Three ways of integration

• Euler

• Verlet

• Implicit Integration

),(

),(

00

00

vxg

vxf

v

x

Page 24: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Integration for Simulation

Euler Method

• ∆t : time step

• M : mass matrix,

• fo : external force

• ∆x ∆v position, velocity updates of particles

• xo vo , current position, velocity

0

1f

v

Δv

Δx 0

M

Δt=

Page 25: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Problem with Euler Method

• When the time step is too large, the

system can blow up (diverge) very

quickly

Page 26: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Verlet integration (Jakobsen ’02)

Directly computing the next position from the acceleration

• x0 : current position

• x’ : updated position

• x*: The position in the previous step

• Δt : time step,

• a : acceleration

• Used intensely when simulating molecular dynamics. It is quite stable

since the velocity is implicitly given

• Directly computing the next location from the current acceleration

0

2

02

xx

axxx'

*

*

=

t+=

Page 27: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Implicit Integration (Baraff ’98)

• Very stable

• Assuming the force in the next time step

also results in the velocity increment at

this time step

• Need to calculate ∆𝒙, ∆𝒗 that satisfies this

equation

)++(M

+Δt=

ΔvvΔx,xf

Δvv

Δv

Δx

00

0

1

Type equation here.

Page 28: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Taylor series expansion of the force

• Substituting this into the last equation,

we get

)++(M

+vΔt=

Δvv

fΔx

x

ff

Δv

Δv

Δx

0

1

0

Page 29: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Finally, computing the velocity

update

• Substituting

We can finally compute by

x

f

v

f

v

Δv0

121

0

1

MΔtΔtMI

x

fΔt+fΔtM

=

)+Δt(= ΔvvΔx 0

Page 30: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Advantages

• We can update by using large time

steps ( )

• Do not have to worry about blowing off

• The motions can be smoothened too much

Drawbacks

ΔvΔx,tΔ

Page 31: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Advanced Character Physics (ACP):

Multibody dynamics by particle system

Jakobsen, GDC `02

• Simulating articulated objects such as

human bodies, robotic arms, cars by

particle systems

• easy to implement

• But slow when the particle number is very

large

Page 32: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

ACP: How does it work?

• Model rigid bodies by a collection of particles

• Assume the distance between the particles will

remain the same if they belong to the rigid body

• Each particle will move based on the free particle

dynamics

• The 3D position will be modified according to the

distance constraints

Page 33: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

ACP: Keeping the distance

between the particles the same

• The two particles are simply translated along the

line connecting them offline

• The traveling distance is inverse proportional to the

mass

Page 34: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Algorithm

1. Move the particles as free particles by physics - Verlet integration

2. For each bone Move each particle inverse proportional to their mass (as explained in last page)

3. Repeat 2 a few times until the all the distance constraints are satisfied

4. Go back to 1

Page 35: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

ACP: Modeling joints

It is possible to connect multiple rigid

bodies by hinges, pin joints, and so on.

Simply let two rigid bodies share a

particle, and they will be connected by a

pin joint. Share two particles, and they

are connected by a hinge.

A 3DOF pin joint (left) and 1DOF hinge

joint (right)

Page 36: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

ACP: Setting joint limits

• A method for restraining angles is to satisfy a dot

product constraint

• Insert a virtual bone between the mass points

temporarily

(x2−x0 )⋅(x1−x0 )<α .

Page 37: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

ACP: Modeling Characters

• We can model human characters by this system

• Used for ragdoll physics in Hitman

• http://www.teknikus.dk/tj/gdc2001.htm

• Can apply for inverse kinematics

Figure 9. The particle/stick configuration used in Hitman for representing the human anatomy

Page 38: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

ACP: Collision detection

• The collision detection will

be done based on the points

and the surfaces

• The colliding particle will be

pushed out from the

penetrating area

• The velocity element of the

colliding particle

perpendicular to the surface

will be reduced to zero

Page 39: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

How to resolve collisions?

• Find the closest face among all the faces

• Move the particle in the direction of the normal vector of the closest face

Page 40: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

ACP: Friction Force

• According to the Coulomb friction model,

friction force depends on the size of the

normal force between the objects in contact.

• The penetration depth dp can be first

measured when a penetration has occured

(before projecting the penetration point out of

the obstacle),

• and then, the tangential velocity vt is then

reduced by an amount proportional to dp (the

proportion factor being the friction constant).

Page 41: Particle Systems - University of Edinburghhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2013.pdf · 2013-02-15 · particle system For each frame of an animation sequence the

Readings • Blinn, “A Generalization of Algebraic Surface Drawing” ACM

Transactions on Graphics, 1982

• Baraff and Witkin, “Large Steps in Cloth Simulation”, SIGGRAPH 98

• Jakobsen, “Advanced Character Physics”, GDC02

• Stam, “Stable Fluids”, SIGGRAPH 99

• M. Lin and J. Canny, IEEE Conference on Robotics and Automation, pages 1008-1014, 1991

• W. T. Reeves, "Particle Systems - A Technique for Modeling a Class of Fuzzy Objects", Computer Graphics, vol. 17, no. 3, pp 359-376, 1983.

• W. T. Reeves, "Approximate and Probabilistic Algorithms for Shading and Rendering Structured Particle Systems", Computer Graphics, vol. 19, no. 3, pp 313-322, 1985.

Implementing Particle System to Simulate Fire and Water Effects Ankit Chaudhari, Pradeep Singh, Puneet Kalra