CSCE 552 Fall 2012 Animations By Jijun Tang. Animation terms  frame – an image that is displayed on the screen, usually as part of a sequence.  pose.

Slides:



Advertisements
Similar presentations
Animation in Video Games presented by Jason Gregory
Advertisements

Blending & State Machines CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
INNER WORKINGS OF UNITY 3D. WHAT WE ARE GOING TO COVER Intro to Unity Physics & Game Objects Cameras & Lighting Textures & Materials Quaternions and Rotation.
Verbs and Adverbs: Multidimensional Motion Interpolation Using Radial Basis Functions Presented by Sean Jellish Charles Rose Michael F. Cohen Bobby Bodenheimer.
Animation Following “Advanced Animation and Rendering Techniques” (chapter 15+16) By Agata Przybyszewska.
Chapter 5.2 Character Animation. 2 Overview Fundamental Concepts Animation Storage Playing Animations Blending Animations Motion Extraction Mesh Deformation.
3D Graphics for Game Programming (J. Han) Chapter XI Character Animation.
1Notes  Assignment 0 marks should be ready by tonight (hand back in class on Monday)
Orientation & Quaternions
CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS.
Spatial Descriptions and Transformations Introduction to Motion
3D orientation.
CSCE 590E Spring 2007 Graphics I By Jijun Tang. Announcements Second presentation will be held on April 16 th and 18 th  April 16 th : Space Banditos,
CSCE 441: Computer Graphics Rotation Representation and Interpolation
Quaternions CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.
Graphics Presented by Shuang Li. 2 Overview  Fundamentals  High-Level Organization  Rendering Primitives  Textures  Lighting  The Hardware Rendering.
Midterm Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2004.
CSCE 590E Spring 2007 Animation By Jijun Tang. Rendering Primitives Strips, Lists, Fans Indexed Primitives The Vertex Cache Quads and Point Sprites.
CSE 473 Dr. Charles B. Owen Fundamentals of 3D Game Development1 Skeletons and Skinning Bones and Skeletons Mesh Skinning.
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Beyond Meshes Spring 2012.
Hierarchical Transformations Hierarchical Models Scene Graphs
Chapter 5.2 Character Animation. CS Overview Fundamental Concepts Animation Storage Playing Animations Blending Animations Motion Extraction Mesh.
Visualizing Orientation using Quaternions Gideon Ariel; Rudolf Buijs; Ann Penny; Sun Chung.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
CS 450: COMPUTER GRAPHICS QUATERNIONS SPRING 2015 DR. MICHAEL J. REALE.
CSE 381 – Advanced Game Programming Basic 3D Graphics
Week 2 - Wednesday CS361.
Geometric Transforms Changing coordinate systems.
CSCE 552 Fall D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and point.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
Computer Graphics 2 In the name of God. Outline Introduction Animation The most important senior groups Animation techniques Summary Walking, running,…examples.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
Geometric Objects and Transformation
Maths & Technologies for Games Animation: Practicalities CO3303 Week 3.
CSE 381 – Advanced Game Programming Animation Systems Jack Skellington, from The Nightmare Before Christmas.
CSCE 552 Spring D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
CSCE 552 Spring 2009 Animation By Jijun Tang. Inverse of 4x4.
Skeletal Animation and Skinning A (hardware friendly) software approach By: Brandon Furtwangler.
CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai.
CSCE 441: Keyframe Animation/Smooth Curves (Cont.) Jinxiang Chai.
CS 450: Computer Graphics PARAMETRIC SPLINES AND SURFACES
Basic Theory (for curve 01). 1.1 Points and Vectors  Real life methods for constructing curves and surfaces often start with points and vectors, which.
Computer Graphics I, Fall 2010 Transformations.
Animation Animation is about bringing things to life Technically: –Generate a sequence of images that, when played one after the other, make things move.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Advanced Math.
CGDD 4003 Character Animation. The Skeletal Hierarchy (aka the “rig”) Based on the concept of bones Each bone has exactly one parent Each bone has a transform.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Game Engine Architecture
CSCE 552 Spring 2010 Animation By Jijun Tang.
- Introduction - Graphics Pipeline
CSCE 552 Fall 2012 Animations By Jijun Tang.
CSCE 552 Spring 2010 Animation By Jijun Tang.
CS451Real-time Rendering Pipeline
© University of Wisconsin, CS559 Spring 2004
Skeletons and Skinning
Computer Animation and Visualisation Lecture 4. Skinning
Chapter 5.2 Character Animation
UMBC Graphics for Games
UMBC Graphics for Games
UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN
Emerging Technologies for Games Review & Revision Strategy
Presentation transcript:

CSCE 552 Fall 2012 Animations By Jijun Tang

Animation terms  frame – an image that is displayed on the screen, usually as part of a sequence.  pose – an orientation of an objects or a hierarchy of objects that defines extreme or important motion.  keyframe – a special frame that contains a pose.  tween – the process of going “between” keyframes.  secondary motion – an object motion that is the result of its connection or relationship with another object.

Example

Homogeneous coordinates Four-dimensional space Combines 3  3 matrix and translation into one 4  4 matrix

Euler Angles Three rotations about three axes Intuitive meaning of values

Rotation Matrix

3x3 Matrix Rotation Easy to use Moderately intuitive Large memory size - 9 values Interpolation is hard  Introduces scales and shears  Need to re-orthonormalize matrices after

