Jump to content

  • Log In with Google      Sign In   
  • Create Account


Animation keyframes


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 ill   Members   -  Reputation: 320

Like
0Likes
Like

Posted 30 October 2012 - 05:02 PM

So if you look at a format like md5, the animations have data about a huge number of keyframes, and it linearly interpolates between the keyframes in game. This creates a huge amount of data that needs to be loaded.

I was also looking at fbx and this stores much less keyframes. If you use some modeling program and set up about 5 keyframes on the bones it looks like it cubically interpolates between them over a long animation. If this animation was exported to md5 though, it'd generate all of the in between keyframes and have the game linearly interpolate between them. I could go from storing 5 keyframes to like 250.

Is there a reason to convert an animation with a small number of keyframes to a format that has many more? My guesses so far is that linear interpolation is much faster. Also it could be that the more complex animations, especially the ones that are motion captured, would effectively have a huge amount of keyframes anyway. The doom 3 animations definitely look very complex and full of constantly changing motion.

Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 12819

Like
1Likes
Like

Posted 30 October 2012 - 06:29 PM

Linear interpolation is the fastest of interpolations, but if accuracy is desired it requires much more storage space, both at run-time and on disk.

A compromise would be to start out with all 250 example key frames and eliminate redundant key frames.
This is fairly trivial to do.
Start with key frames 0 and 2 and linearly interpolate between them.
If the result is reasonably close to the value of key frame 1, eliminate key frame 1.
Repeat with key frame 1 and 3, checking to see if 2 can be eliminated.
When you reach a point where you can’t eliminate a key frame, repeat the whole process from that key frame.
For example if 2 cannot be eliminated, restart the process with key frames 2 and 4, checking for 3’s elimination.

You can adjust the accuracy tolerance to eliminate more key frames at the cost of playback accuracy, but you generally won’t be able to notice any inaccuracies at run-time unless they are huge.


L. Spiro

Edited by L. Spiro, 30 October 2012 - 06:31 PM.

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 mhagain   Crossbones+   -  Reputation: 7579

Like
1Likes
Like

Posted 30 October 2012 - 06:51 PM

Keyframe interpolation can be done entirely on the GPU without needing to re-up any vertex data at runtime, and is even reasonably friendly for instancing - if you're drawing 10s or 100s of the same model then there's a good chance that many of them will share the same pair of keyframes (perhaps with the order flipped, in which case use 1 - blendweight). Per-model data can be as low as a single transformation matrix (or even just position xyz if it doesn't need to rotate), a blend weight and maybe some colour/lighting info. Set 3 vertex streams - one for keyframe 1, one for keyframe 2, one for shared data (like texcoords), then issue a draw call - done.

In that sense it's still a viable technology for many model types. Not everything needs the full animation possibilities of a character or opponent, and simpler models can be quite reasonably handled with keyframes. If you're happy to eat the extra memory requirement (which - depending on the simplicity of the model - may not actually be overly onerous and may be hugely outweighed by the perf benefits) then it may be a great choice for certain classes of scene decoration objects.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#4 Lauris Kaplinski   Members   -  Reputation: 841

Like
0Likes
Like

Posted 31 October 2012 - 03:56 PM

They probably wanted to keep the MD5 format simple.

I think most modeling programs allow you to use cubic bezier paths to define interpolation between keyframes. This makes it possible to have very small number of keyframes even for complex animations. But those keyframes/interpolations are usually defined for IK targets during animation and (at least for Blender) will be resampled to many keyframes with linear interpolation while converting animations to FK skeleton.

You can compact your animations to cubic or quadratic bezier interpolation, thus significantly reducing the number of keyframes but it requires a method to find local minima of arbitrary functions (some serious math). Or some optimization library (like LM).
Lauris Kaplinski

First technology demo of my game Shinya is out: http://lauris.kaplinski.com/shinya
Khayyam 3D - a freeware poser and scene builder application: http://khayyam.kaplinski.com/

#5 ill   Members   -  Reputation: 320

Like
0Likes
Like

Posted 31 October 2012 - 05:40 PM

So right now it sounds like just linear interpolations may be the way to go after all. I was looking at some code for cubic interpolation and it looks a bit heavy. Also if this worked for Doom 3 in the year 2004, it's probably fine and not something that will cause huge performance issues today.

#6 Lauris Kaplinski   Members   -  Reputation: 841

Like
0Likes
Like

Posted 01 November 2012 - 02:51 AM

So right now it sounds like just linear interpolations may be the way to go after all. I was looking at some code for cubic interpolation and it looks a bit heavy. Also if this worked for Doom 3 in the year 2004, it's probably fine and not something that will cause huge performance issues today.


It will be storage issue, not performance issue. High-quality animations take a lot of space and thus the compression of keyframes is important.

But this probably is no-issue for most indie games where people do not have a budget for massive amount of scripted animations anyways...
Lauris Kaplinski

First technology demo of my game Shinya is out: http://lauris.kaplinski.com/shinya
Khayyam 3D - a freeware poser and scene builder application: http://khayyam.kaplinski.com/




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS