soft-body physics

35
Soft-Body Physics

Upload: others

Post on 13-Mar-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Soft-Body Physics

Game Physics

β€’ Realistic objects are not purely rigid.

β€’ Good approximation for β€œhard” ones.

β€’ …approximation breaks when objects break, or deform.

β€’ Generalization: soft (deformable) bodies

β€’ Deformed by force: car body, punched or shot at.

β€’ Prone to stress: piece of cloth, flag, paper sheet.

β€’ Not solid: snow, mud, lava, liquid.

2

Soft Bodies

Game Physics

β€’ Forces may cause object deformation.

β€’ Elasticity: the tendency of a body to return to its

original shape after the forces causing the

deformation cease.

β€’ Rubbers are highly elastic

β€’ Metal rods are much less.

3

Elasticity

Game Physics

β€’ The magnitude within an object of an applied

force, divided by the area of the application

β€’ large value when the force is large or when the surface

is small

β€’ It is a pressure measure 𝜎, with a unit denoted as

Pascal: π‘ƒπ‘Ž = 𝑁/π‘š2

β€’ Example: the stress on the

plane is:

Οƒ = π‘šπ‘”/ πœ‹π‘Ÿ2

4

Stress

π‘Ÿ

π‘Š

π‘š

Game Physics

β€’ The fractional deformation πœ– caused by a stress

β€’ Dimensionless (a ratio).

β€’ How much a deformation differs from being rigid:

β€’ Negative: compression

β€’ Zero: rigid

β€’ Positive: stretch

β€’ Example

β€’ the strain on the

rod is πœ– = βˆ†πΏ 𝐿

5

Strain

𝐹𝑑

𝑑 + βˆ†π‘‘

𝐿

𝐿 + βˆ†πΏ

Game Physics

β€’ The amount of stress to produce a strain is a

property of the material.

β€’ Modulus: a ratio of stress to strain.

β€’ Usually in a linear direction, along a planar region or

throughout a volume region.

β€’ Young’s modulus, Shear modulus, Bulk modulus

β€’ Describing the material reaction to stress.

6

Body Material

Game Physics

β€’ Defined as the ratio of linear stress to linear strain:

π‘Œ =π‘™π‘–π‘›π‘’π‘Žπ‘Ÿ π‘ π‘‘π‘Ÿπ‘’π‘ π‘ 

π‘™π‘–π‘›π‘’π‘Žπ‘Ÿ π‘ π‘‘π‘Ÿπ‘Žπ‘–π‘›=𝐹/𝐴

βˆ†πΏ/𝐿

β€’ Example:

7

Young’s Modulus

𝐿 + βˆ†πΏ

𝐹𝐴

Game Physics

β€’ The ratio of planar stress to planar strain:

𝑆 =π‘π‘™π‘Žπ‘›π‘Žπ‘Ÿ π‘ π‘‘π‘Ÿπ‘’π‘ π‘ 

π‘π‘™π‘Žπ‘›π‘Žπ‘Ÿ π‘ π‘‘π‘Ÿπ‘Žπ‘–π‘›=𝐹/𝐴

βˆ†πΏ/𝐿

β€’ Example:

8

Shear modulus

𝐿

𝐴 𝐹

βˆ†πΏ

Game Physics

β€’ The ratio of volume stress to volume strain

(inverse of compressibility):

𝐡 =π‘£π‘œπ‘™π‘’π‘šπ‘’ π‘ π‘‘π‘Ÿπ‘’π‘ π‘ 

π‘£π‘œπ‘™π‘’π‘šπ‘’ π‘ π‘‘π‘Ÿπ‘Žπ‘–π‘›=βˆ†π‘ƒ

βˆ†π‘‰/𝑉

β€’ Example

9

Bulk modulus

𝐴

𝑃 = 𝐹/𝐴

𝑉

𝐹 𝐴

𝑃 + βˆ†π‘ƒ

𝑉 +βˆ†π‘‰

𝐹 + βˆ†πΉ

Game Physics

β€’ Strain in one direction causes compression in

another.

β€’ Poisson’s ratio: the ratio of transverse to axial

strain:

𝜈 = βˆ’π‘‘ π‘‘π‘Ÿπ‘Žπ‘›π‘ π‘£π‘’π‘Ÿπ‘ π‘’ π‘ π‘‘π‘Ÿπ‘Žπ‘–π‘›

𝑑 π‘Žπ‘₯π‘–π‘Žπ‘™ π‘ π‘‘π‘Ÿπ‘Žπ‘–π‘›β€’ Equals 0.5 in perfectly incompressible material.

β€’ If the force is applied along π‘₯:

𝜈 = βˆ’π‘‘πœ–π‘¦

π‘‘πœ–π‘₯= βˆ’π‘‘πœ–π‘§π‘‘πœ–π‘₯

