Chapter 5.2 Character Animation

Similar documents
Advanced Graphics and Animation

SM2231 :: 3D Animation I :: Basic. Rigging

Computer Animation Fundamentals. Animation Methods Keyframing Interpolation Kinematics Inverse Kinematics

CMSC 425: Lecture 10 Skeletal Animation and Skinning

COMPUTER ANIMATION 3 KEYFRAME ANIMATION, RIGGING, SKINNING AND CHARACTER ANIMATION. Rémi Ronfard, Animation, M2R MOSIG

Overview. Animation is a big topic We will concentrate on character animation as is used in many games today. humans, animals, monsters, robots, etc.

Character Animation 1

Rigging / Skinning. based on Taku Komura, Jehee Lee and Charles B.Own's slides

Animation. CS 4620 Lecture 33. Cornell CS4620 Fall Kavita Bala

Animations. Hakan Bilen University of Edinburgh. Computer Graphics Fall Some slides are courtesy of Steve Marschner and Kavita Bala

Character Animation. Presented by: Pam Chow

BONE CONTROLLER ASSET VERSION 0.1 REV 1

animation computer graphics animation 2009 fabio pellacini 1 animation shape specification as a function of time

animation computer graphics animation 2009 fabio pellacini 1

Articulated Characters

Animation. CS 4620 Lecture 32. Cornell CS4620 Fall Kavita Bala

Applications of Dual Quaternions in Three Dimensional Transformation and Interpolation

Animation. Keyframe animation. CS4620/5620: Lecture 30. Rigid motion: the simplest deformation. Controlling shape for animation

Homework 2 Questions? Animation, Motion Capture, & Inverse Kinematics. Velocity Interpolation. Handing Free Surface with MAC

animation projects in digital art animation 2009 fabio pellacini 1

Beginners Guide Maya. To be used next to Learning Maya 5 Foundation. 15 juni 2005 Clara Coepijn Raoul Franker

3D Modelling: Animation Fundamentals & Unit Quaternions

Blending & State Machines. CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2017

Kinematics and Orientations

Chapter 9 Animation System

CS354 Computer Graphics Character Animation and Skinning

Keyframing an IK Skeleton Maya 2012

CS770/870 Spring 2017 Animation Basics

CS770/870 Spring 2017 Animation Basics

Character animation Christian Miller CS Fall 2011

Introduction to Computer Graphics. Animation (1) May 19, 2016 Kenshi Takayama

Inverse Kinematics Programming Assignment

Advanced Computer Graphics Transformations. Matthias Teschner

Animation. CS 465 Lecture 22

Computer Animation. Algorithms and Techniques. z< MORGAN KAUFMANN PUBLISHERS. Rick Parent Ohio State University AN IMPRINT OF ELSEVIER SCIENCE

MODELING AND HIERARCHY

Channels & Keyframes. CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2017

Breathing life into your applications: Animation with Qt 3D. Dr Sean Harmer Managing Director, KDAB (UK)

Animation Essentially a question of flipping between many still images, fast enough

CS 231. Basics of Computer Animation

Human body animation. Computer Animation. Human Body Animation. Skeletal Animation

Learning Autodesk Maya The Modeling & Animation Handbook. Free Models From Turbo Squid Value US $ Official Autodesk Training Guide

Announcements: Quiz. Animation, Motion Capture, & Inverse Kinematics. Last Time? Today: How do we Animate? Keyframing. Procedural Animation

Motion Capture & Simulation

Last Time? Inverse Kinematics. Today. Keyframing. Physically-Based Animation. Procedural Animation

Animation. Traditional Animation Keyframe Animation. Interpolating Rotation Forward/Inverse Kinematics

KINEMATICS FOR ANIMATION. Rémi Ronfard, Animation, M2R MOSIG

Why animate humans? Why is this hard? Aspects of the Problem. These lectures. Animation Apreciation 101

Quaternions and Rotations

Real Time Skin Deformation with Bones Blending

Game Programming. Bing-Yu Chen National Taiwan University

The goal is the definition of points with numbers and primitives with equations or functions. The definition of points with numbers requires a

Character Animation COS 426

Last Time? Animation, Motion Capture, & Inverse Kinematics. Today. Keyframing. Physically-Based Animation. Procedural Animation

7 Modelling and Animating Human Figures. Chapter 7. Modelling and Animating Human Figures. Department of Computer Science and Engineering 7-1

Quaternions and Rotations

MOTION CAPTURE DATA PROCESSING - MOTION EDITING / RETARGETING - MOTION CONTROL / GRAPH - INVERSE KINEMATIC. Alexandre Meyer Master Informatique

