370 likes | 540 Views
Lecture 08: Animation. COMP 175: Computer Graphics March 4, 2014. Topics in Animation. Physics (dynamics, simulation, mechanics) Particles Rigid bodies (collisions, contact, etc.) Articulated bodies (constraints, robotics) Deformable bodies (fracture, cloth, elastic materials)
E N D
Lecture 08:Animation COMP 175: Computer Graphics March 4, 2014
Topics in Animation • Physics (dynamics, simulation, mechanics) • Particles • Rigid bodies (collisions, contact, etc.) • Articulated bodies (constraints, robotics) • Deformable bodies (fracture, cloth, elastic materials) • Natural phenomenon (fluid, water, fire, etc.) • Character dynamics (motion, skin, muscle, hair, etc.) • Character Animation • Motion capture • Motion synthesis (locomotion, IK, procedural motion, retargeting) • Motion playback • Artificial Intelligence • Behavioral animation • Simulation of crowds (flocks, herds, crowds) • Video game agents • Camera control
Key Framing • Traditionally used in cel animation • Animator specifies the positions and orientations at various key points • In between frames are then interpolated. • This used to be done by hand • Now this is mostly done by computers • John Lasseter, SIGGRAPH 87, “Principles of Traditional Animation Applied to 3D Computer Graphics”
Interpolating Key Frames • Splines are typically used to interpolate the positions of objects
Splines • The easiest spline to use is the cubic spline. • As the name suggests, cubic means an equation with a power of 3, which also means that we need 4 numbers to define the equation • E.g., for a linear curve, y = ax + b, there are two unknowns (a and b), so we need two sets of equations. For quadratic function, y = ax^2 + bx + c, we will need three sets of equations, etc. • With key framing, how do we get a “smooth” curve between any two points?
Cubic Splines • General form of a cubic spline: • q(t) = a + bt * ct^2 + dt^3 • q’(t) = b + 2ct + 3dt^2 • Given: • q(0) = S (starting point) • q’(0) = Vs (velocity at point S) • q(1) = G (goal point) • q’(1) = Vg (velocity at end point G)
Cubic Spline • Plug in the numbers: • q(0) = a + b(0) + c(0) + d(0) = S • => a = S • q’(0) = b + 2c(0) + 3d(0) = Vs • => b = Vs • Two remaining variables (c, d), two equations. Solve for c and d: • q(1) = a + b(1) + c(1) + d(1) = G • q’(1) = b + 2c + 3d = Vg
Cubic Spline • Plug in a = S, and b = Vs • q(1) = S + Vs + c + d = G ---- (eq1) • q’(1) = Vs + 2c + 3d = Vg ---- (eq2) • Solve for c first, (eq1)*3 – (eq2) • => c = -3S + 3G – 2Vs – 2Vg • Solve for d, (eq2) – ((eq1) * 2) • => d = 2S – 2G + Vs + Vg
Cubic Spline • Putting it all together: • q(t) = ( 1S + 0G + 0Vs + 0Vg) + ( 0S + 0G + 1Vs + 0Vg) * t + (-3S + 3G - 2Vs - 1Vg) * t * t + ( 2S - 2G + 1Vs + 1Vg) * t * t * t • Test this by plugging in t = 0 and t = 1
Splines in 3D • Note that the above equation solves for the cubic spline in one dimension, but you can generalize it to 3D. • This is because that since x, y, and z or orthogonal, we can compute the forces to x, y, and z independently.
Generalized Motion • Animators in the past didn’t have access to computers, so they had to “simulate” what our eyes see when perceiving motion. • These are known as stretch and squash
How to Obtain the Key Frames? • Generating key frames continues to be an important question for animator because different effects require different techniques
Key Framing in Character Animation • Skeletons and Skinning • Skeletons: a collection of bones (rigid bodies) and joints • Skinning: associating each point of the mesh to an affine combination of bone/joint locations • Real-time deformation by applying skinning weights to deformed skeleton
Skeletal Animation • Popular in movies / games and supported by a wide range of software such as Maya, 3D Max.
Kinematics • Forward Kinematics: • “Given a set of joint angles, what is the x,y,z position of my hand?” • Inverse Kinematics: • “Given the position of my hand, what is the pose (joint angles) of my character?” • Note that the solution might not be unique
Simple IK • In a simple case: that is, • 2D, • two links, • 1 fixed joint (can rotate by can’t move), and • 1 regular joint • We can solve for theta_knee using cos-1 because we know the length of link1 and link2. • Given theta_knee, we can find beta
Complex IK • In more complex cases that involves multiple (hierarchical) joints, the problem is much more difficult. • Again, this is partially because the solution space could be empty, or it could be large (i.e., solutions are not unique) • The common solution is to use an iterative approximation algorithm (such as gradient descent, simulated annealing, etc.)
A Quick Reference to Gradient Descend • The general idea behind gradient descend method is based on the assumption that: • Given a function f, you can quickly compute f(x) in g • However, it is not easy to directly compute g(x) • In addition, there’s an “error function” that tells you how “wrong” you are (and sometimes in what directionality the error is – that is, the gradient) • So, gradient descent becomes iterative in that: • The algorithm takes a random guess on x • Given the error feedback, compute a delta_x • Then compute f(x + delta_x) • And so on
Inverse Kinematics • Given an articulated figure, there are often constraints to the joints (e.g., how far they can bend) • The iterative approach can integrate these constraints when looking for the solution x
Motion Capture • Different technologies, but roughly categorized into two groups: • Passive: passive systems are usually camera based. This means that an actor would wear reflective markers on a body suit, and cameras would capture and compute depth information. The benefits are that it’s easy to set up; can scale up to multiple actors; can be used on anything (such as faces or non-human actors). Downsides are: noise, occlusion, cost (in hardware and software), fixed environment (in the lab) • Active: active systems do direct measurements of the joint angles. These include skeletal suits or flexors to measure forces.The benefits are almost exactly the opposite of the passive systems
Hybrid • “Practical Motion Capture in Everyday Surroundings” by Vlasic et al., SIGGRAPH 07
Motion Graphs • Motion capture labs are still largely very expensive to set up (depth cameras could cost hundreds of thousands) • One approach to cut down the cost is to capture “snippets” of motions. For example, for a walk cycle, a gesture, etc. • Given a sufficiently large motion library, one can generate a plausible motion graph by stitching these motion snippets together • The “easy” challenge is in blending the motions to hide the seams • The “hard” challenge is to model intent
Motion Graph • How would you blend motions?
Motion Retargeting • The idea of motion map sounds great, but there are still some big issues: • Motion captured data only works on a 3D model of the exact same (real) person. • For example, think about how an infant (toddler, and troll) walks differently because of differences in body part proportions (http://research.cs.wisc.edu/graphics/Gallery/Retarget/final_render.htm) • And can we apply walking motion to, say, the Pixar Lamp? (Semantic Deformation Transfer -- http://www.mit.edu/~ibaran/sdt/)
Motion Synthesis • In addition to the retargeting issue, there is also the problem of “coverage”. Namely, what happens if there is a missing chunk of animation that you need but it isn’t in the library/database? • http://www.cs.cmu.edu/~aw/pdf/spacetime.pdf • http://www.cs.cmu.edu/~aw/mpg/luxo.mpg • http://graphics.cs.cmu.edu/nsp/papers/sig97.pdf • http://graphics.cs.cmu.edu/nsp/projects/spacetime/spacetime.html
Perception of Motion • “Plausible Motion Simulation for Computer Graphics Animation”, Barzel et al., SIGGRAPH 96 • http://www.ronenbarzel.org/papers/plausible/ • “Perceptual Metrics for Character Animation”, Reitsma et all, SIGGRAPH 02 • http://graphics.cs.cmu.edu/nsp/projects/perception/perception.html
Generalized Motion • The motion of any dynamic system can be described with the following equation: • = generalized forces • = generalized positions • = generalized velocities • = generalized accelerations • = mass or inertia coefficients • = gravity and velocity contributions to Q (e.g., centrifugal and coriolis forces)
Generalized Motion • This is kind of a fancy way of saying f = ma, but still has the problem of needing to work with the linear forces and the rotational forces (torque) separately. • Thankfully, we can put the two together in one package in matrix form.
Generalized Forces • Where: • = force, a vector in • = mass of the body • = mass matrix (a 3x3 matrix), scalar m times the 3x3 identity matrix • = inertia tensor of a body (a 3x3 matrix) • = gravity, a vector in • = linear acceleration of the body, a vector in • = angular velocity of the body, a vector in • = angular acceleration of the body, a vector in
Going back to the Generalized Form • Using the original (generalized form), this means that:
Example • In this example, • , and • But the other terms, and are much more complicated. • See additional handout for more detail
Physically Based Simulation • Rigid Bodies • Fast collision detection • Transference of forces • Fast computation for large number of objects • Deformable Bodies • Natural phenomenon • http://physbam.stanford.edu/~fedkiw/ • http://www.youtube.com/watch?v=nJWz0PaMlkI
Last Word • Remco’s Master’s thesis…