• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Animation blending and/or layering

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.

6 replies to this topic

Posted 26 March 2012 - 06:09 AM

I can now blend animations together in my engine. For testing I'm just using a simple box with 5 sections with a bone per section.

During my searches for help with animation blending, I came across animation layering as well. I read a gamedev post where haegar wrote up some info on the differences but it was a bit above my head. Could someone please explain the difference between animation blending and animation layering with some easy examples?

My blending gave some interesting results. Animation A bends my box sections in one direction effectively creating a 'C' shape. Animation B twists the box along its length, effectively simulating torsion. Now if I give animation A 90% of the blend and animation B 10%, I get a 90% bend in the 'C' shape and only 10% torsion - just as expected, and it obviously works vice versa.

Now here's the thing, what if I wanted full torsion and full bend? Would that be where animation layering comes in? And how exactly would that work?

At the moment to do the animation blends I convert my matrices to quaternions, nlerp between them quaternions and lerp between the translations and then convert that back to a matrix. Not very efficient I know, but I'll refactor this later.

So looking at this from my game character's requirements, I would like him to have an idle animation, a jog and a run, so this would be a fairly simple blend between idle and jog and then jog and run, but why would I need layering? Would this be for something like running with the bottom half of the character and shooting with the top? (instead of animating arms as they'd be when running).

Thanks for any help or pointers

### #2Ashaman73  Members

Posted 26 March 2012 - 11:18 PM

So looking at this from my game character's requirements, I would like him to have an idle animation, a jog and a run, so this would be a fairly simple blend between idle and jog and then jog and run, but why would I need layering? Would this be for something like running with the bottom half of the character and shooting with the top? (instead of animating arms as they'd be when running).

Yep.

Animation layering is used to blend several layers of animation on top of each other. A simple example would be a character. The first layer could be a walking animation, a second layer could be a shooting animation. Instead of overlaying the second layer just on-top of the walking layer, you can use weights to just blend the animation of the upper-part of body , this is, your character runs while shooting. It is like layering several alpha blended images in photoshop.

Ashaman

Posted 27 March 2012 - 02:24 AM

Thanks for the great explanation, I had a feeling it was that. So in a nutshell:

Animation blending is where all animation 'parts' (e.g. Walk anim, run anim) are pro-rata'd against each other using blend weights which add up to 1.

Animation layering is where you just add animation parts together with a weight for each and I assume it doesn't matter if the combined weight goes over 1, e.g. Layering run and walk would look odd but you can do it

So animation layering is the same as blending just without the combined weight normalisation?

And a use case:

My character is standing idle using the idle animation, breathing, swaying a bit etc. This is obviously just one animation, no blending or layering.

If the user leaves him in that pose for 10 or so seconds, to add a bit of eye candy, he maybe brushes something off his jacket. So I'd have an animation that only affects the top left half of his body, his head, shoulder, arms, etc. playing the idle animation, I can layer the jacket brushing anim over the top? If the jacket brushing anim has a weight of 1 and the top left half of his idle anim has a weight of 1, would that work?

The way I see it is that you'd use blending to fade nicely between animations and layering to combine animations together albeit to different parts of the skeleton.

So in the use case above, would I need to reduce the weight of the top left half of the idle anim down to 0 so the jacket brushing anim slots nicely in or can I just add them? I can't visualise what adding two anims together (making a combined weight of 2) would do - I'm guessing his hand in the jacket brushing anim wouldn't line up correctly with his chest because you've also got the idle anim in there. I guess I could add a priority and set the priority of the jacket brushing to higher than idle and restrict the combined weights to 1 meaning the top left half of the idle anim won't have any effect.

### #4Ashaman73  Members

Posted 27 March 2012 - 05:03 AM

Animation layering is where you just add animation parts together with a weight for each and I assume it doesn't matter if the combined weight goes over 1, e.g. Layering run and walk would look odd but you can do it

Not exactly, layering and blending is more or less technically the same. The weights should always sum up to 1. It is more of an other term for combining animations.

An other example:
You have a walking character with his gun ready. Then he starts running while targeting his gun at an opponent in front of him. In this case we have 4 animations (walk,run,gun ready, gun aiming). We could divide the animation on two tracks or channels (movement and action). When our character starts running, the walk animation will blend over to the run animation, on the other hand, the gun ready animation will blend over to the gun aiming animation. Something like this:
movement_ani = blend_animation(walk,run,alpha)

Alpha and beta are time dependent. Now you need to combine the movement and action animation by laying the action animation on-top of the movement animation with a bone-dependent weight, this is infact blending too.
final_ani = blend_animation(movement_ani, action_ani, bone_dependent_weight)


More advanced approaches are vertex animation overlays (i.e. facial animations not done with bones) or inverse-kinetics (i.e. pointing the characters arm always in the direction of the mouse).

Ashaman

Posted 27 March 2012 - 05:14 AM

Animation layering is where you just add animation parts together with a weight for each and I assume it doesn't matter if the combined weight goes over 1, e.g. Layering run and walk would look odd but you can do it

Not exactly, layering and blending is more or less technically the same. The weights should always sum up to 1. It is more of an other term for combining animations.

An other example:
You have a walking character with his gun ready. Then he starts running while targeting his gun at an opponent in front of him. In this case we have 4 animations (walk,run,gun ready, gun aiming). We could divide the animation on two tracks or channels (movement and action). When our character starts running, the walk animation will blend over to the run animation, on the other hand, the gun ready animation will blend over to the gun aiming animation. Something like this:
movement_ani = blend_animation(walk,run,alpha)

Alpha and beta are time dependent. Now you need to combine the movement and action animation by laying the action animation on-top of the movement animation with a bone-dependent weight, this is infact blending too.
final_ani = blend_animation(movement_ani, action_ani, bone_dependent_weight)


More advanced approaches are vertex animation overlays (i.e. facial animations not done with bones) or inverse-kinetics (i.e. pointing the characters arm always in the direction of the mouse).

I see, so when you do the third blend (the one between the movement and the action anim), you have per bone weights which essentially means the lower body will be fully (or almost fully) weighted towards the movement anim and the upper body will be weighted heavily toward the action anim...?

### #6Ashaman73  Members

Posted 28 March 2012 - 11:54 PM

I see, so when you do the third blend (the one between the movement and the action anim), you have per bone weights which essentially means the lower body will be fully (or almost fully) weighted towards the movement anim and the upper body will be weighted heavily toward the action anim...?

Yep.
Thought this kind of animation technique helps you to reduce the work load of creating animations (good for us hobby/indie developer), it has some disadvantages too. One is, that you really need to "separate" the action-body part from the movement-body part. This is not a major problem for animating a humanoid with a gun, but it is more difficult to animate a humanoid melee fighter (where movement is part of the action) or i.e. a spider (where single body parts can't be assigned to action or movement).

As far as I know, most modern AAA games doesn't combine animation this way and use separate animation for each possible animation piece, linking and blending them in an smart way at run-time and adding some inverse kinetics chains to push the integration into the environment even further.

Before digging into an animation system, first think about what animation are needed and what are your animator resources.

Ashaman