Splines. Parameterization of a Curve. Curve Representations. Roller coaster. What Do We Need From Curves in Computer Graphics? Modeling Complex Shapes

Animation COM3404. Richard Everson. School of Engineering, Computer Science and Mathematics University of Exeter

Ryan Marcotte CS 499 (Honours Seminar) March 16, 2011

Fall CSCI 420: Computer Graphics. 4.2 Splines. Hao Li.

3.3 Interpolation of rotations represented by quaternions

Animation, Motion Capture, & Inverse Kinematics. Announcements: Quiz

About this document. Introduction. Where does Life Forms fit? Prev Menu Next Back p. 2

3D Character animation principles

COMP 175 COMPUTER GRAPHICS. Lecture 10: Animation. COMP 175: Computer Graphics March 12, Erik Anderson 08 Animation

The 3D rendering pipeline (our version for this class)

Interactive Computer Graphics

Last Time? Animation, Motion Capture, & Inverse Kinematics. Today. Keyframing. Physically-Based Animation. Procedural Animation

CS 775: Advanced Computer Graphics. Lecture 3 : Kinematics

2D/3D Geometric Transformations and Scene Graphs

Animation Lecture 10 Slide Fall 2003

Animation Curves and Splines 2

The Benefits of Guidelines. Elimination of hype Clarity and certainty Ease of drafting schedules and test plans Varying from the guidelines

TIEA311 Tietokonegrafiikan perusteet kevät 2018

Animation II: Soft Object Animation. Watt and Watt Ch.17

Kinematical Animation.

Maya Lesson 8 Notes - Animated Adjustable Desk Lamp

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

12.1 Quaternions and Rotations

Blender Animation Editors

For each question, indicate whether the statement is true or false by circling T or F, respectively.

Inverse Kinematics II and Motion Capture

AMSTERDAM BOSTON HEIDELBERG LONDON NEW YORK OXFORD PARIS SAN DIEGO SAN FRANCISCO SINGAPORE SYDNEY TOKYO F ^ k.^

Platformer Tutorial 8 - Adding Mr.Green and Character Animation. Last month. Character FX

Quaternions and Rotations

Principles of Computer Game Design and Implementation. Revision Lecture

CS 4621 PPA3: Animation

Inverse Kinematics (part 1) CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2018

the gamedesigninitiative at cornell university Lecture 12 2D Animation

Kinematics. CS 448D: Character Animation Prof. Vladlen Koltun Stanford University

Quaternions and Rotations

Chapter 9- Animation Basics

6.837 Computer Graphics Hierarchical Modeling Wojciech Matusik, MIT EECS Some slides from BarbCutler & Jaakko Lehtinen

COMP371 COMPUTER GRAPHICS

Final Exam CS 184: Foundations of Computer Graphics! page 1 of 12!

Lecture 18 of 41. Scene Graphs: Rendering Lab 3b: Shader

Spline Control. How to Create the Spline

Motion Control Methods for Skeleton Daniel Thalmann

Walk Cycle with Symbols

Transcription:

Chapter 5.2 Character Animation

Overview Fundamental Concepts Animation Storage Playing Animations Blending Animations Motion Extraction Mesh Deformation Inverse Kinematics Attachments & Collision Detection Conclusions 2

Fundamental Concepts Skeletal Hierarchy The Transform Euler Angles The 3x3 Matrix Quaternions Animation vs Deformation Models and Instances Animation Controls 3

Skeletal Hierarchy The Skeleton is a tree of bones Often flattened to an array in practice Top bone in tree is the root bone May have multiple trees, so multiple roots Each bone has a transform Stored relative to its parent s transform Transforms are animated over time Tree structure is often called a rig 4

The Transform Transform is the term for combined: Translation Rotation Scale Shear Can be represented as 4x3 or 4x4 matrix But usually store as components Non-identity scale and shear are rare Optimize code for common trans+rot case 5

Euler Angles Three rotations about three axes Intuitive meaning of values But Euler Angles Are Evil No standard choice or order of axes Singularity poles with infinite number of representations Interpolation of two rotations is hard Slow to turn into matrices 6

3x3 Matrix Rotation Easy to use Moderately intuitive Large memory size - 9 values Animation systems always low on memory Interpolation is hard Introduces scales and shears Need to re-orthonormalize matrices after 7

Quaternions Represents a rotation around an axis Four values <x,y,z,w> <x,y,z> is axis vector times sin(angle/2) w is cos(angle/2) No singularities But has dual coverage: Q same rotation as Q This is useful in some cases! Interpolation is fast 8

