interpolazione posevcg.isti.cnr.it/~tarini/teaching/gamedev2015/21.animations.pdf · editing...

14
Video Games Dev - 2015/2016 05/12/2015 Marco Tarini - Univ. Insubria 1 Interpolazione pose Due pose si possono interpolare! basta interpolare le trasformazioni che le compongono posa A posa B 0.5 posa A + 0.5 posa B --- --- --- --- Pose = keyframes Per comprimere animazioni keyframe A 0.75 A + 0.25 B 0.50 A + 0.50 B 0.25 A + 0.75 B keyframe B 0.50 B + 0.50 C keyframe C animazione “corsa” t = 0 t = 1 t = 2 t = 3 t = 4 t = 5 t = 6 posa memorizzata posa interpolata (on the fly)

Upload: vuongtram

Post on 21-Aug-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

Video Games Dev - 2015/2016 05/12/2015

Marco Tarini - Univ. Insubria 1

Interpolazione pose

� Due pose si possono interpolare!

� basta interpolare le trasformazioniche le compongono

posa A posa B

0.5 ∙ posa A

+

0.5 ∙ posa B

---

---

---

---

Pose = keyframes

� Per comprimere animazioni

keyframe A

0.75 A + 0.25 B

0.50 A + 0.50 B

0.25 A + 0.75 B

keyframe B

0.50 B + 0.50 C

keyframe C

animazione

“corsa”

t = 0

t = 1

t = 2

t = 3

t = 4

t = 5

t = 6

posa memorizzata

posa interpolata(on the fly)

Video Games Dev - 2015/2016 05/12/2015

Marco Tarini - Univ. Insubria 2

Interpolare intere animazioni

� Es: da stance a corsa

keyframe A

0.75 A + 0.25 B

0.50 A + 0.50 B

0.25 A + 0.75 B

keyframe B

0.67 B + 0.33 C

animazione X

“stance”

t = 0

t = 1

t = 2

t = 3

t = 4

t = 5

0.33 B + 0.67 C

keyframe C

t = 6

t = 7

keyframe D

0.50 D + 0.50 E

0.75 E + 0.25 F

0.50 E + 0.50 F

t = 0+k

t = 1+k

t = 2+k

t = 3+k

t = 4+k

t = 5+k0.25 E + 0.75 F

keyframe F t = 6+k

t = 7+k

ritardo

k = 3animazione Y

“corsa”

keyframe E

0.80 X + 0.20 Y

0.60 X + 0.40 Y

0.40 X + 0.60 Y

0.20 X + 0.80 Y

0.25 A + 0.75 B

keyframe B

0.67 B + 0.33 C

0.33 B + 0.67 C

keyframe C

keyframe D

0.50 D + 0.50 E

0.75 E + 0.25 F

0.50 E + 0.50 F

keyframe E

Interpolazione pose (a runtime):

transizioni fra animazioni

� Es: da stance a corsa

keyframe A

0.75 A + 0.25 B

0.50 A + 0.50 B

animazione X

“stance”

t = 0

t = 1

t = 2

t = 3

t = 4

t = 5

t = 6

t = 7 0.50 E + 0.50 F

t = 0+k

t = 1+k

t = 2+k

t = 3+k

t = 4+k

t = 5+k0.25 E + 0.75 F

keyframe F t = 6+k

t = 7+k

ritardo

k = 3animazione Y

“corsa”

0.25 A + 0.75 B

keyframe B

0.67 B + 0.33 C

0.33 B + 0.67 C

keyframe C

keyframe D

0.50 D + 0.50 E

0.75 E + 0.25 F

keyframe E

Video Games Dev - 2015/2016 05/12/2015

Marco Tarini - Univ. Insubria 3

Animazioni scheletali:come si ottengono

� Editing manuale

� Animatori digitali

� help da: IK, simulazioni fisiche …

� Motion capture:

Cinematica direttaCinematica inversa

� Tipici task della robotica

Forward kinematics: «da angoli (e lunghezze) a (x,y)»

banale!

soluz univoca

VS

Inverse kinematics: «da (x,y) (e lunghezze), a angoli»

non banale!

soluzioni multiple

(task: scegliere quella “migliore”)

Video Games Dev - 2015/2016 05/12/2015

Marco Tarini - Univ. Insubria 4

Inverse Kinematic (IK):un tool utile

� Cinematica diretta:

� “date le trasf locali

P1, P2… PN,

(es, come angoli)

dove finisce il piede?”

� (univoco, banale)

� Cinematica inversa:

� “se voglio mettere il piede

nella pos p, quali

P1, P2… PN, ?”

� (+ vincoli, es. DoF giunti)

� (non univoco, non banale)

bacino(root)

