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

Feature suggestion: auto correct root bone orientation? #205

Open
sacrish opened this issue Dec 7, 2024 · 8 comments
Open

Feature suggestion: auto correct root bone orientation? #205

sacrish opened this issue Dec 7, 2024 · 8 comments
Labels
Suggestion / Enhancement New feature or request

Comments

@sacrish
Copy link

sacrish commented Dec 7, 2024

If I manually include a root bone in my rig hierarchy, it will get a non-zero rotation value when imported to UE. This could cause problem with some retargeted animations. Setting its rotation to 0 in UE can't fix the problem because it will make the character lie on the floor.

This seems to be the default behavior of Blender's stock fbx exporter as well.

A workaround I found is to remove the root bone from hierarchy and let the plugin automatically add a root bone on export. This way the root bone can maintain a (0,0,0) orientation in UE. But the drawback is that I would not be able to do root animations in Blender.

So I wonder whether it's possible to make sure the manually added root bone doesn't get an unapplied rotation value, or it's just hard limitation of the program?

@sacrish
Copy link
Author

sacrish commented Dec 8, 2024

Managed to work around the problem by placing the root bone in a specific way (X pointing down and Z pointing forward) so that it matches UE's default orientation after the axis conversion:
Screenshot 2024-12-08 150500

I wonder if this procedure could be done by the plugin? But I think it's fine if users need to do this manually.

@sacrish sacrish changed the title Is it possible to ensure my own root bone has no rotation when imported to UE? Feature suggestion: auto correct root bone orientation? Dec 8, 2024
@xavier150
Copy link
Owner

Hey @sacrish
You need a single root bone in any case to have a correct export or Unreal will automatically add it.
I recomand you to keep the rotation and location at Zero and Scale at 1 to avoid issues.

Unreal should keep the correct orientation in unreal. If not it's probably you need to re import the animation too.

If you need to use the Unreal bones orientation you can use the custom IO exporter here.
image

You can found more details here:
UE Bone Structure and UE Mannequin
Skeleton & Root bone

@sacrish
Copy link
Author

sacrish commented Dec 8, 2024

Hey @sacrish You need a single root bone in any case to have a correct export or Unreal will automatically add it. I recomand you to keep the rotation and location at Zero and Scale at 1 to avoid issues.

Unreal should keep the correct orientation in unreal. If not it's probably you need to re import the animation too.

If you need to use the Unreal bones orientation you can use the custom IO exporter here. image

Yes, I am using a single root bone hierarchy, with no unapplied transform on the Armature, and having the UE standard export selected.

My rig hierarchy is similar to UE's mannequin, like this:
Screenshot 2024-12-09 004501
(the other CTRL_* bones are all non-deform ones so they won't be exported)

I think the thing that matters is how the root bone is oriented. For example if the root bone is placed in a conventional "Blender fashion" pointing upward like this:
Screenshot 2024-12-09 005723

Then when imported into UE the root bone will get a default rotation:
Screenshot 2024-12-09 010022

And if in Blender the root bone is placed in a specific way (so that after export axis conversion it becomes X-left Y-forward and Z-up):
Screenshot 2024-12-09 005735

Then when imported into UE it gets a clean transform (well almost):
Screenshot 2024-12-09 010409

I've attached a Blend file with both rigs so you can test them out if you're interested:
ue_rig_test.zip

@xavier150
Copy link
Owner

Sorry for the delay.

If I use the "Blender fashion" pointing upward with a roll at zero I get in Unreal Engine (Pitch=90.000000,Yaw=0.000000,Roll=0.000000) It also what I get with my other skeleton from Blender.

If you need get zero for all axes well I think your method is the best.

@sacrish
Copy link
Author

sacrish commented Dec 12, 2024

No problem. The non-zero root bone orientation in UE is fine in most cases. However, for some reason that I don't understand, some retargeted animations will have a incorrect root rotation if it's not all zero by default.

So I imagine a feature that: the user could specify a bone as their custom root bone, and on export the plugin automatically converts its orientation (and animation values) to match UE standard. Would such a feature be possible or easy to implement? I understand if it's impossible or too much of a bother and the user has to manually set up their rig correctly.

@xavier150
Copy link
Owner

Yes I understand the problem. I would have thought that Retargeting tools could fix this. Also it is much simpler if the animations are natively compatible especially if they come from the same character.

Unfortunately an option to reorient the root bone would be too tedious, and would probably cause problems with other Rigs.
The best is to modify your armature to directly place the root bone with the right axes so as to have a value of 0 in Unreal Engine.
@SAM-tak worked on the custom fbx I/O. Maybe they has an opinion about it?

About animating the root bone I guess for the Root Motion it's better to do it with the rig animation.
Here my controller will move and rotate the root bone:
image

@xavier150 xavier150 added the Suggestion / Enhancement New feature or request label Dec 13, 2024
@SAM-tak
Copy link
Contributor

SAM-tak commented Dec 23, 2024

tried a bit, but it wasn't easy...

I thought it might work if the process around line 3528 of fbxio/io_scene_fbx_*/export_fbx_bin.py included the root bone as well.

@drpsyko101
Copy link

Option for zeroing out/transform root would also be helpful with the use of the default generated rig from Blender's metarig. My pipeline does need Rigify retargeting in Blender and UE so having a coherent root transform in both workflows really helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Suggestion / Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants