Deltakosh

Animation weights

Recommended Posts

Hey team!

@MackeyK24 asked for it with so much energy that I spent my entire week end working on a new feature: the animation weights support

To learn more about it, please read the doc here: http://doc.babylonjs.com/babylon101/animations#animation-weights

A demo can be found here: https://www.babylonjs-playground.com/#IQN716#3 

ANIMATION WEIGHTS

As always, any feedback is welcome!

 

Note: I could have added a third animation to the demo (a run animation) but the model animation for run is a bit bad (it looked like the model was flying). If you have a better model, feel free to let me know

Share this post


Link to post
Share on other sites

It looks cool, I'll test that soon. So we can made walk a character and play a second animation of shooting for example?

Thank you Dk for that.

Share this post


Link to post
Share on other sites
52 minutes ago, Dad72 said:

It looks cool, I'll test that soon. So we can made walk a character and play a second animation of shooting for example?

Thank you Dk for that.

Yes and no... You can BLEND similar  animations like your ground locomotions. This blend ALL the bones and play weighted animations on ALL the bones.

Our next setup would be to create some kind of BONE MASKING system we could them implement LAYERS so you play then base animations and blend in the TOP HALF of body masked of and play either a blend or a total weight of 1.0  to top half of body bones. IE ... Walk or running while swinging a sword or shooting weapon.

This is how unity does it and how i will capturing the Animation Controller Layers as metadata and not only blend the ground locomotion animation but also apply any LAYER animations that should be running based on the Animation State Machine. Exactly how unity does it. That way you can use the Unity Editor to setup all the animations (or use existing animation controllers from the asset store something).  At least that is my goal for the babylon toolkit :)

 

Share this post


Link to post
Share on other sites

Yo @Deltakosh I need some advice....

Using the new animation weight system from a Unity Controller Blend Tree... Often each BlendTree may have up to 16 or more BlendTree Branches (The bendable animations that I loop thru calling scene.beginWeightedAnimation). Now that thechnically starts running all 16 or more animations. The first one has a full weight of 1.0 and the other fifteen are at ZERO. Then in the game loop I would loop thru the returned BABYLON.IAnimatable[] array and change each weight according to which ones should actually be contributing a weight GREATER than ZERO. I cant see how that would be no more than 2 or 3 animations out of the 16 that actually get used depending on your input values... Like gamepad stick forward.

Should I:

A... Just load all 16 or more animations for blending and just live with the performance cost of the dozen or more animations that are not getting used (at least for that update frame check) but actually still playing the animation as far as the engine is concerned.

B... Figure out which few of the 16 animations SHOULD be contributing on that frame and if those animations are NOT currently playing... call scene.beginWeightAnimation from that frame update with ONLY the few animations that should be contributing. But this too has a performance cost as well . Especially if the user is doing ALOT of gamepad stick movement. Could be calling beginWeightAnimation every few frames.

C... Load all 16 by calling scene.beginWeightedAnimation. Then immediately STOP all of them. Then in the frame update figure out what ones should contribute weight, assign the weights accordingly and then figure out what frame we should be on and then each animatable.goToFrame (so timing still in sync)  and finally animatable.restart on the ones that SHOULD be contributing.

I dont know about what kind of performance cost constantly STOPPING and RESTART the weighted animations that should be contributing VS Loading them all and just changing the weights on 16 currently blendable playing animations VS constantly scene.beginWeightAnimation with only the few animations that should contribute on that frame.

 What do you think ???

Do have any other suggestions on how to handle this ???

 

Share this post


Link to post
Share on other sites

I would recommend to keep the number of animations to the lowest level possible.

You can use stopAnimation(target, name) to hand pick which animations to stop

But I have a good news for you: The new version will ignore all animations with weight = 0; So your point A should be fine

 

Share this post


Link to post
Share on other sites
2 hours ago, Deltakosh said:

I would recommend to keep the number of animations to the lowest level possible.

You can use stopAnimation(target, name) to hand pick which animations to stop

But I have a good news for you: The new version will ignore all animations with weight = 0; So your point A should be fine

 

Sweet... cant wait for the next commit.... Thanks @Deltakosh ... You da man :)

 

Share this post


Link to post
Share on other sites

Yo @Deltakosh ... I think the changes were in that last "Impoved Deep Copy" commit... Now I DONT get T-POSE and I have 18 bendable animation tree branches load (but I am only playing IDLE in this screenshot)... But it is only costing me 1MS ... The scene without the animatied character is 1MS .. for a total of 2MS

 

5aa817b62cb1c_ScreenShot2018-03-13at8_22_03AM.thumb.png.23c00cf1628d45bd0d1d312b3a8a6f24.png

 

5aa817e37e873_ScreenShot2018-03-13at8_26_20AM.thumb.png.843e047640373fae51fc137c1ae6f89e.png

Share this post


Link to post
Share on other sites

Yo @Deltakosh  and anyone who is interested in Animation Blending.

This is my first little demo of my Frame By Frame Animation State Machine. That Supports Animation Blending (Both Blending Speed And Final Composition)

Note the Play Blend button with play a Walk Forward animation with a 50% blend of the Left Strafe Walk ... Giving a Diagonal Walk Forward result :)

Clear your browser cache and take a look: http://mackey.cloud/games/tester/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.