busto 1

spalla dx spalla sx

P2

P4 P6

gambadxgamba

sx

polpacciodx

busto 2

P3 P7

piedeDx

collo

P5 P8

P3P1

Inverse Kinematic (IK):un tool utile

� Due tipi di utilizzo:� in preprocessing (durante il task dell’animator)

� in real time (task da game engine)

� Esempi di utilizzo in real time:� Posizionamento esatto piedi su terreno irregolare

� Mano che raggiunge esattamenteun oggetto da afferrare

� Mani che si congiungono esattamente in un’arma a due mani� (es. nonostante piccole discrepanze nella forma dello

scheletro)� (es. nelle trasizioni)

Video Games Dev - 2015/2016 05/12/2015

Marco Tarini - Univ. Insubria 5

Third personview

spaziomondo

spazio vista

V

T1

= ( T1 x T2 )-1

= ( T2 )-1 x ( T1 )-1

camera

T2

First person view

spaziomondo

T1

busto 1

spalla dx spalla sx

P3

P8 P10

gambadxgamba

sx

polpacciodx

busto 2

P4P7

piedeDx

collo

P9P11

P2P1

testa

bacino(root)

P12

spazio vista

V

camera

T2 T2 = pos occhi (in spazio «testa»)

Video Games Dev - 2015/2016 05/12/2015

Marco Tarini - Univ. Insubria 6

busto 1

spalla dx spalla sx

P3

P8 P10

gambadxgamba

sx

polpacciodx

busto 2

P4

P7

piedeDx

collo

P9

P11

P2P1

testa

bacino(root)

P12

Composizione di pose(� e di animazioni)

+ =lower

joints

upper

joints

busto 1

spalla dx spalla sx

P3

P8 P10

gambadxgamba

sx

polpacciodx

busto 2

P4

P7

piedeDx

collo

P9

P11

P2P1

testa

bacino(root)

P12

busto 1

spalla dx spalla sx

P3

P8 P10

gambadxgamba

sx

polpacciodx

busto 2

P4

P7

piedeDx

collo

P9

P11

P2P1

testa

bacino(root)

P12

Pose A Pose B New Pose

busto 1

spalla dx spalla sx

P3

P8 P10

gambadxgamba

sx

polpacciodx

busto 2

P4

P7

piedeDx

collo

P9

P11

P2P1

testa

bacino(root)

P12

Composizione di pose(� e di animazioni)

+ =lower

joints

upper

joints

busto 1

spalla dx spalla sx

P3

P8 P10

gambadxgamba

sx

polpacciodx

busto 2

P4

P7

piedeDx

collo

P9

P11

P2P1

testa

bacino(root)

P12

busto 1

spalla dx spalla sx

P3

P8 P10

gambadxgamba

sx

polpacciodx

busto 2

P4

P7

piedeDx

collo

P9

P11

P2P1

testa

bacino(root)

P12

P1 = 0.45 ∙ + 0.55 ∙ P1 P1

anche interpolando, p.e.:

Pose A Pose B

Video Games Dev - 2015/2016 05/12/2015

Marco Tarini - Univ. Insubria 7

Composizione di pose(� e di animazioni)

� Utile in molteplici contesti:

� pezzi di personaggio diversi che seguono

animazioni diverse

� Nota implementativa:

� In Unity, si ottiene definendo “Layers” sovrapposti

in un Animation Controller

� Layer = maschera, su quali ossa agisce l’animazione

Alcuni (pre)processing su animazioni skeletali

� Compressione� input: Animaz con N keyframes

� output: Animaz con M<N keyframes

� Retargeting� input: Rig1 + (Skel animat per Rig1) + Rig2

� output: (Skel animat per Rig 2)

� Costruzione da blend-shape animation� input: Blend-shape

� output: Rig + Skinned Mesh + Anim

Video Games Dev - 2015/2016 05/12/2015

Marco Tarini - Univ. Insubria 8

Compressione animazioniskeletali

� Obiettivo: rimuovere keyframes� quelli “inutili”

� in preprocessing (e.g. as a game tool)

� Versione 0.0 di un algoritmo:� per ogni keyframe Px

� rimuovi keyframe Px

� computa versione interpolata Pi

dai keyframe rimanenti

� (il precedente e il successivo)

� se distanza( Pi , Px ) > MAX_ERRallora reinserisci keyframe Px

Per-vertex animations VS Skeletal-Animations

� Per Vertex animations

� possibilità

interpolazione

(e.g. keyframes)

� pesante in RAM

� replicazione esplicita

posizioni + normali

� leggero in computation

� Skeletal animations

� possibilità

interpolazione

(e.g. keyframes)

� leggero in RAM

� ortogonalità

