Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RetargetModifier3D for realtime retarget to keep original rest #97824

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

TokageItLab
Copy link
Member

@TokageItLab TokageItLab commented Oct 4, 2024

Closes godotengine/godot-proposals#3379

RetargetModifier3D

Add RetargetModifier3D. Currently Godot performs retargeting by overwriting rest. However, that means discarding the bone rest which set in the DCC, and it is quite possible that the axis of rest will be in an unintended direction. It makes re-targeting useless for specifying IK pole vectors and setting constraints for specific axes.

This PR solves this problem by retargeting the parent skeleton with the rest defined in the SkeletonProfile and the child skeleton holding the original rest with the RetargetModifier that will be added in this PR. Also keep in mind that parenting is required to guarantee process order.

image

The Profile specified to RetargetModifier3D is used only as a list of bone names, so if you want to retarget only specific bones, you can create a custom SkeletonProfile with arbitrary bone names only and set it to the RetargetModifier3D.

It has the following two types of retargets by Use Global Pose option.

Use Global Pose option

If enabled, retargeting is enabled when the parent of the source bone is deformed, even if the target bone is less than the source bone. However, as a limitation, the lengths of the bones must be exactly equal. For example a specific use case, adding a dummy bone with zero length helps share animation between models with different numbers of bones.

retmod002.mp4

If disabled, retargeting is not performed when the parent of the source bone is deformed if the target bone is less than the source bone. However, it is possible to retarget bones of different lengths without destroying the appearance of the bones. For example a specific use case, you can retarget a chibi character from a skeleton that matches your real body shape for XR motion tracking. In addition, position, rotation, and scale can be handled individually.

image

Post importer change

Add option to separate unmapped bone library

image

Add option to use RetargetModifier to keep original rest

image image

Note that the Rename Bone option must be enabled.

image

@TokageItLab TokageItLab added this to the 4.4 milestone Oct 4, 2024
@TokageItLab TokageItLab requested a review from a team October 4, 2024 20:15
@TokageItLab TokageItLab requested review from a team as code owners October 4, 2024 20:15
@TokageItLab TokageItLab force-pushed the retarget-modifier branch 3 times, most recently from e3f3157 to a7b2351 Compare October 4, 2024 20:22
@TokageItLab TokageItLab requested review from fire and lyuma October 4, 2024 20:29
@fire
Copy link
Member

fire commented Oct 5, 2024

Is there particular tests you want us to look at? I'll try to review this as soon as possible.

@TokageItLab TokageItLab force-pushed the retarget-modifier branch 3 times, most recently from 61da730 to 8346442 Compare October 5, 2024 07:19
@TokageItLab
Copy link
Member Author

TokageItLab commented Oct 5, 2024

I put the project that I used to test the behavior on my end. I would appreciate it if you could retarget other models or test the combination with XRModifier like one more RetargetModifier to the GeneralSkeleton parent to retarget from the real body shape skeleton with tracking. cc @Malcolmnixon

retarget-modifier-test.zip

Godette / CC by SirRichard94
Blender Chan! / CC by SearKitchen
Alicia Solid / DWANGO Co., Ltd.

@TokageItLab TokageItLab force-pushed the retarget-modifier branch 2 times, most recently from 3cdd2eb to 42eda8c Compare October 5, 2024 07:46
@TokageItLab
Copy link
Member Author

TokageItLab commented Oct 5, 2024

It may be possible (not so at the current this PR) to modify it so that Skeleton can create a children list even if it is not a direct child of RetargetModifier like:

ParentSkeleton
└RetargetModifier
 └Node
  └ChildSkeleton <- detect

but it will need to be tested.

I will try to improve this in a later Follow up PR, as it could be applied to SkeletonModifier lists that are direct children of Skeleton to organize tree view like:

Skeleton
├Node
│├ModifierA_1
│└ModifierA_2
└Node_2
 ├ModifierB_1
 └ModifierB_2

@TokageItLab TokageItLab force-pushed the retarget-modifier branch 3 times, most recently from d9c790b to e42e587 Compare October 7, 2024 09:56
@TokageItLab TokageItLab requested review from a team as code owners October 15, 2024 13:47
@fire
Copy link
Member

fire commented Oct 15, 2024

I have tested this on https://github.com/V-Sekai/godot-humanoid-project where we retarget a character body without a UpperChest to a character body that has does not have a UpperChest but only has a Chest.

Note that there a difference in animation in the godot-humanoid-project but it is unrelated to this pr.

@TokageItLab TokageItLab force-pushed the retarget-modifier branch 2 times, most recently from d45866a to f6de32d Compare October 29, 2024 02:25
@SaracenOne SaracenOne self-assigned this Nov 10, 2024
Copy link
Member

@SaracenOne SaracenOne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was discussed and demonstrated in the Animation meeting and seems fine 👍

@fire
Copy link
Member

fire commented Nov 21, 2024

@TokageItLab Does this resolve the Add a bone expander (to be able to change the local scale) priority?

@TokageItLab
Copy link
Member Author

TokageItLab commented Nov 21, 2024

@fire No, Bone expander should be superseded by the option to add a cancel bone by constrain as discussed in godotengine/godot-proposals#9885 (comment); It adds a constrained bone without length that applies the reverse scale to the child of the bone you want to cancel the scale. We have discussed this with lyuma in the past and we agree.

This PR helps to implement Constraint (by keeping original rest), but is not directly related to it. Although it might be useful in terms of facilitating retargeting when adding a zero length bone.

Canceling non-uniform scales in local space requires allowing non-orthogonal scales in the bone pose, but non-orthogonal scales do not conform to the glTF specification and are incompatible with the TRS3D track, which prevents compression and hinders the implementation of streaming animation playback.

@Repiteo Repiteo merged commit 04786f0 into godotengine:master Nov 26, 2024
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Nov 26, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Implement Skeleton re-targeting node
5 participants