Physically-based Animation - Informatics Homepages...

49
Physically-based Animation Computer Animation and Visualisation Lecture 10-11 Taku Komura

Transcript of Physically-based Animation - Informatics Homepages...

Page 1: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Physically-based Animation

Computer Animation and Visualisation

Lecture 10-11

Taku Komura

Page 2: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Overview • Particle System

– Modelling fuzzy objects – Modelling fire– Modelling liquid

• SPH• Visualization by implicit surface

– Modelling cloth, hair – Integration :

– Euler– Verlet integration– implicit integration,

– Rigid body dynamics by particle systems• Advanced character physics

Page 3: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Modelling fuzzy objects with 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: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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.

Page 6: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Modelling Fire

- Define an emitter circle- The particles are launched in a random

direction within a predefined range

• number of particles generated :

Page 7: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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 8: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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 9: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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 10: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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 11: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Fluid Simulation

– Simulating things like • Water, • Air flow

Page 12: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Fluid Simulation (2)

– Two approaches • Lagrangian (today)

– Particle-based method– i.e. SPH

• Eulerian– Uniform grid, vector field – i.e. Stable Fluids

Page 13: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Smoothed-particle hydrodynamics (SPH)

● A Lagrangian method developed for initially for astrophysical problems. ● Modelling the fluid by a set of particles● The particles have a spatial distance over which properties are smoothed by a kernel function https://www.youtube.com/watch?v=POnmzzhc5E0

Page 14: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

SPH Kernel Function

●The particle properties are smoothed by a kernel function to simulate the continuous nature of fluid by finite set of particles

Page 15: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

SPH Kernel Function

●The value of the kernel function at the position of particle j whose center is at particle I is computed by

j

i● The kernel function must integrate to 1

Page 16: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

SPH Kernel Function

●Kernel function: Should be close to a Gaussian function● Better have a finite support●Also polynomial function is preferred

●Example:

Page 17: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

SPH Kernel Attributes

●Properties of the fluid are interpolated using the kernel function

●Density

Mass of particle j i

j

Page 18: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

SPH Kernel Attributes

●Properties such as velocity, pressure are computed by the following function

Kernel functioni

j

Page 19: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

SPH Kernel Attributes (2)

● The spatial derivatives can be easily computed by deriving the kernel function

i

j

Page 20: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Pressure

For liquid, the pressure is modelled such that they are cohesive when the particles are far, and repulsive when close

Page 21: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Pressure (2)

Pressure force(with some modification to work well)

Using the kernel function

Particle acceleration due to pressure differences

Page 22: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Viscosity Force

Acceleration due to friction forces between particles with difference velocities

vj vi

Page 23: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Navier Stokes Equation (Lagrangian)

Other forces:

Gravity, surface tension, etc.

Page 24: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

SPH Algorithm

Page 25: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Rendering liquid

• Two ways can be considered– 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 26: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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

Page 27: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Cloth Simulation

• Need to generate animations of cloth of the characters appearing in the games

• Can use particles for this purpose

Page 28: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Cloth • We model the cloth by mass-spring

models (particles connected with springs)– Mass pulled by the interconnecting

springs

Page 29: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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 30: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Integration for Simulation Euler Method

• h : time step

• M : mass matrix,

• fo : external force

• pos, vel of particles

Page 31: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Problem with Euler Method

• When the time step is too large, the system can blow up (diverge) very quickly

Page 32: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Verlet integration (Jakobsen ’02)

Directly computing the next position from the acceleration

• x : 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

x'=2x−x+aΔt2

x=x

*

*

Page 33: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Implicit Integration (Baraff ’98)

• Very stable

• Assuming the force in the next time step also results in the velocity increment at this time step

• Original Euler

(ΔxΔv )=Δt( v0

M−1 f (x0 ,v0 ))

Page 34: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Implicit Integration (Baraff ’98)

• Very stable

• Assuming the force in the next time step also results in the velocity increment at this time step

• Implicit Integration

(ΔxΔv )=Δt( v0+Δv

M−1 f ( x0+Δx,v0+Δv ))

Page 35: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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

(ΔxΔv )=Δt( v0+Δv

M−1 f ( x0+Δx,v0+Δv ))

Page 36: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Taylor series expansion of the force

• Substituting this into the last equation, we get

Page 37: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Finally, computing the velocity update

• Substituting

We can finally compute by

Page 38: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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

Page 39: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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 40: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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 41: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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 42: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Algorithm1. 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 all the distance constraints are satisfied

4. Go back to 1

Page 43: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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 44: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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

Page 45: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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 46: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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 term of the colliding particle perpendicular to the surface will be reduced to zero

Page 47: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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 48: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

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 49: Physically-based Animation - Informatics Homepages Serverhomepages.inf.ed.ac.uk/tkomura/cav/presentation10_2016.pdf · Overview • Particle System –Modelling fuzzy objects –Modelling

Readings

• Blinn, “A Generalization of Algebraic Surface Drawing” ACM Transactions on Graphics, 1982

• Baraff and Witkin, “Large Steps in Cloth Simulation”, SIGGRAPH 98• SPH Fluids in Computer Graphics, EG2014, STAR Report• Muller et al. Particle-Based Fluid Simulation for Interactive Applications,

SCA03

• Jakobsen, “Advanced Character Physics”, GDC02

• 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.

Steele et al., “Modeling and rendering viscous liquids”, CAVW 2004Implementing Particle System to Simulate Fire and Water Effects