modelli / animazioni

� piccolo sforzo real-time

� interpolaz trasf.

(x vertice!)

� ricomputo trasf globali

(se mix di pose, o altre

manipolaz transf locali)

Video Games Dev - 2015/2016 05/12/2015

Marco Tarini - Univ. Insubria 9

Animations in games(of 3D Solid Objects)

ProceduralNon-Procedural

Rigid

Articulated

Free form

Skeletal

Animations

Blend-Shapes

Rigid body

dynamicsPre-made

transforms

(ASSETS) (PHYSIC ENGINE)

RagdollingInverse

kinematics

(generic)

deformable object

simulation

usually

too expensive

Cloth/

garments

Ropes

Non-procedural Animations:which one to pick?

� Which format to pick?

EXAMPLE:

say we want

a model capable of

doing this:

Video Games Dev - 2015/2016 05/12/2015

Marco Tarini - Univ. Insubria 10

Non-procedural Animations:which one to pick?

Transform

animation

“wing” mesh (2 instances)

“hull” mesh

“wing” mesh(2 instances)

“windscreen”

mesh

wingmesh

wind-screen

mesh

wingmesh

wingmesh

wingmesh

hullmesh

TwsTw1

Tw2 Tw3Tw4

Tshipanimate

these!

solution 1:

rest of scene

scene graph

Non-procedural Animations:which one to pick?

Skeletal

animation

x-wingskinned mesh

wingbone

wind-screen

bone

wingbone

wingbone

wingbone

hullbone

Tship

solution 2:

x-wing rigskeletal animations

Video Games Dev - 2015/2016 05/12/2015

Marco Tarini - Univ. Insubria 11

Non-procedural Animations:which one to pick?

Blend-

shapesolution 3:

“x-wing” blend-shape

base shape morph 1 morph 2

Non-procedural Animations:which one to pick?In this example:� Animation of transforms (of the scenegraph):

� how: 3 (rigid) meshes, 5 instances, animate scenegraph transforms

� can reuse geometry for all wings: most compact on RAM ☺

� simpler rendering

� 5 separated draw calls! �

� Skeletal animation:� how: one rig + one skinned mesh + few skeletal animations

� mesh skinning: single bone enough in this case

� if very low poly mesh (few polys): a waste?

� more taxing rendering (a bit) �� real time skinning on vertex any

� single draw call! ☺

� Blend shapes:� how: blend shape with one base shape + 2 morphs

� minimal impact

� worst quality interpolation: linear� vertices on straight paths

(unless, more shapes added)

� heaviest on RAM �� (a waste of DoF!)

� not important, if very low res

� single draw call! ☺� but to different buffers each frame / or to a larger buffer

straight

(non curved)

paths

Video Games Dev - 2015/2016 05/12/2015

Marco Tarini - Univ. Insubria 12

Animations in games(of 3D Solid Objects)

ProceduralNon-Procedural

Rigid

Articulated

Free form

Skeletal

Animations

Blend-Shapes

Rigid body

dynamicsPre-made

transforms

(ASSETS) (PHYSIC ENGINE)

RagdollingInverse

kinematics

(generic)

deformable object

simulation

usually

too expensive

Cloth/

garments

Ropes

“Geom

. Caches”

Geom. Caches(for lack of a better name)

� Baked, optimized animations

� of a mixture of types e.g.

� blend shapes

� kinematic animatios

� (approximated)

� skinned animations

� (typically, no scene graph, just final transf)

� optimized

� compressed, streamed…

� Baking of a variety of simulations results

.abc

most used

file format:

by

Video Games Dev - 2015/2016 05/12/2015

Marco Tarini - Univ. Insubria 13

Geom. Caches(for lack of a better name)

� Baked, optimized animations

� of a mixture of types

Geometry Caches(a subset of Alembic)

by

in Unity (+Mecanim)(note)

� Assets (modelli, animazioni, scheletri) importabili in formati:� fbx, collada

� Compressione animazioni� durante import o builds

� riduzione num link per vertice, num keyframes … :

� Modulo «Animator Controller» gestisce (in parte WYSIWYG):� blending fra animazioni: transitions

� composizione di animazioni: layers� e.g.: un layer sovrascrive solo le ossa upper body

� Inverse Kinematic: da script ( Avatar.SetIKPoistion )

� Scheletri:� custom (importati da file)

� standard per umanoidi � «scheletro standard per bipedi di unity (e mecanim)» (~21 ossa)

� interfaccia semplificata

Video Games Dev - 2015/2016 05/12/2015

Marco Tarini - Univ. Insubria 14

What about animationsof non solid objects?

� Gases, liquids, etc

� fire, smoke, water splosh, explosions, clouds…

� See particle effects