1 / 13

Maths and Technologies for Games Animation: Interpolation

Maths and Technologies for Games Animation: Interpolation. CO3303 Week 2. Interpolation for Animation. Given two transforms for a model, we can calculate the transforms in between the two: This is called interpolation Animation is stored as a sequence of key frames (transforms).

Download Presentation

Maths and Technologies for Games Animation: Interpolation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Maths and Technologies for GamesAnimation: Interpolation CO3303 Week 2

  2. Interpolation for Animation • Given two transforms for a model, we can calculate the transforms in between the two: • This is called interpolation • Animation is stored as a sequence of key frames (transforms) • To get frames between the key frames, we use interpolation • For example a rotating arm has 2 key frames stored • One at the start of rotation (T1), one at the end (T2) • Calculate (don’t store) frames in between with interpolation

  3. Previous Interpolation • We have interpolated between elements before: • Alpha blending – source and destination colours • Skinning – the effects of multiple bones • We used Linear Interpolation each time: • Alpha blending: Dest.R = Source.A * Source.R + (1-Source.A) * Dest.R • Skinning (with two bones) • Do you see a pattern? • N.B. Details for this section in Van Verth

  4. Linear Interpolation (Lerp) • General linear interpolation between two mathematical elements P0 and P1 takes the form: • Typically t is in the range [0,1] - note that: • The parameter t selects a element P(t) in between the start and end elements P0 and P1 • If P0 & P1 are points, then P(t) will be on the line between them: • Hence linear interpolation

  5. Linear Interpolation of Transforms • A transformation is typically made up of a position, a rotation and a scaling component • Can be stored in several ways, e.g. • Position: vector / scalars (x,y,z) or a matrix • Rotation: Euler angles, a matrix or a quaternion • Scaling: vector / scalars or a matrix • Can have a single combined matrix for everything • We will consider the effect of linear interpolation on each of the components separately • Then consider how this affects our storage choice

  6. Linear Interpolation of Position • Linear interpolation applied to key-frame positions will give sensible in-between positions: • With several key-frames we get piecewise linear interpolation • Motion between points has sharp changes in direction: • May prefer smoother motion and we can use higher order interpolations to do this • But linear interpolation works and will suffice for now Piecewise Linear Interpolation Higher Order Interpolation

  7. Linear Interpolation of Scaling • Scaling can also be interpolated linearly: • Works fine for one pair of key-frames • Again, linear interpolation over many frames will cause scaling rate to change sharply at each key-frame: • The speed of shrinking/expanding changes suddenly • Generally a less noticeable effect • Again, possible to calculate smoother result with higher order interpolation

  8. Linear Interpolation of Rotation • Can apply linear interpolation to rotations if they are in matrix or quaternion form: • Ineffective with Euler angles • Unlike position and scale, the result is not correct • Even with just one pair of key-frames • The tips of the rotated vectors are interpolated • Resulting in an unwanted scaling • Incorrect angles – want quarter steps, but here α ≠ β

  9. Normalised Lerp (Nlerp) • Can normalise the rotations to remove the scaling effect • Still have inaccurate angles • Normalising quaternions is trivial • Gram-Schmidt orthogonalisation used to normalise matrices (see Van Verth early chapter) • Allows us to use linear interpolation of rotations • If the overall rotation is small enough • Otherwise we need linear interpolation of the angles

  10. Spherical Lerp (Slerp) • Linear interpolation of angles is same as linear interpolation of an arc on a sphere • So this technique is called spherical linear interpolation or slerp • The formula is different from linear interpolation: • As before – take a start and end rotation (P,Q), and a value t from [0,1] • Formula calculates the correct interpolated rotation

  11. Slerp for Matrices • We can apply the slerp formula if P, Q are matrices • Matrix multiplication / inverse are understood • But how to calculate a matrix raised to a power? • i.e. Mt • Need to convert the matrix to axis-angle format, then calculate θt, then convert back • Very expensive • More than 100 operations

  12. Slerp for Quaternions • Can show that slerp for quaternions is: • Expensive, mainly because of the sin functions • But sin θcan be precalculated • It’s constant for any pair of key frames • Has potential accuracy problems for small θ • However, more usable than the matrix version

  13. Interpolation Summary • We want to interpolate between two key frames • Can use simple linear interpolation (lerp) for the position and scaling • For rotation, consider angle between the frames: • Can often use lerp on rotations & normalise the result • For large angles, use slerp • In any case store rotations as quaternions if you intend to interpolate them • Matrices expensive to interpolate, Eulaer angles ineffective • Note: there are some newer methods to approximate or avoid slerp

More Related