KybernetikGames / animancer

Documentation for the Animancer Unity Plugin.
65 stars 8 forks source link

How to realize 3 layers:BaseLayer , WeightedMaskLayer and AdditiveLayer? #300

Closed fomiao closed 1 year ago

fomiao commented 1 year ago

WeightedMaskMixer feature can work by https://github.com/KybernetikGames/animancer/issues/154. but it only supports 2 layers。I want to add another layer for additive animation.maybe layers can connect different playble?

KybernetikGames commented 1 year ago

You would need to modify the WeightedMaskMixerJob struct in WeightedMaskLayerList.cs. The ProcessRootMotion method is probably fine, but in ProcessAnimation where it uses input streams 0 and 1 you'd need to add 2. For the position just give it the lerped value + the value from stream 2 and the same for rotation but using * for quaternions instead of +.

fomiao commented 1 year ago

You would need to modify the WeightedMaskMixerJob struct in WeightedMaskLayerList.cs. The ProcessRootMotion method is probably fine, but in ProcessAnimation where it uses input streams 0 and 1 you'd need to add 2. For the position just give it the lerped value + the value from stream 2 and the same for rotation but using * for quaternions instead of +.

I tried this way but i also want the clip additive refer pose by the first frame (i find it is not easy to get clip data in runtime).now i create AnimationLayerMixerPlayable to mixer layer_playable and additive_playble,it can work but not perfect.so i think if layers can connect different playble may be better

KybernetikGames commented 1 year ago

Unfortunately, the source code of AnimationLayerMixerPlayable isn't public so I don't have any more insight into how they might have implemented it.

so i think if layers can connect different playble may be better

Can you explain what you mean in more detail?

fomiao commented 1 year ago

Unfortunately, the source code of AnimationLayerMixerPlayable isn't public so I don't have any more insight into how they might have implemented it.

so i think if layers can connect different playble may be better

Can you explain what you mean in more detail? now in animancer all layers connect to the same playale.if we can layer1 and layer2 connect to playable1(AnimationScriptPlayab),then playable1 and layer3 connect to playable2(AnimationLayerMixerPlayable ).

KybernetikGames commented 1 year ago

I can't think of a clean way to implement a feature like that without dedicating a bunch of development time to it and likely imposing a small performance cost for everyone regardless of whether they use this feature or not. That doesn't seem worth it for such an uncommon use case so for now you'll have to keep using your hacky approach. I might reconsider if this gets interest from more people, but otherwise I already have a very long list of higher priority features to work on.