Animation vs Deformation Skeleton + bone transforms = pose Animation changes pose over time Knows nothing about vertices and meshes Done by animation system on CPU Deformation takes a pose, distorts the mesh for rendering Knows nothing about change over time Done by rendering system, often on GPU 9

Model Describes a single type of object Skeleton + rig One per object type Referenced by instances in a scene Usually also includes rendering data Mesh, textures, materials, etc Physics collision hulls, gameplay data, etc 10

Instance A single entity in the game world References a model Holds current position & orientation (and gameplay state health, ammo, etc) Has animations playing on it Stores a list of animation controls 11

Animation Control Links an animation and an instance 1 control = 1 anim playing on 1 instance Holds current data of animation Current time Speed Weight Masks Looping state 12

Animation Storage The Problem Decomposition Keyframes and Linear Interpolation Higher-Order Interpolation The Bezier Curve Non-Uniform Curves Looping 13

Storage The Problem 4x3 matrices, 60 per second is huge 200 bone character = 0.5Mb/sec Consoles have around 32-64Mb Animation system gets maybe 25% PC has more memory But also higher quality requirements 14

Decomposition Decompose 4x3 into components Translation (3 values) Rotation (4 values - quaternion) Scale (3 values) Skew (3 values) Most bones never scale & shear Many only have constant translation Don t store constant values every frame 15

Keyframes Motion is usually smooth Only store every n th frame Store only key frames Linearly interpolate between keyframes Inbetweening or tweening Different anims require different rates Sleeping = low, running = high Choose rate carefully 16

Higher-Order Interpolation Tweening uses linear interpolation Natural motions are not very linear Need lots of segments to approximate well So lots of keyframes Use a smooth curve to approximate Fewer segments for good approximation Fewer control points Bézier curve is very simple curve 17

The Bézier Curve (1-t) 3 F 1 +3t(1-t) 2 T 1 +3t 2 (1-t)T 2 +t 3 F 2 T 2 T 1 t=1.0 F 2 t=0.25 F 1 t=0.0 18

The Bézier Curve (2) Quick to calculate Precise control over end tangents Smooth C0 and C1 continuity are easy to achieve C2 also possible, but not required here Requires three control points per curve (assume F2 is F1 of next segment) Far fewer segments than linear 19

Bézier Variants Store 2F 2 -T 2 instead of T 2 Equals next segment T 1 for smooth curves Store F 1 -T 1 and T 2 -F 2 vectors instead Same trick as above reduces data stored Called a Hermite curve Catmull-Rom curve Passes through all control points 20

Non-Uniform Curves Each segment stores a start time as well Time + control value(s) = knot Segments can be different durations Knots can be placed only where needed Allows perfect discontinuities Fewer knots in smooth parts of animation Add knots to guarantee curve values Transition points between animations Golden poses 21

Looping and Continuity Ensure C0 and C1 for smooth motion At loop points At transition points Walk cycle to run cycle C1 requires both animations are playing at the same speed Reasonable requirement for anim system 22

Playing Animations Global time is game-time Animation is stored in local time Animation starts at local time zero Speed is the ratio between the two Make sure animation system can change speed without changing current local time Usually stored in seconds Or can be in frames - 12, 24, 30, 60 per second 23

Scrubbing Sample an animation at any local time Important ability for games Footstep planting Motion prediction AI action planning Starting a synchronized animation Walk to run transitions at any time Avoid delta-compression storage methods Very hard to scrub or play at variable speed 24

Blending Animations The Lerp Quaternion Blending Methods Multi-way Blending Bone Masks The Masked Lerp Hierarchical Blending 25

The Lerp Foundation of all blending Lerp =Linear interpolation Blends A, B together by a scalar weight lerp (A, B, i) = ia + (1-i)B i is blend weight and usually goes from 0 to 1 Translation, scale, shear lerp are obvious Componentwise lerp Rotations are trickier 26

Quaternion Blending Normalizing lerp (nlerp) Lerp each component Normalize (can often be approximated) Follows shortest path Not constant velocity Multi-way-lerp is easy to do Very simple and fast 27

Quaternion Blending (2) Spherical lerp (slerp) Usual textbook method Follows shortest path Constant velocity Multi-way-lerp is not obvious Moderate cost 28

Quaternion Blending (3) Log-quaternion lerp (exp map) Rather obscure method Does not follow shortest path Constant velocity Multi-way-lerp is easy to do Expensive 29

