Page MenuHome

NLA: implement a new blending mode that intelligently overlays actions.
ClosedPublic

Authored by Alexander Gavrilov (angavrilov) on Jan 10 2019, 6:24 PM.

Details

Summary

The existing Add and Multiply blending modes have limited usability,
because the appropriate operation for meaningfully combining values
depends on the channel: e.g. add for location, multiply for scale,
and quaternion multiplication for rotations.

This adds a new mode that chooses the operation automatically based
on property settings. Strips with this mode can also be keyframed
normally in Tweak mode, except that the channel value sliders on the
left side of Graph/Action editors won't insert keys without Auto Key.

Supporting a strip blending type that treats quaternions as a unit
also means being able to adjust all sub-channels as a unit when
inserting keyframes. This requires refactoring keyframe insertion
code to retrieve array property values for all channels at once,
before iterating over the indices being inserted.

Diff Detail

Repository
rB Blender

Event Timeline

This is a massive feature for animators. It basically means that layered animation is now fully supported via the NLA, and that you can even properly keyframe items while they are being layered, with the correct offset being applied.

I've tested this with some rigs, and it seems to work correctly.

As for the name of this blend mode, which is called Overlay here, I have a slight preference towards the name 'Layer' rather than 'Overlay' - I simply think it would be slightly clearer what it is for. But that is a minor detail.

This revision is now accepted and ready to land.Jan 10 2019, 8:50 PM

As for the name of this blend mode, which is called Overlay here, I have a slight preference towards the name 'Layer' rather than 'Overlay' - I simply think it would be slightly clearer what it is for. But that is a minor detail.

My logic was mainly that something like 'Combine' is too abstract, and 'Overlay' is an already existing blend mode name for color.

Right, I assumed that was the case. But the image blending type Overlay does something quite different from this blending type. This blending mode is more like 'Do the right blending based on the F-Curve type to make layering work properly' Anyway, I don't think it's much of an issue.

As an aside, I think perhaps we should make this blending mode the default? Or at least the second blending mode in the list? The old Add and Multiply blending types have very limited practical purpose. In the vast majority of cases, either Replace or this new Overlay blending what you'd want to use. Add or Multiply fail to work with even the most basic of cases such as transforming a cube.

I wonder if @Brecht Van Lommel (brecht) or @Campbell Barton (campbellbarton) have any opinion on naming.

Also, maybe @Campbell Barton (campbellbarton) can comment on the conceptual validity of using PROP_QUATERNION, PROP_AXISANGLE and PROP_PROPORTIONAL to determine blending from the RNA design perspective?

I thought all rotation types would use quaternion blending? Isn't that required to get good results for Euler and axis-angle values?

Is there a plan for Replace to also use quaternion blending when influence < 1?

For the name, it seems like replace is for mixing animation and this new blend mode is for adding animation? So perhaps they could be named Mix and Add, both using quaternion blending. The other (legacy)? blend modes could be presented under a separate label in the enum menu. Not sure what the right name for them would be, "per-component" "individual add", "legacy", ... ? Something to make clear that they are a special type of blend mode that is not the first thing you should try using.

Using PROP_QUATERNION and PROP_AXISANGLE is fine. PROP_PROPORTIONAL is a bit weak since it is used for both scale and size type properties, and multiply only makes sense for scale. Maybe we need a new PROP_SCALE subtype which implies PROP_PROPORTIONAL?

source/blender/blenkernel/intern/anim_sys.c
2487

This should check for division by zero?

I thought all rotation types would use quaternion blending? Isn't that required to get good results for Euler and axis-angle values?

Obviously only quaternions use quaternion multiplication. No conversion is attempted and I don't think it would work that well.

Is there a plan for Replace to also use quaternion blending when influence < 1?

There is no point, because linear interpolation of quaternions works reasonably well.

For the name, it seems like replace is for mixing animation and this new blend mode is for adding animation? So perhaps they could be named Mix and Add, both using quaternion blending. The other (legacy)? blend modes could be presented under a separate label in the enum menu. Not sure what the right name for them would be, "per-component" "individual add", "legacy", ... ? Something to make clear that they are a special type of blend mode that is not the first thing you should try using.

Replace is for replacing the result of the previous layers, there is nothing wrong with that name. The two modes basically allow you to either override a different animation, or stack on top of it using the appropriate math operation for combining each channel.

Using PROP_QUATERNION and PROP_AXISANGLE is fine. PROP_PROPORTIONAL is a bit weak since it is used for both scale and size type properties, and multiply only makes sense for scale. Maybe we need a new PROP_SCALE subtype which implies PROP_PROPORTIONAL?

Multiplication makes sense for any non-negative property that is connected to scale. Default values not being 0 or 1 doesn't matter, because the formula actually accounts for them - it's along the lines of "result = prev + (cur - default) * influence" and "result = prev * (cur / default)^influence".

Alexander Gavrilov (angavrilov) marked an inline comment as done.Jan 11 2019, 2:19 PM
Alexander Gavrilov (angavrilov) added inline comments.
source/blender/blenkernel/intern/anim_sys.c
2487

nlaevalchan_get_default_values should be ensuring it's not 0.

Obviously only quaternions use quaternion multiplication. No conversion is attempted and I don't think it would work that well.

I can see automatic conversion could be problematic for inserting keyframes or constraint evaluation.

Most animators are using Euler as far as I know. I do wonder if you can reliably mix or stack such animations without better rotation blending. Maybe it's fine in practice, or a different type of use case that this patch is not trying to handle.

There is no point, because linear interpolation of quaternions works reasonably well.

Agreed it works ok for quaternion properties. This would mostly make sense for Euler or Axis-Angle if they were using quaternion blending.

Replace is for replacing the result of the previous layers, there is nothing wrong with that name. The two modes basically allow you to either override a different animation, or stack on top of it using the appropriate math operation for combining each channel.

Ok, I don't care too much about Mix vs. Replace. Mainly I think the legacy modes should be moved out of the way to not confuse things.

If we want to follow conventions, in Maya, Motionbuilder and Unity the blending modes are called Override and Additive.

Multiplication makes sense for any non-negative property that is connected to scale. Default values not being 0 or 1 doesn't matter, because the formula actually accounts for them - it's along the lines of "result = prev + (cur - default) * influence" and "result = prev * (cur / default)^influence".

Ok, makes sense.

How about:

Replace -> Override
Overlay -> Combine

This is a bit more standard, but still keeps a clear difference between Combine and Add.

We could still keep Add and Multiply in that same menu, although again, they have very little practical purpose, at lease for transforms (and thus any type of character animation). Perhaps they are good to keep for mixing non-transform curves.

Renamed to Combine, plus some tweaks.

Looks good to me now.

Regarding interpolation, maybe there are two somewhat different use cases?

If you think of it more like a game engine or cheap background character animation where you blend and combine existing animation clips, then I think you would expect to get quaternion interpolation. You don't care about the underlying values but just want something that makes sense visually.

On the other hand you could use this for manually animating a shot, splitting up different components of the animation, trying some variations, make some part of the animation more subtle/extreme, etc. In that case you might want the values to be blended in a way that's very simple and predictable.

This revision was automatically updated to reflect the committed changes.