10

Poisson’s ratio

Game Physics

β€’ Example of a cube of size 𝐿

π‘‘πœ–π‘₯ =𝑑π‘₯

π‘₯π‘‘πœ–π‘¦ =

𝑑𝑦

π‘¦π‘‘πœ–π‘§ =

𝑑𝑧

𝑧

βˆ’πœˆ 𝐿

𝐿+βˆ†πΏ 𝑑π‘₯

π‘₯= 𝐿

πΏβˆ’βˆ†πΏβ€² 𝑑𝑦

𝑦= 𝐿

πΏβˆ’βˆ†πΏβ€² 𝑑𝑧

𝑧⇔

1 +βˆ†πΏ

𝐿

βˆ’π‘£

= 1 βˆ’βˆ†πΏβ€²

𝐿⇔ 𝜈 β‰ˆ

βˆ†πΏβ€²

βˆ†πΏ

11

Poisson’s ratio

𝐹

Δ𝐿

𝐿

βˆ†πΏβ€²

8.1-8.5

Game Physics

β€’ A deformable object is defined by rest shape and

material parameters.

β€’ Deformation map: π‘ž = 𝑓( 𝑝) of every point 𝑝 =π‘₯, 𝑦, 𝑧 .

β€’ Relative displacement field: 𝑓( 𝑝) = 𝑝 + 𝑒( 𝑝)

12

Continuum Mechanics

𝑝

𝑝 + 𝑑𝑝

𝑑𝑝

π‘ž

π‘ž+ π‘‘π‘ž

π‘‘π‘ž

𝑓(𝑝)

𝑓(𝑝 + 𝑑𝑝)

𝑑𝑝

𝑑𝑒

Game Physics

β€’ The strain and stress are related to the material

deformation gradient tensor π½π‘ž, and so to the

displacement field 𝑒.

β€’ The stretch in a unit direction 𝑣 β†’ 𝑣′:

𝑑𝑣′ 2 = π‘£π‘‡βˆ— π½π‘žπ‘‡π½π‘ž βˆ— 𝑣

β€’ π½π‘žπ‘‡π½π‘ž is called the (right) Cauchy-Green strain

tensor.

β€’ Movement is rigid π½π‘ž is orthonormal π½π‘žπ‘‡π½π‘ž =

I No strain!

14

CG Strain Tensor

Game Physics

β€’ And stress tensor from Hooke’s linear material law

𝜎 = 𝐸 βˆ— πœ–

where 𝐸 is the elasticity tensor and depends on the

Young’s modulus and Poisson’s ratio (and more).

15

Stress Tensor

Game Physics

β€’ Two common approaches to simulation:

β€’ Lagrangian (particle-based):

β€’ A set of moving points carrying material properties.

β€’ Object is a connected mesh or cloud of points, suitable for

deformable soft bodies.

β€’ Examples: Finite Element/Difference/Volume methods, Mass-

spring system, Coupled particle system, Smoothed particle

hydrodynamics.

β€’ Eulerian (grid-based):

β€’ A stationary point set where material properties change over time.

β€’ boundary of object not explicitly defined, suitable for fluids.

16

Soft-Body Simulation

Game Physics

β€’ For every point π‘ž, The PDE is given by

𝜌 βˆ— π‘Ž = 𝛻 βˆ™ 𝜎 + 𝐹

β€’ 𝜌: the density of the material.

β€’ π‘Ž: acceleration of point π‘ž.

β€’ 𝛻 βˆ™ 𝜎 = 𝑑 𝑑π‘₯ , 𝑑 𝑑𝑦 , 𝑑 𝑑𝑧 βˆ— 𝜎 is the divergence

of the stress tensor (internal forces):

β€’ 𝐹: other external forces.

17

Motion of Dynamic Elastic materials

Game Physics

β€’ Used to numerically solve partial differential

equations (PDEs).

β€’ Tessellating the volume into a large finite number

of disjoint elements (3D volumetric/surface mesh).

β€’ Typical workflow:

β€’ Estimating deformation field from nodes.

β€’ Computing local strain and stress tensors

β€’ The motion equation determined by integrating the

stress field over each element.

18

Finite Element Method (FEM)

Game Physics

β€’ If the object is sampled using a regular spatial grid,

the PDE can be discretized using finite differences.

β€’ Pro: easier to implement than FEM.

β€’ Con: difficult to approximate complex boundaries.

β€’ Semi-implicit integration is used to move forward

through time

19

Finite Differences Method

Game Physics

β€’ The boundary element method simplifies the finite

element method from a 3D volume problem to a

2D surface problem.

β€’ PDE is given for boundary deformation.

β€’ Only works for homogenous material.

β€’ Topological changes more difficult to handle.

21

