Fbx export: random, weird bones rotation artefact
Open, Needs TriagePublic

Description

System Information
Win10

Blender Version
2.79

Short description of error
First, sorry if this report is a duplicate, i've found some similar report but could not make sure they're the same.
A few bones orientation are wrong when exported to Fbx then imported in Unity or Unreal Engine. Importing back the Fbx in Blender is ok, but not in these game engines.

Exact steps for others to reproduce the error
-Import the attached fbx file in Blender, then check it's ok.
-Export it to fbx using the default options
-Import in Unity or Unreal Engine. The lips, cheeks and chin bones are distorted. After investigation, moving of +/-0.01 the bones transforms in Blender before exporting can fix it. So it seems to be an imprecision error at some point...

Details

Type
Bug

Dont have access to Unity/Unreal atm.
@lucas veber (lucky3) : could you upload a screenshot of both Unity and Unreal as a reference?

Sure thing. Actually it's the same issue in Maya in case you're able to test it. Haven't tested with 3dsmax but i'd assume it may be the same.
Here is attached a screenshot.

lucas veber (lucky3) added a comment.EditedMar 27 2018, 1:30 PM

While praying for this bug not to be forgotten in the dark, i've simplified at maximum the example blend file (attached) to help. It now only contains one mesh and two bones. When exporting to Fbx and importing in other apps, such as Unity, "bone2" is imported with Rot X = 179.8, instead of -90.
Rotating in Edit Mode bone2 1 or 2 degrees in Blender fixes the issue. However it's not a clean solution, it may happen in other situations. Seems to happen when a bone is making 180 degrees x-axis angle with its parent.
After further investigations with the Fbx exporter code, tracking the exported rotations values seems to output correct values. However it's the way these values are read in other app that is the problem. Likely to be an euler issue, if only Fbx used quaternions...

Exported rotations from Blender, using a "print" command in the Fbx script (truncated for readibility):
bone1 [-90, 0, -90]
bone 2 [179.8, 0.115, 0.035]

Imported rotations in Unity (truncated for readibility):
bone1 [0.000, -90, 89.9]
bone 2 [179.8, -0.115, 0.0]