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)