FBX Import - Armatures are incorrect #53620
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
21 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#53620
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This has been there for a very long time. Whenever importing FBX with skeleton/armature from other apps, many times It's completely screwed - bones are rotated in wrong directions and rotations are wrong. Looks like coordinate systems are not converted correctly.
In this case - perfectly normal skeleton from Maya (From actual project where it is used in production in Maya, Unity, Motion builder etc).
Blender: All versions
OS: All OS
tereza_skel.fbx
Added subscriber: @GatisKurzemnieks
#72386 was marked as duplicate of this issue
#68495 was marked as duplicate of this issue
#53821 was marked as duplicate of this issue
Added subscribers: @mont29, @lichtwerk
While I cant very the file in another program atm (could do tomorrow) I can confirm the output in blender looks unexpected [tried a couple of settings with no luck]
Hate to ask, but @mont29, could you have a look?
can confirm that provided file reads just fine into Maya or Unity
Using
Force Connect Children
andAutomatic Bone Orientation
will help. Besides that, yes, upper part of the skeleton is weird, no idea why. Probably some issue in Pose/bind matrices somehow, armature model of FBX is so complicated…Added subscriber: @Joe_W
Added subscriber: @SergienkoEugene
Added subscriber: @Ghoulish
I'm experiencing this issue with the importer (100% of FBX armatures I import fail to import correctly).
After spending a while looking into it, what appears to be happening is the importer is ignoring (or not successfully using) the PreRotation and PostRotation properties from the FBX LimbNodes to give the bones in Blender the rotation they're supposed to have. When the bones are getting created by the importer, the bones are successfully given proper lengths however the bones aren't getting rotated at all so that the bone tails actually wind up where they're supposed to. I'm not 100% sure about this, but from the reading of the python code I've put in I believe somewhere in the following line the rotation information using the PreRotation and PostRotation info is either not being considered or not being correctly applied:
from line 1931 of import_fbx.py
"# And rotate/move it to its final "rest pose".
bone_matrix = parent_matrix @ self.get_bind_matrix().normalized()"
Added subscriber: @StephenLeger
Looks like at least math behind pre-rotation is wrong.
PreRotation should be something like this
parent_matrix @ rotation_matrix @ parent_matrix.inverted()
wait , what? Are you telling me that those f***ing pre transform matrices need to be inter-mingled with parenting??? In other words, we are supposed to 'cancel' the parent transform for those?
So that would give something like (to get final bind matrix)
parent_matrix @ pre_matrix @ parent_matrix.inverted() @ bind_matrix @ post_matrix
(which should then be normalized and post-multiplied again withparent_matrix
)???I ô so hate FBX transformations model… :(((
Either apply the "pre rotation" first - assuming bone is transform free when we apply, or cancel any transform before, "pre"-rotate and re-apply transform after.
Current code does
parent_matrix @ ((pre_matrix @ bind_matrix) @ post_matrix).normalized()
… So that should be correct, right (iirc, order matters, but not associativity, in matrix multiplication…)?As far as i can understand the pre-rotation concept, it is not as the rotation must apply before any other transform (around 0,0,0).
So assuming object is at 0,0,0 before, should more be like this.
parent_matrix @ (post_matrix @ bind_matrix @ pre_matrix).normalized()
If it is not the case (any translation exist) you must cancel translation and re-apply after pre-rotation.
Added subscriber: @Bater
Yes I have the same issue when importing stuff from Unreal Engine to Blender 2.7X and 2.8
Importing FBX from Unreal Engine to Blender results in distorted bones and wrong IK bones locations and orientation even when connecting to children.
I can also confirm that creating an IK in blender and then exporting it to fbx then importing again will show different results than the originals
Added subscriber: @tw2020
Added subscriber: @Eittipat
Added subscriber: @sbaranov
Added subscriber: @Mentales
Added subscriber: @cschubert25
In case anyone else is stuck by this issue:
I had many FBX files with armatures/animations and many were not rotated correclty when using FBX import. None of the import settings helped, and I tried every combination of bone alignment. The armatures would appear fine in rest pose, but playing animations would distort everything horribly. No amount of manual bone-roll alignment seemed to help.
What did work for me:
Converting the FBX files to glTF, and then importing glTF. The armatures imported correctly and the animations played correctly.
The magic to resolve this issue is either somewhere in the FBX > glTF conversion, or in the glTF importer itself. However, if FBX support is not a priority, maybe a simple hack could be an intermediate conversion during FBX import to glTF, which then proceeds with glTF import.
Anyway, for anyone looking for a manual workaround, here's the github for the converter. You run it via command line but it is very simple to use, and there is good documentation.
FBX to glTF: https://github.com/facebookincubator/FBX2glTF
Documentation: https://developers.facebook.com/docs/sharing/3d-posts/glb-tutorials/#convert-from-fbx
Added subscriber: @djee
Added subscriber: @DavidJeske
I've investigated and I think I've uncovered the cause of some FBX armature problems as it relates to game engine import/export.
In order to round trip skeletons and animations to game engines, the skeleton bone (joint) rotations need to remain consistent. However the Blender FBX Import
automatic bone orientation
andforce connect children
options alter the bone (joint) rotations, effectively altering the skeleton, and so animations built with an imported skeleton no longer match the basis skeleton when pushed back into game engines via Blender FBX Export. (sometimes game engine animation retargetting can fix this, sometimes)The workaround is to standardize on a Blender compatible +Y bone skeleton.
The fix is for Blender to somehow preserve the original bone orientation through FBX import/export. (more detail below)
Background
I believe (based on what I can find and deduce) a Maya/FBX bone is always displayed connecting two bone joints. In other words, the Maya visual of the bone segment is not dependent on the bone/joint local axis orientation or bone scaling in any way. It's basically just an arrow pointing to a child joint.
Blender always displays bone segments towards the +Y local bone axis.
The pictures below are the default unreal engine mannequin loaded in Maya 2020. I don't see anything in the ASCII FBX file indicating a bone display orientation. In the first image you can see one bone pointing generally towards +x and the other generally towards -x. However, the display bone does not need to point towards any bone axis. In the second picture you can see a bone that doesn't point towards any bone axis at all... The bone is just pointing to the child joint. Joints with no children are shown as a circle with no bone.
Maya also supports adjusting bone axis in "Orient Joint Options" dialog, though I'm not sure what effect this has on the bone.
Maya Joint Orientation in a Minute - YouTube
The Blender FBX import
Automatic Bone Orientation
andForce Connect Children
options sort-of do what Maya does, but the problem is that it throws away the transformation it performs, which effectively creates a new skeleton. Then, when you export an animation based on this skeleton, it does not match the original FBX imported skeleton anymore.Because each FBX bone can point in a different direction, there is no single uniform swapping of bone orientations on import/export that will ever work for FBX armatures which have different orientations on different bones. For example, the default UE4 skeleton orients left-leg bones towards -X, and right-leg bones towards +X. As a result, using Blender FBX Import "primary bone axis" can fix the left leg OR the right leg, but never both at the same time.
This pic below shows a UE4 mannequin skeleton imported into blender without any bone adjustment. You can see the bone X axis points up on one leg and down on the other. Without any bone correction, the animations work fine in blender and export fine back to UE4, but this rig isn't very convenient to use, as the bones are not oriented in the model.
Ideas about how to fix this problem...
(1) have the FBX importer save the correction_matrix that "automatic bone orientation" computes, and save it in custom property per bone. Then. during FBX export of that armature or animations, that matrix would be inverted to correct the bone orientations back to the way they were in the source FBX file. (and it would be convenient to have a small property UI and widget to display the FBX bone local axis, which will not match the Blender bone local axis)
(2) extend Blender's bone display code to have an additional "bone display rotation", which would rotate the visible bone handle without affecting the underlying bone axis. An additional toggle "always orient bone towards child pivot" could orient the bone display towards the child bone, matching Maya's behavior. Leaf bones could be automatically oriented during import, similar to the current "automatic bone orientation"
Pros and Cons:
(1) is likely to be easier to implement and experiment with. It has the drawback that any thing driven off the Blender bone local axis will not match the FBX local axis, but anything like this is unlikely to export into game engines anyway (a primary target of this fbx import/export process).
(2) and/or (3) are probably unnecessary... as the way blender handles bones works just fine
Workaround until then...
Until there is a solution which makes Blender able to preserve FBX bone orientations through import/export in a useful way.. the solution to get import/export interop between Blender and FBX based tools is to standardize on a rig where all bones match the Blender orientation... such as by building a rig in blender and standardizing on that rig. This is the approach the Blender Uefy addon for Unreal Engine takes. Alternatively, one can build a blender-centric +Y bone skeleton for getting animations into Unreal/UE and then retarget them to another skeleton with their animation retargeting tools.
Added subscriber: @satr7h
Added subscribers: @DrPhil, @OmarEmaraDev, @mano-wii, @Ahm4Design
Added subscriber: @mistercokes
Added subscriber: @marc_von_step
Added subscriber: @LuffyTheFox
Hello everyone. I did it - finally. Just because I love Blender, creative freedom and believe in the future of indie gamedev.
This has been there for a very long time, but finally after almost a year of development I fixed almost everything related to FBX files, Rig and 3D animations at least for Unreal Engine 5. Here how UE4 and UE5 skeletons now look like. Now you can do whatever you want with 3D characters based on Epic Skeleton. Animations for 3D meshes with correct scaling is supported too. Rig works too on standart Blender features without extra skeleton creation:
All original bone +X and -X axis from FBX file are preserved. Here YouTube playlist with half of Blender Next features: https:*youtube.com/playlist?list=PLldtCJ1OMBDhLSnxOyrNe-8iIAX_Xmhz- . Precompiled custom Blender Next build for Windows with Quinn rig file available now on my GitHub page: https:*github.com/LuffyTheFox/Blender-Next-for-Unreal-Engine/releases/tag/Blender
Enjoy. I hope you will not be as sad as I am right now at this difficult time for all of us. Due to the fact that I have changed a lot of things in the program I can not post here diff. In addition, this build breaks the support of existing plugins from Blender Market. So It just works correctly for FBX files for Unreal Engine 5 Epic Skeleton. That's it.
Added subscriber: @Valdimir
Thank you very much Alexey for your work!
Thank you very much! May I ask you why you tested against UE and not against Unity?
Sure. First, UE is open source - it's programming freedom for development. Second, very complex stuff with character setup in UE can be done in matter of seconds via quick and simple 3D character mesh replacement in Control Rig and Third Person blueprint. Also, animation retarget is quick and easy too via IK retargetter.
But I think my Blender Next can be used in Unity too. Because FBX behaviour is same for both engines.
@LuffyTheFox It's important to recognize that FBX does not use "+X" or "-X" bone orientations.
FBX has NO bone axis.
In Maya, bones are visually displayed pointing towards their CHILD bone, which means Maya does not care (and doesn't normally expose to the user) which way the bone is facing. You can see the evidence of this if you import an FBX file into Blender, because Blender will render the bone pointing in a weird direction but everything actually WORKS just fine.
If you want to fix Blender FBX rig import/export workflow, there is really only one reasonable way I can think of to do it...
Add an "external rig bone orientation offset" variable to bones. When any external filetype is imported (like FBX), if the importer needs to "make the bone point at the child join" like the FBX importer does, it would then calculate the rotation offset to correct the bone orientation back to the source rotation.
Then, during FBX export, the addon would need to use this "external rig bone orientation offset" to un-rotate all the bones back to their original rotation in a way that restores the original bone base rotation before it is written.
Hello David Jeske. Sorry for long responce. I think there is no reason to "external rig bone orientation offset" variable to bones, because FBX Exporter is extremly hard do debug and I am not a Python expert. So, I desided to keep everything as it is, just because it works.
Here my typical workflow actually and how I use this build and how it can be useful for community:
So far on my end everything works great. It saved a lot of time and money for me and my customers during 3D modelling and 3D animation process in Unreal Engine.