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

Loading different animation resource from same skeleton, different file causes corrupt animation (GLTF) #51931

Closed
stryker313 opened this issue Aug 20, 2021 · 13 comments

Comments

@stryker313
Copy link

stryker313 commented Aug 20, 2021

Godot version

v3.3.3.stable.official

System information

Windows 10 GTX 1060 6gb Intel 4690k

Issue description

Potentially linked issues include #50212, but perhaps less so #51785.
#50212 Doesn't focus on loading the resource.

You can have two of the same skeletons, no difference in settings; however, when you attempt to move animations between these skeletons, the animation is corrupted.

ex. Skeleton A has animation B and Skeleton C has animation D.
A and C are the same skeleton, no difference in anything, except for the fact they are two different exports.

You can't copy animation D to skeleton A. The animation ends up being corrupted/off. Same goes for animation B to Skeleton D.

It doesn't matter if you copy paste the animations, save the animations as a resource then load them into different skeletons, or turn off optimize animations in the GLTF import.

Here is short vid: https://youtu.be/Y6JX2CK95d8

Steps to reproduce

Export two armatures/skeletons from blender. Same skeleton, don't change anything, just give both of these skeletons different animations.

Load these armatures into godot, and create a scene for each GLTF import.

Copy the animation from one skeleton onto the other one, and the animation will not be correct, despite there being no difference in the skeletons.

Minimal reproduction project

There are two models. INSPECTAHDECK and METHODMAN. For this example, copy the animation "Armature002|mixamocom|Layer0 Retarget" from INSPECTAHDECK to METHODMAN, either by copy paste or saving and loading a resource. The animation will come out corrupted. In scene METHODMAN, this has already been done as an example. The result animation is labeled "CorruptAnimationExample", however for debugging purposes you may want to follow the above instructions.

Regardless of models and animations, this issue plagues all models and anims. Different animations using the same skeleton won't work correctly unless they are exported in the same file

Ignore the blockBroken animation, that one works on both because it was exported alongside both skeletons, so it has no impact on the bug/investigation
AnimationTransferBug.zip

@stryker313 stryker313 changed the title Loading different animation resource from same skeleton, different file causes corrupt animation Loading different animation resource from same skeleton, different file causes corrupt animation (GLTF) Aug 20, 2021
@fire
Copy link
Member

fire commented Aug 21, 2021

My analysis of similar problems was done in godotengine/godot-proposals#2961 and #51057.

Godot does not have generalized retargeting support and glTF2 if you are not strict about starting from the rest pose has an issue with reset.

Edited:

Master is broken so I will have some trouble debugging.

@stryker313
Copy link
Author

I'll give you as much data as I can, and create more debug projects if you need them, as I have run into this problem quite frequently across many different scenarios.
I use rokoko retargeting tool to put animations on my skeleton
What's weird is that I verify that the supposed "rest_pose" (in blender, there is the "pose_position" and "rest_position") are the same, or at least appear to be before the files are exported. Once again, nothing modified, nothing change, just different animations with the same rest pose. So, at least from my perspective, something is either happening during the GLTF export from blender or during the GLTF import by godot that is causing some type of shift, because if the animations can work when exported WITH the skeleton, but not work when exported WITHOUT the skeleton, something has to be occurring during the transition from blender to gltf or gltf to godot.

A workaround for some people can be https://github.com/smix8/GodotAnimationRetargeting, however this doesn't work 100% and minor repair work is needed after using it.

@fire
Copy link
Member

fire commented Aug 22, 2021

Here's my copy of the retargeter from rokoko, may the Blender addon help. https://github.com/V-Sekai/blender-skeletal-motion-animate

@fire
Copy link
Member

fire commented Aug 22, 2021

Also please investigate the "fortune" and "temperance" algorithms from Blender. The fortune and temperance algorithms happen on Blender import.

@stryker313
Copy link
Author

stryker313 commented Aug 22, 2021

Im confused by the blender addon. How is that one different from the one you can get from https://github.com/Rokoko/rokoko-studio-live-blender ? Will look into fortune and temperance

@fire
Copy link
Member

fire commented Aug 22, 2021

@stryker313 I want to streamline using the Blender plugin and making it more usable.

@stryker313
Copy link
Author

Currently looking into fortune and temperance on GLTF import, but something to note: This error happens on the SAME skeleton, SAME save file, making me believe that import error is less likely.

For example, if you import a gltf, save the file.Then resuse this file. ie. retargeting anims to this skeleton, exporting, then not saving the skeleton so that the save file can be used a clean slate for other animations. I don't know that fortune and temperance would be contributing to this error if it is the same skeleton with the same rest pose (unless rokoko would be changing the rest pose, which it would seem is unlikely) Even though you are importing a different skeleton for retargeting animations, the target skeleton is still not changing, nor would the rest pose.

Are there any settings that you think could make a difference in the GLTF export? (That's a more likely scenario I'd think. Between that and godot)

@stryker313
Copy link
Author

stryker313 commented Aug 26, 2021

I found the solution. So this isn't a godot issue. What happens is that when you export a skeleton from Blender, whatever pose the skeleton is in at the moment of export becomes the "rest pose". Your skeleton does not inherit the rest position that is listed in the armature settings. So the simple solution is to make sure that when you export a gltf skeleton, that you make sure the skeleton is in its rest pose.

I think that it would be a good idea for Godot to potentially warn the user that their animation/gltf skeleton does not have the same rest pose when moving animations around like this, because this issue isn't something that is apparent. You would assume that the rest pose listed on the armature would be the rest pose that gets exported. Its vexed me for a bit, but I imagine that other people might run into a similar thing.

Your version of the rokoko addon, I imagine 1 of the steps should be to export the skeleton in rest pose, so that if a user accidentally forgets, its not a bother.

@fire
Copy link
Member

fire commented Aug 26, 2021

Now is a good time remind you of the RESET proposal. godotengine/godot-proposals#2961

You can make two defined RESET animations and then the pose the skeleton is in at the moment of export can be synced.

See docs https://docs.godotengine.org/en/stable/getting_started/workflow/assets/importing_scenes.html

It is important that the mesh is not deformed by bones when exporting. Make sure that the skeleton is reset to its T-pose or default rest pose before exporting with your favorite 3D editor.

@stryker313
Copy link
Author

Nice. Retargeting wont be priority in the engine for a while if ever, but are there plans to ever incorporate a system like Unreal Engine (basically just built in retargeting)?

@fire
Copy link
Member

fire commented Aug 26, 2021

I don't have a good technical approach to it.

Also if the issue is resolved, please close. Also you can find me on discord. I'll be around next week.

@TokageItLab
Copy link
Member

TokageItLab commented Sep 2, 2021

Currently, if you want to set an optional T-pose as the initial pose for the model you are importing into the Godot, you need to sort on the T-pose animation into the top of animation tracks in the Blender.

@fire Is the cause of this problem that Blender's gltf exporter implicitly changes the skeleton of the glTF node (it will be Godot skeleton rest) depending on the order of the animation tracks? Or is it that Godot's glTF importer can't select the default pose animation?

If the cause is the second, how about adding the initial rest pose animation selector to the import settings?

However, if the cause is the first, we might want to send an issue/PR to Blender's I/O.

Edit:
If you make an animation track named "RESET" on export, Godot 4 will use it as initial rest pose.

@fire
Copy link
Member

fire commented Oct 16, 2021

Should be resolved by #53765.

Today's godot hash is 90a1e51

@akien-mga akien-mga added this to the 4.0 milestone Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants