Implement additive blending for animation graphs.#15631
Merged
mockersf merged 4 commits intobevyengine:mainfrom Oct 4, 2024
Merged
Implement additive blending for animation graphs.#15631mockersf merged 4 commits intobevyengine:mainfrom
mockersf merged 4 commits intobevyengine:mainfrom
Conversation
*Additive blending* is an ubiquitous feature in game engines that allows animations to be concatenated instead of blended. The canonical use case is to allow a character to hold a weapon while performing arbitrary poses. For example, if you had a character that needed to be able to walk or run while attacking with a weapon, the typical workflow is to have an additive blend node that combines walking and running animation clips with an animation clip of one of the limbs performing a weapon attack animation. This commit adds support for additive blending to Bevy. It builds on top of the flexible infrastructure in bevyengine#15589 and introduces a new type of node, the *add node*. Like blend nodes, add nodes combine the animations of their children according to their weights. Unlike blend nodes, however, add nodes don't normalize the weights to 1.0. The `animation_masks` example has been overhauled to demonstrate the use of additive blending in combination with masks. There are now controls to choose an animation clip for every limb of the fox individually. This patch also fixes a bug whereby masks were incorrectly accumulated with `insert()` during the graph threading phase, which could cause corruption of computed masks in some cases. Note that the `clip` field has been replaced with an `AnimationNodeType` enum, which breaks `animgraph.ron` files. The `Fox.animgraph.ron` asset has been updated to the new format. Closes bevyengine#14395.
Contributor
Author
|
r? @aecsocket |
mweatherley
suggested changes
Oct 4, 2024
Contributor
mweatherley
left a comment
There was a problem hiding this comment.
Looks great overall. Just the one thing.
mweatherley
approved these changes
Oct 4, 2024
Contributor
Contributor
Author
|
I never really considered that, but I think that's correct? |
mockersf
approved these changes
Oct 4, 2024
7 tasks
Member
|
Thank you to everyone involved with the authoring or reviewing of this PR! This work is relatively important and needs release notes! Head over to bevyengine/bevy-website#1715 if you'd like to help out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Additive blending is an ubiquitous feature in game engines that allows animations to be concatenated instead of blended. The canonical use case is to allow a character to hold a weapon while performing arbitrary poses. For example, if you had a character that needed to be able to walk or run while attacking with a weapon, the typical workflow is to have an additive blend node that combines walking and running animation clips with an animation clip of one of the limbs performing a weapon attack animation.
This commit adds support for additive blending to Bevy. It builds on top of the flexible infrastructure in #15589 and introduces a new type of node, the add node. Like blend nodes, add nodes combine the animations of their children according to their weights. Unlike blend nodes, however, add nodes don't normalize the weights to 1.0.
The
animation_masksexample has been overhauled to demonstrate the use of additive blending in combination with masks. There are now controls to choose an animation clip for every limb of the fox individually.This patch also fixes a bug whereby masks were incorrectly accumulated with
insert()during the graph threading phase, which could cause corruption of computed masks in some cases.Note that the
clipfield has been replaced with anAnimationNodeTypeenum, which breaksanimgraph.ronfiles. TheFox.animgraph.ronasset has been updated to the new format.Closes #14395.
Showcase
additive-animation.mp4
Migration Guide
animgraph.ronformat has changed to accommodate the new additive blending feature. You'll need to changeclipfields to instances of the newAnimationNodeTypeenum.