CS-184: Computer Graphics Lecture #18: Simulation Basics Prof. - - PowerPoint PPT Presentation

cs 184 computer graphics
SMART_READER_LITE
LIVE PREVIEW

CS-184: Computer Graphics Lecture #18: Simulation Basics Prof. - - PowerPoint PPT Presentation

1 CS-184: Computer Graphics Lecture #18: Simulation Basics Prof. James OBrien University of California, Berkeley V2016-F-18-1.0 (With some slides from Prof. Ren Ng who is really an awesome guy.) 2 Today Introduction to Simulation


slide-1
SLIDE 1

CS-184: Computer Graphics

Lecture #18: Simulation Basics

  • Prof. James O’Brien

University of California, Berkeley

V2016-F-18-1.0

(With some slides from Prof. Ren Ng who is really an awesome guy.)

1

2

Today

  • Introduction to Simulation
  • Basic particle systems
  • Time integration (simple version)

2

slide-2
SLIDE 2

3

  • Generate motion of objects using numerical simulation

methods

Physically Based Animation

xt+∆t = xt +∆t vt + 1 2∆t2at

g v

3

4

Physically Based Animation

4

slide-3
SLIDE 3

Example: Cloth Simulation

5

5

Example: Fluids

6

Macklin and Müller, Position Based Fluids

6

slide-4
SLIDE 4

Example: Fracture

7

7

Example: Fracture

8

8

slide-5
SLIDE 5

9

Particle Systems

  • Single particles are very simple
  • Large groups can produce interesting effects
  • Supplement basic ballistic rules
  • Collisions
  • Interactions
  • Force fields
  • Springs
  • Others...

Karl Sims, SIGGRAPH 1990

9

10

10

slide-6
SLIDE 6

11

  • Single particles are very simple
  • Large groups can produce interesting effects
  • Supplement basic ballistic rules
  • Collisions
  • Interactions
  • Force fields
  • Springs
  • Others...

Particle Systems

Feldman, Klingner, O’Brien, SIGGRAPH 2005

11

12

Basic Particles

  • Basic governing equation
  • is a sum of a number of things
  • Gravity: constant downward force proportional to mass
  • Simple drag: force proportional to negative velocity
  • Particle interactions: particles mutually attract and/or repell
  • Beware complexity!
  • Force fields
  • Wind forces
  • User interaction

¨ x = 1 mf

f

O(n2)

12

slide-7
SLIDE 7

13

Basic Particles

  • Properties other than position
  • Color
  • Temp
  • Age
  • Differential equations also needed to govern these

properties

  • Collisions and other constrains directly modify position

and/or velocity

13

Particle Rules

14 Bryan E. Feldman, James F . O'Brien, and Okan Arikan. "Animating Suspended Particle Explosions". In Proceedings of ACM SIGGRAPH 2003, pages 708–715, August 2003.

14

slide-8
SLIDE 8

Gravitational Attraction

  • Newton’s universal law of gravitation
  • Gravitational pull between particles

15

Fg = Gm1m2 d2 G = 6.67428 × 10−11 Nm2kg−2

d

m1 m2

15

Example: Galaxy Simulation

16

Disk galaxy simulation, NASA Goddard

16

slide-9
SLIDE 9

17

Integration

  • Euler’s Method
  • Simple
  • Commonly used
  • Very inaccurate
  • Most often goes unstable

xt+∆t = xt + ∆t ˙ xt ˙ xt+∆t = ˙ xt + ∆t ¨ xt

17

18

Integration

  • For now let’s pretend
  • Velocity (rather than acceleration) is a function of force

f = mv ˙ x = f(x, t)

Witkin and Baraff

Note: Second order ODEs can be turned into first order ODEs using extra variables.

18

slide-10
SLIDE 10

19

Integration

  • For now let’s pretend
  • Velocity (rather than acceleration) is a function of force

f = mv ˙ x = f(x, t)

Witkin and Baraff

Start

19

20

Integration

  • With numerical integration, errors accumulate
  • Euler integration is particularly bad

x := x + ∆t f(x, t)

Witkin and Baraff

20

slide-11
SLIDE 11

21

Integration

  • Stability issues can also arise
  • Occurs when errors lead to larger errors
  • Often more serious than error issues