Quaternions Quaternions are an interesting mathematical concept with a deep relationship with the foundations of algebra and number theory Invented by W.R.Hamilton in 1843 In practice, they are most useful to use as a means of representing orientations A quaternion has 4 components

Quaternions on Rotation Represents a rotation around an axis Four values is axis vector times sin(θ /2) w is cos(θ/2) Interpolation is fast

Illustration

Quaternions (Imaginary Space) Quaternions are actually an extension to complex numbers Of the 4 components, one is a ‘real’ scalar number, and the other 3 form a vector in imaginary ijk space!

Quaternions (Scalar/Vector) Sometimes, they are written as the combination of a scalar value s and a vector value v where

Unit Quaternions For convenience, we will use only unit length quaternions, as they will be sufficient for our purposes and make things a little easier These correspond to the set of vectors that form the ‘surface’ of a 4D hypersphere of radius 1 The ‘surface’ is actually a 3D volume in 4D space, but it can sometimes be visualized as an extension to the concept of a 2D surface on a 3D sphere

Quaternions as Rotations A quaternion can represent a rotation by an angle θ around a unit axis a: If a is unit length, then q will be also

Quaternions as Rotations

Quaternion to Matrix To convert a quaternion to a rotation matrix:

Pose

Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and point sprites) Three points define a plane Triangle plane is mapped with data  Textures  Colors “Rasterized” to find pixels to draw

Mesh

Vertices A vertex is a point in space Plus other attribute data  Colors  Surface normal  Texture coordinates  Whatever data shader programs need Triangles use three vertices  Vertices shared between adjacent triangles

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

Instance A single entity in the game world References a model Holds current states:  Position & orientation  Game play state – health, ammo, etc Has animations playing on it  Stores a list of animation controls  Need to be interpolated

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

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

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

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 But human characters may have higher requirement  Muscle move, smiling, etc.  Cloth under winds Don’t store constant values every frame, use index instead

Keyframes Motion is usually smooth Only store every n th frame (key frames) Interpolate between keyframes  Linear Interpolate  Inbetweening or “tweening” Different anims require different rates  Sleeping = low, running = high  Choose rate carefully

Linear Interpolation

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

B é zier Curves (2D & 3D) B é zier curves can be thought of as a higher order extension of linear interpolation p0p0 p1p1 p0p0 p1p1 p2p2 p0p0 p1p1 p2p2 p3p3

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=0.25 F1F1 T1T1 T2T2 F2F2 t=1.0 t=0.0

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

C0/C1/C2 The curves meet the tangents are shared the"speed" is the same before and after

Catmull-Rom Curve Defined by 4 points. Curve passes through middle 2 points. P = C 3 t 3 + C 2 t 2 + C 1 t + C 0 C 3 = -0.5 * P * P * P * P 3 C 2 = P * P * P * P 3 C 1 = -0.5 * P * P 2 C 0 = P 1

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

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

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

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

Delta Compression Delta compression is a way of storing or transmitting data in the form of differences between sequential data rather than complete files. The differences are recorded in discrete files called deltas or diffs. Because changes are often small (only 2% total size on average), it can greatly reduce data redundancy. Collections of unique deltas are substantially more space-efficient than their non-encoded equivalents.

Animation Blending The animation blending system allows a model to play more than one animation sequence at a time, while seamlessly blending the sequences Used to create sophisticated, life-like behavior  Walking and smiling  Running and shooting

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

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 – normalized quaternions is usually the best method.

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 Many others:  Spherical lerp (slerp)  Log-quaternion lerp (exp map)

Which is the Best 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

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

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

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

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

Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and point sprites) Three points define a plane Triangle plane is mapped with data  Textures  Colors “Rasterized” to find pixels to draw

Mesh

Vertices A vertex is a point in space Plus other attribute data  Colors  Surface normal  Texture coordinates  Whatever data shader programs need Triangles use three vertices  Vertices shared between adjacent triangles

Textures Array of texels  Same as pixel, but for a texture  Nominally R,G,B,A but can mean anything 1D, 2D, 3D and “cube map” arrays  2D is by far the most common  Basically just a 2D image bitmap  Often square and power-of-2 in size Cube map - six 2D arrays makes hollow cube  Approximates a hollow sphere of texels  For environmental

Cube Map

Texture Example

High-Level Organization Gameplay and Rendering Render Objects Render Instances Meshes Skeletons Volume Partitioning

Gameplay and Rendering Rendering speed varies according to scene  Some scenes more complex than others  Typically frames per second Gameplay is constant speed  Camera view should not change game  In multiplayer, each person has a different view, but there is only one shared game  1 update per second (RTS) to thousands (FPS) Keep the two as separate as possible!

Render Objects Description of renderable object type Mesh data (triangles, vertices) Material data (shaders, textures, etc) Skeleton (+rig) for animation Shared by multiple instances

Render Instances A single entity in a world References a render object  Decides what the object looks like Position and orientation Lighting state Animation state

Meshes Triangles Vertices Single material “Atomic unit of rendering”  Not quite atomic, depending on hardware Single object may have multiple meshes  Each with different shaders, textures, etc  Level-Of-Distance (LOD)

LOD Objects have different mesh for different distance from the player The mesh should be simpler if object is faraway Many games have LOD, for example, Microsoft Train Simulator

Example (40m, poly)

Example (120m, 3900 poly)