Boundary Element Method

Game Physics

β€’ An object consists of point masses connected by a

network of massless springs.

β€’ The state of the system: the positions π‘₯𝑖 and

velocities 𝑣𝑖 of the masses 𝑖 = 1⋯𝑛.

β€’ The sum force 𝑓𝑖 on each mass:

β€’ External forces (e.g. gravity, friction).

β€’ Spring connections with the mass’ neighbors.

β€’ The motion equation 𝑓𝑖 = π‘šπ‘–π‘Žπ‘– is summed up:

𝑀 βˆ— π‘Ž = 𝑓(π‘₯, 𝑣)

where 𝑀 is a 3𝑛 Γ— 3𝑛 diagonal matrix.

22

Mass-Spring System

Game Physics

β€’ Mass points are initially regularly spaced in a 3D

lattice.

β€’ The edges are connected by structural springs.

β€’ resist longitudinal deformations

β€’ Opposite corner mass points are connected by

shear springs.

β€’ resist shear deformations.

β€’ The rest lengths define the rest shape of the

object.

23

Mass-Spring System

Game Physics

β€’ The force acting on mass point 𝑖 generated by the

spring connecting 𝑖 and 𝑗 is

𝑓𝑖 = 𝐾𝑠𝑖( π‘₯𝑖𝑗 βˆ’ 𝑙𝑖𝑗)π‘₯𝑖𝑗

π‘₯𝑖𝑗

where π‘₯𝑖𝑗 is the vector from positions 𝑣𝑖to 𝑣𝑗, 𝐾𝑖 is

the stiffness of the spring and 𝑙𝑖𝑗 is the rest length.

β€’ To simulate dissipation of energy, a damping force

is added:

𝑓𝑖 = 𝐾𝑑𝑖𝑣𝑗 βˆ’ 𝑣𝑖

𝑇π‘₯𝑖𝑗

π‘₯𝑖𝑗𝑇π‘₯𝑖𝑗

π‘₯𝑖𝑗

24

Mass-Spring System

Game Physics

β€’ Pro: intuitive and simple to implement.

β€’ Con: Not accurate and does not necessarily

converges to correct solution.

β€’ depends on the mesh resolution and topology

β€’ …and the choice of spring constants.

β€’ Can be good enough for games, especially cloth

animation

β€’ For possible strong stretching resistance and weak

bending resistance.

25

Mass-Spring System

Game Physics

β€’ Particles interact with each other depending on

their spatial relationship.

β€’ these relationships are dynamic, so geometric and

topological changes can take place.

β€’ Each particle 𝑝𝑖 has a potential energy 𝐸𝑃𝑖.

β€’ The sum of the pairwise potential energies between the

particle 𝑝𝑖 and the other particles.

𝐸𝑃𝑖 =

𝑗≠𝑖

𝐸𝑃𝑖𝑗

26

Coupled Particle System

Game Physics

β€’ The force 𝑓𝑖 applied on the particle at position 𝑝𝑖 is

𝑓𝑖 = βˆ’π›»π‘π‘–πΈπ‘ƒπ‘– = βˆ’

𝑗≠𝑖

𝛻𝑝𝑖𝐸𝑃𝑖𝑗

where 𝛻𝑝𝑖𝐸𝑃𝑖 =𝑑𝐸𝑃𝑖

𝑑π‘₯𝑖,𝑑𝐸𝑃𝑖

𝑑𝑦𝑖,𝑑𝐸𝑃𝑖

𝑑𝑧𝑖

β€’ Reducing computational costs by localizing.

β€’ potential energies weighted according to distance to

particle.

27

Coupled Particle System

Game Physics

β€’ The equation for any quantity 𝐴 at any point π‘Ÿ is given by

𝐴 π‘Ÿ =

𝑗

π‘šπ‘—π΄π‘—

πœŒπ‘—π‘Š( π‘Ÿ βˆ’ π‘Ÿπ‘— , β„Ž)

β€’ π‘Š is a smoothing kernel.– usually Gaussian function or cubic spline.

β€’ β„Ž the smoothing length (max influence distance).

β€’ Example: the density can be calculated as

𝜌 π‘Ÿ =

𝑗

π‘šπ‘—π‘Š( π‘Ÿ βˆ’ π‘Ÿπ‘— , β„Ž)

β€’ It is applied to pressure and viscosity forces, while external forces are applied directly to the particles.

28

Smoothed Particle Hydrodynamics

Game Physics

β€’ Derivatives of quantities: by derivatives of π‘Š.

β€’ Varying the smoothing length β„Ž tunes the

resolution of a simulation locally.

β€’ Typically use a large length in low particle density

regions and vice versa.

β€’ Pro: easy to conserve mass (constant number of

particles).

β€’ Con: difficult to maintain material incompressibility.