˙ x = [ − sin(ωt) , − cos(ωt) ]

Witkin and Baraff

21

22

  • Modified Euler

Integration

˙ xt+∆t = ˙ xt + ∆t ¨ xt xt+∆t = xt + ∆t 2 ( ˙ xt + ˙ xt+∆t) xt+∆t = xt + ∆t ˙ xt + (∆t)2 2 ¨ xt 22

slide-12
SLIDE 12

23

Integration

  • Midpoint method

a. Compute half Euler step b.

  • Eval. derivative at halfway

c. Retake step

  • Other methods
  • Verlet
  • Runge-Kutta
  • And many others...

a b c

Witkin and Baraff

23

24

Integration

  • Implicit methods
  • Informally (incorrectly) called backward methods
  • Use derivatives in the future for the current step

xt+∆t = xt + ∆t ˙ xt+∆t ˙ xt+∆t = ˙ xt + ∆t ¨ xt+∆t

¨ xt+∆t = A(xt+∆t, ˙ xt+∆t, t + ∆t) ˙ xt+∆t = V(xt+∆t, ˙ xt+∆t, t + ∆t)

24

slide-13
SLIDE 13

25

Integration

  • Implicit methods
  • Informally (incorrectly) called backward methods
  • Use derivatives in the future for the current step
  • Solve nonlinear problem for and
  • This is fully implicit backward Euler
  • Many other implicit methods exist...
  • Modified Euler is partially implicit as is Verlet

˙ xt+∆t = ˙ xt + ∆t A(xt+∆t, ˙ xt+∆t, t + ∆t)

xt+∆t

˙ xt+∆t

˙ xt+∆t = ˙ xt + ∆t V(xt+∆t, ˙ xt+∆t, t + ∆t)

25

26

Temp Slide

Need to draw reverse diagrams....

26

slide-14
SLIDE 14

27

Integration

A(xt+∆t, ˙ xt+∆t) ≈ A(xt, ˙ xt) + C · (∆x) + D · (∆ ˙ x) V(xt+∆t, ˙ xt+∆t) ≈ V(xt, ˙ xt) + A · (∆x) + B · (∆ ˙ x)

  xt+∆t

˙ xt+∆t

   =   xt

˙ xt

   + ∆t       ˙

xt ¨ xt

   +   A B

C D

     ∆x

∆ ˙ x

     

  • Semi-Implicit
  • Approximate with linearized equations

27

28

Integration

  • Explicit methods can be conditionally stable
  • Depends on time-step and stiffness of system
  • Fully implicit can be unconditionally stable
  • May still have large errors
  • Semi-implicit can be conditionally stable
  • Nonlinearities can cause instability
  • Generally more stable than explicit
  • Comparable errors as explicit
  • Often show up as excessive damping

28

slide-15
SLIDE 15

29

Integration

  • Integrators can be analyzed in modal domain
  • System have different component behaviors
  • Integrators impact components differently

29

Example: Mass Spring Rope

30

Credit: Elizabeth Labelle, https://youtu.be/Co8enp8CH34

30

slide-16
SLIDE 16

Example: Mass Spring Mesh

31

Slide from Ren Ng

31

Example: Hair

32

Slide from Ren Ng

32

slide-17
SLIDE 17

Example: Cloth

33 Huamin Wang, Ravi Ramamoorthi, and James F . O'Brien. "Data-Driven Elastic Models for Cloth: Modeling and Measurement". ACM Transactions on Graphics, 30(4):71:1–11, July 2011. Proceedings of ACM SIGGRAPH 2011, Vancouver, BC Canada.

33

Example: Clothing on Character

34

34

slide-18
SLIDE 18

Strain Limiting

35 Huamin Wang, James F . O'Brien, and Ravi Ramamoorthi. "Multi-Resolution Isotropic Strain Limiting". In Proceedings of ACM SIGGRAPH Asia 2010, pages 160:1–10, December 2010.

35

36

A Simple Spring

  • Ideal zero-length spring
  • Force pulls points together
  • Strength proportional to distance

fa→b = ks(b − a) fb→a = −fa→b

36

slide-19
SLIDE 19

37

A Simple Spring

  • Energy potential

