FBX Importer tangents import problem

Hello! Recently working with FBX Import in Unreal Engine I’ve found an issue that persists in UE 4.27-5.1. Probably 5.2-5.3, haven’t tested it yet.

LONG STORY SHORT

I’ve found a bug in Unreal Engine FBX Importer that’s producing this weird triangle shading.
If you met it importing mesh from Blender you can fix it using “Raw Normals And Raw Tangents” export option in Better FBX (available after v5.3.6).
If you met it importing mesh from elsewhere I guess you need to find some other workaround.

Detailed description

When I import FBX mesh as Skeletal Mesh (with preserved original normals/tangents from FBX - Normal Import Mode - Import Normals and Tangents) it looks fine but when I add any shader that’s using normal map mesh starts to look like this.
The reason for that is something wrong with imported tangents - when we use normal maps tagnent space is used to interpret them, if we don’t use normal maps tangent space and this is why mesh seems fine.

Example shader:

Mesh was exported from Blender using Better FBX addon which in my experience is the most reliable option to export FBX.
Investigating I couldn’t figure out the root cause and I’ve contacted the addon developer.
They’ve investigated even deeper and found a bug in Unreal Engine FBX Importer and added workaround in Better FBX exporter to avoid the issue at memory cost.
I want to emphasize that it’s UE FBX Importer’s problem, not exporter’s. For example, the same mesh without any workaround works fine in Unity.

Bug description from the developer:

I have read the source code ofUE4/UE5, and found that it is a bug of UE4/UE5’ FBX importer, Unity does not have the bug, it can import tangents correctly.
In UE4/UE5, if you import FBX as static mesh, the tangents are correct; but if you import FBX as skeleton mesh, the tangents will mess up.
The reason is that when importing as static mesh, it uses tangent index to load tangent data; but when importing as skeleton mesh,
it uses normal index instead of tangent index to load tangent data, it assumes that the normal indices are the same as the tangent indices, but it is not alway true, normals and tangent can have their own indices.
To verify my judgment, I save all the raw normals and all the raw tangents when exporting, of course the FBX file will get larger than before, UE4/UE5 can import tangents correctly.
I’ll fix the issue by adding anew option to control if it exports raw normals and raw tangents when exporting to fit UE4/UE5.

After using new exporter option “Raw Normals And Raw Tangents” mesh imported just fine.

If someone from UE developers want to inverstigate themselves I’m attaching 2 fbx of the same mesh: bugged - the one that Unreal fail to import tangents from, fixed - the one that works fine.

fbx_unreal_tangents_bug.zip (16.5 MB)

Sumbitted pull request with fix to Epic Games - Same approach for FBX SM/SK tangents/binormals import by Andrej730 · Pull Request #10862 · EpicGames/UnrealEngine (github.com)

Update - submitted a pull request more than a month ago and no response from devs, that’s demotivating. :smiling_face_with_tear:

Running into the exact same issue right now
using legacy fbx exporter from blender

you’re “bug description from devs” gave me insight to navigate this

i have a main skeletal mesh and there are empty pivots that are controlling regular static mesh (i did not make this model, so i am just exporting as is)

the thing is, there are parts of the main body that are part of the skeletal mesh that are also messed up tangents

il try taking the time to rig up all the parts that are not actually in the armature

Issue still persists, important note - it only occurs if you import normals and tangents from fbx (“Normal Import Mode” - “Import Normals and Tangents”) and using unreal computed normals can work in some cases, though it’s not very reliable.