29

Smoothed Particle Hydrodynamics

Game Physics

β€’ Typically used to simulate fluids (liquids, smoke,

lava, cloud, etc.).

β€’ The scene is represented as a regular voxel grid,

and fluid dynamics describes the displacements

β€’ Applying finite difference formulation on the voxel grid.

β€’ Velocity is stored on the cell faces.

β€’ Pressure is stored at the center of the cells.

β€’ Heavily rely on the Navier-Stokes equations of

motion for a fluid.

30

Eulerian Methods

Game Physics

β€’ Representing the conservation of mass and momentum for an incompressible fluid:

𝛻 βˆ™ 𝑒 = 0

𝜌 𝑒𝑑 + 𝑒 βˆ™ 𝛻𝑒 = 𝛻 βˆ™ 𝜈 𝛻𝑒 βˆ’ 𝛻𝑝 + 𝑓

β€’ 𝑒𝑑 is the time derivative of the fluid velocity (the unknown), 𝑝 is the pressure field, 𝜈 is the kinematic viscosity, 𝑓 is the body force per unit mass (usually just gravity ρ𝑔).

31

Navier-Stokes Equations

Inertia (per volume) Divergence of stress

Unsteady

acceleration

Convective

acceleration

Pressure

gradientViscosity

Other body

forces

Game Physics

β€’ First 𝑓 is scaled by the time step and added to the

current velocity

β€’ Then the advection term 𝑒 βˆ™ 𝛻𝑒 is solved

β€’ it governs how a quantity moves with the underlying

velocity field (time independent, only spatial effect).

β€’ it ensures the conservation of momentum.

β€’ sometimes called convection or transport.

β€’ solved using a semi-Lagrangian technique.

32

Navier-Stokes Equations

Game Physics

β€’ Then the viscosity term 𝛻 βˆ™ 𝜈 𝛻𝑒 = 𝑣𝛻2𝑒 is solved

β€’ it defines how a cell interchanges with its neighbors.

β€’ also referred to as diffusion.

β€’ Viscous fluids can be achieved by applying diffusion to

the velocity field.

β€’ it can be solved for example by FD and an explicit

formulation:

β€’ 2-neighbor 1D:

𝑒𝑖(𝑑) = 𝑣 βˆ— βˆ†π‘‘ βˆ— 𝑒𝑖+1 + π‘’π‘–βˆ’1 βˆ’ 2𝑒𝑖

β€’ 4-neighbor 2D: 𝑒𝑖,𝑗 𝑑 = 𝑣 βˆ— βˆ†π‘‘ βˆ— 𝑒𝑖+1,𝑗 + π‘’π‘–βˆ’1,𝑗 + 𝑒𝑖,𝑗+1 +

33

Navier-Stokes Equations

Game Physics

β€’ Finally, the pressure gradient is found so that the

final velocity will conserve the volume (i.e. mass

for incompressible fluid)

– sometimes called pressure projection

– it represents the resistance to compression βˆ’π›»π‘

34

Navier-Stokes equations

Lesser density

Greater density

Game Physics

β€’ We make sure the velocity field stays divergence-

free with the second equation 𝛻 βˆ™ 𝑒 = 0.

β€’ The velocity flux of all faces at each fluid cell is

zero (everything that comes in, goes out).

β€’ The equation 𝑒 𝑑 + βˆ†π‘‘ = 𝑒 𝑑 βˆ’ βˆ†π‘‘π›»π‘ is solved

from its combination with 𝛻 βˆ™ 𝑒 = 0, giving

𝛻 βˆ™ 𝑒 𝑑 + βˆ†π‘‘ = 𝛻 βˆ™ 𝑒 𝑑 βˆ’ βˆ†π‘‘π›» βˆ™ 𝛻𝑝 = 0⟺ βˆ†π‘‘π›»2𝑝 = 𝛻 βˆ™ 𝑒(𝑑)

with which we solve for 𝑝, then plug back in the

𝑒(𝑑 + βˆ†π‘‘) equation to calculate the final velocity

35

Navier-Stokes equations

Game Physics

β€’ Compressible fluids can also conserve mass, but

their density must change to do so.

β€’ Pressure on boundary nodes

β€’ In free surface cells, the fluid can evolve freely (𝑝 = 0)β€’ so that for example a fluid can splash into the air

β€’ Otherwise (e.g. in contact with a rigid body), the fluid

cannot penetrate the body but can flow freely in

tangential directions π‘’π‘π‘œπ‘’π‘›π‘‘π‘Žπ‘Ÿπ‘¦ βˆ™ 𝑛 = π‘’π‘π‘œπ‘‘π‘¦ βˆ™ 𝑛.

36

Navier-Stokes equations

End of

Soft body physics

Next

Physics engine design and

implementation