fa→b = ks(b − a) fb→a = −fa→b

  • 2
  • 1

1 2

  • 2
  • 1

1 2 2 4 6 8

  • 1

2

fa = raE =  ∂E ∂ax , ∂E ∂ay , ∂E ∂az

  • E = 1/2 ks(b − a) · (b − a)

37

38

A Simple Spring

  • Energy potential: kinetic vs elastic
  • 6
  • 4
  • 2

2 4 6

  • 1
  • 0.5

0.5 1

E = 1/2 ks(b − a) · (b − a)

E = 1/2 m(˙ b − ˙ a) · (˙ b − ˙ a)

38

slide-20
SLIDE 20

39

Non-Zero Length Springs

fa→b = ks b − a ||b − a|| (||b − a|| − l)

Rest length

E = ks (||b − a|| − l)2

  • 2
  • 1

1 2

  • 2
  • 1

1 2 1 2 3

  • 1

2

39

40

Comments on Springs

  • Springs with zero rest length are linear
  • Springs with non-zero rest length are nonliner
  • Force magnitude linear w/ discplacement (from rest length)
  • Force direction is non-linear
  • Singularity at

||b − a|| = 0

40

slide-21
SLIDE 21

41

Damping

  • “Mass proportional” damping
  • Behaves like viscous drag on all motion
  • Consider a pair of masses connected by a spring
  • How to model rusty vs oiled spring
  • Should internal damping slow group motion of the pair?
  • Can help stability... up to a point

f = −kd ˙ a

f ˙ a

41

42

Damping

  • “Stiffness proportional” damping
  • Behaves viscous drag on change in spring length
  • Consider a pair of masses connected by a spring
  • How to model rusty vs oiled spring
  • Should internal damping slow group motion of the pair?

fa = −kd b − a ||b − a||2(b − a) · (˙ b − ˙ a)

42

slide-22
SLIDE 22

43

Spring Constants

  • Two ways to model a single spring

l ∆l

∆l/2

l/2 l/2 ∆l/2 43

44

Spring Constants

  • Constant gives inconsistent results with different

discretizations

  • Change in length is not what we want to measure
  • Strain: change in length as fraction of original length

ks

✏ = ∆l l0 Nice and simple for 1D... 44

slide-23
SLIDE 23

45

Structures from Springs

  • Sheets
  • Blocks
  • Others

45

46

Structures from Springs

  • They behave like what they are (obviously!)

This structure will not resist shearing This structure will not resist out-

  • f-plane bending either...

46

slide-24
SLIDE 24

47

Structures from Springs

  • They behave like what they are (obviously!)

This structure will resist shearing but has anisotopic bias This structure still will not resist

  • ut-of-plane bending

47

48

  • They behave like what they are (obviously!)

Structures from Springs

This structure will resist shearing Less bias Interference between spring sets This structure still will not resist

  • ut-of-plane bending

48

slide-25
SLIDE 25

49

  • They behave like what they are (obviously!)

Structures from Springs

This structure will resist shearing Less bias Interference between spring sets This structure will resist out-of- plane bending Interference between spring sets Odd behavior How do we set spring constants?

49

50

Edge Springs

1 2 3 4 n e n

1 2 ^ ^ ^

n1

^

n2

^

From Bridson et al., 2003, also see Grinspun et al., 2003 u1 = |E| N1 |N1|2 u2 = |E| N2 |N2|2 u3 = (x1 −x4)·E |E| N1 |N1|2 + (x2 −x4)·E |E| N2 |N2|2 u4 = −(x1 −x3)·E |E| N1 |N1|2 − (x2 −x3)·E |E| N2 |N2|2

Fe

i = ke

|E|2 |N1|+|N2| sin(θ/2)ui,

50

slide-26
SLIDE 26

Example: Thin Material

51

Discrete Shells

SCA 2003 Eitan Grinspun, Anil Hirani, Mathieu Desbrun and Peter Schröder

51

Sharp Creases

52

52

slide-27
SLIDE 27

Sharp Creases

53

Anisotropic remeshing avoids locking.

53

Fracture

54

Dominated by discretization artifacts Natural appearance

54

slide-28
SLIDE 28

Variety of Materials

55

55