Quaternion Blending (4) No perfect solution! Each missing one of the features All look identical for small interpolations This is the 99% case Blending very different animations looks bad whichever method you use Multi-way lerping is important So use cheapest - nlerp 30

Multi-way Blending Can use nested lerps lerp (lerp (A, B, i), C, j) But n-1 weights - counterintuitive Order-dependent Weighted sum associates nicely (ia + jb + kc + ) / (i + j + k + ) But no i value can result in 100% A More complex methods Less predictable and intuitive Can be expensive 31

Bone Masks Some animations only affect some bones Wave animation only affects arm Walk affects legs strongly, arms weakly Arms swing unless waving or holding something Bone mask stores weight for each bone Multiplied by animation s overall weight Each bone has a different effective weight Each bone must be blended separately Bone weights are usually static Overall weight changes as character changes animations 32

The Masked Lerp Two-way lerp using weights from a mask Each bone can be lerped differently Mask value of 1 means bone is 100% A Mask value of 0 means bone is 100% B Solves weighted-sum problem (no weight can give 100% A) No simple multi-way equivalent Just a single bone mask, but two animations 33

Hierarchical Blending Combines all styles of blending A tree or directed graph of nodes Each leaf is an animation Each node is a style of blend Blends results of child nodes Construct programmatically at load time Evaluate with identical code each frame Avoids object-specific blending code Nodes with weights of zero not evaluated 34

Motion Extraction Moving the Game Instance Linear Motion Extraction Composite Motion Extraction Variable Delta Extraction The Synthetic Root Bone Animation Without Rendering 35

Moving the Game Instance Game instance is where the game thinks the object (character) is Usually just pos, orientation and bounding box Used for everything except rendering Collision detection Movement It s what the game is! Must move according to animations 36

Linear Motion Extraction Find position on last frame of animation Subtract position on first frame of animation Divide by duration Subtract this motion from animation frames During animation playback, add this delta velocity to instance position Animation is preserved and instance moves Do same for orientation 37

Linear Motion Extraction (2) Only approximates straight-line motion Position in middle of animation is wrong Midpoint of a jump is still on the ground! What if animation is interrupted? Instance will be in the wrong place Incorrect collision detection Purpose of a jump is to jump over things! 38

Composite Motion Extraction Approximates motion with circular arc Pre-processing algorithm finds: Axis of rotation (vector) Speed of rotation (radians/sec) Linear speed along arc (metres/sec) Speed along axis of rotation (metres/sec) e.g. walking up a spiral staircase 39

Composite Motion Extraction (2) Very cheap to evaluate Low storage costs Approximates a lot of motions well Still too simple for some motions Mantling ledges Complex acrobatics Bouncing 40

Variable Delta Extraction Uses root bone motion directly Sample root bone motion each frame Find delta from last frame Apply to instance pos+orn Root bone is ignored when rendering Instance pos+orn is the root bone 41

Variable Delta Extraction (2) Requires sampling the root bone More expensive than CME Can be significant with large worlds Use only if necessary, otherwise use CME Complete control over instance motion Uses existing animation code and data No extraction needed 42

The Synthetic Root Bone All three methods use the root bone But what is the root bone? Where the character thinks they are Defined by animators and coders Does not match any physical bone Can be animated completely independently Therefore, synthetic root bone or SRB 43

The Synthetic Root Bone (2) Acts as point of reference SRB is kept fixed between animations During transitions While blending Often at centre-of-mass at ground level Called the ground shadow But tricky when jumping or climbing no ground! Or at pelvis level Does not rotate during walking, unlike real pelvis Or anywhere else that is convenient 44

Animation Without Rendering Not all objects in the world are visible But all must move according to anims Make sure motion extraction and replay is independent of rendering Must run on all objects at all times Needs to be cheap! Use LME & CME when possible VDA when needed for complex animations 45

Mesh Deformation Find Bones in World Space Find Delta from Rest Pose Deform Vertex Positions Deform Vertex Normals 46

Find Bones in World Space Animation generates a local pose Hierarchy of bones Each relative to immediate parent Start at root Transform each bone by parent bone s worldspace transform Descend tree recursively Now all bones have transforms in world space World pose 47

Find Delta from Rest Pose Mesh is created in a pose Often the da Vinci man pose for humans Called the rest pose Must un-transform by that pose first Then transform by new pose Multiply new pose transforms by inverse of rest pose transforms Inverse of rest pose calculated at mesh load time Gives delta transform for each bone 48

Deform Vertex Positions Deformation usually performed on GPU Delta transforms fed to GPU Usually stored in constant space Vertices each have n bones n is usually 4 4 bone indices 4 bone weights 0-1 Weights must sum to 1 49

