soft-body physics
TRANSCRIPT
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