Deform Vertex Positions (2) vec3 FinalPosition = {0,0,0}; for ( i = 0; i < 4; i++ ) { int BoneIndex = Vertex.Index[i]; float BoneWeight = Vertex.Weight[i]; FinalPosition += BoneWeight * Vertex.Position * PoseDelta[BoneIndex]); } 50

Deform Vertex Normals Normals are done similarly to positions But use inverse transpose of delta transforms Translations are ignored For pure rotations, inverse(a)=transpose(a) So inverse(transpose(a)) = A For scale or shear, they are different Normals can use fewer bones per vertex Just one or two is common 51

Inverse Kinematics FK & IK Single Bone IK Multi-Bone IK Cyclic Coordinate Descent Two-Bone IK IK by Interpolation 52

FK & IK Most animation is forward kinematics Motion moves down skeletal hierarchy But there are feedback mechanisms Eyes track a fixed object while body moves Foot stays still on ground while walking Hand picks up cup from table This is inverse kinematics Motion moves back up skeletal hierarchy 53

Single Bone IK Orient a bone in given direction Eyeballs Cameras Find desired aim vector Find current aim vector Find rotation from one to the other Cross-product gives axis Dot-product gives angle Transform object by that rotation 54

Multi-Bone IK One bone must get to a target position Bone is called the end effector Can move some or all of its parents May be told which it should move first Move elbow before moving shoulders May be given joint constraints Cannot bend elbow backwards 55

Cyclic Coordinate Descent Simple type of multi-bone IK Iterative Can be slow May not find best solution May not find any solution in complex cases But it is simple and versatile No precalculation or preprocessing needed 56

Cyclic Coordinate Descent (2) Start at end effector Go up skeleton to next joint Move (usually rotate) joint to minimize distance between end effector and target Continue up skeleton one joint at a time If at root bone, start at end effector again Stop when end effector is close enough Or hit iteration count limit 57

Cyclic Coordinate Descent (3) May take a lot of iterations Especially when joints are nearly straight and solution needs them bent e.g. a walking leg bending to go up a step 50 iterations is not uncommon! May not find the right answer Knee can try to bend in strange directions 58

Two-Bone IK Direct method, not iterative Always finds correct solution If one exists Allows simple constraints Knees, elbows Restricted to two rigid bones with a rotation joint between them Knees, elbows! Can be used in a cyclic coordinate descent 59

Two-Bone IK (2) Three joints must stay in user-specified plane e.g. knee may not move sideways Reduces 3D problem to a 2D one Both bones must remain same length Therefore, middle joint is at intersection of two circles Pick nearest solution to current pose Or one solution is disallowed Knees or elbows cannot bend backwards 60

Two-Bone IK (3) Disallowed elbow position Shoulder Wrist Allowed elbow position 61

IK by Interpolation Animator supplies multiple poses Each pose has a reference direction e.g. direction of aim of gun Game has a direction to aim in Blend poses together to achieve it Source poses can be realistic As long as interpolation makes sense Result looks far better than algorithmic IK with simple joint limits 62

IK by Interpolation (2) Result aim point is inexact Blending two poses on complex skeletons does not give linear blend result Can iterate towards correct aim Can tweak aim with algorithmic IK But then need to fix up hands, eyes, head Can get rifle moving through body 63

Attachments e.g. character holding a gun Gun is a separate mesh Attachment is bone in character s skeleton Represents root bone of gun Animate character Transform attachment bone to world space Move gun mesh to that pos+orn 64

Attachments (2) e.g. person is hanging off bridge Attachment point is a bone in hand As with the gun example But here the person moves, not the bridge Find delta from root bone to attachment bone Find world transform of grip point on bridge Multiply by inverse of delta Finds position of root to keep hand gripping 65

Collision Detection Most games just use bounding volume Some need perfect triangle collision Slow to test every triangle every frame Precalculate bounding box of each bone Transform by world pose transform Finds world-space bounding box Test to see if bbox was hit If it did, test the tris this bone influences 66

Conclusions Use quaternions Matrices are too big, Eulers are too evil Memory use for animations is huge Use non-uniform spline curves Ability to scrub anims is important Multiple blending techniques Different methods for different places Blend graph simplifies code 67

Conclusions (2) Motion extraction is tricky but essential Always running on all instances in world Trade off between cheap & accurate Use Synthetic Root Bone for precise control Deformation is really part of rendering Use graphics hardware where possible IK is much more than just IK algorithms Interaction between algorithms is key 68