FBX Normals export issue (IndexToDirect interpreted wrong in Unity) #123088
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#123088
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?
System Information
Operating system: Windows 10
Blender Version
Broken: 4.1.1
Worked: 4.0.2
Short description of error
Normals are exported incorrectly to FBX files, artifacts show up when imported into Unity. It seems like normal smoothing information may be lost. I've confirmed this issue is in fact Blender, not Unity. Also confirmed it is still an issue on 4.3.0 Alpha.
Exact steps for others to reproduce the error
Tested attached FBX files in the following Unity version, all with the same results pictured.
Recently there had been a few reports on possible FBX exporting errors indeed. @Mysteryem Could you take a look?
To get this out of the way first:
test_4-0.fbx
seems to have no texture associated with the normal map nodetest_4-1.fbx
seems to have a texture associated (HS_AK12_Forearm_Normal.png
)(at least this is what happens when you import them into blender)
When I open
test.blend
in Blender 4.1.1 and export as FBX, I dont get the texture associated when re-importing into Blender.Not sure if this is responsible for the issue, just wanted to ask if both FBXes have really been exported from the exact same file?
Whoops, I think I zipped up the wrong FBX files, there shouldn't be any reference to a normal map. I uploaded the correct FBXs now.
Originally I thought the normal map might be causing the problem so I created a flat normal map, same issue.
In the end I removed the normal map as it has no impact on this bug. I think it's something with the mesh data in the FBX.
From my investigation, this seems to be a Unity bug specifically with per-vertex normals exported with the
IndexToDirect
FBX reference mode, where Unity considersnormals belonging to only a single facenormals used by more than one vertex to be invalid and then throws out all the normals in the mesh and recalculates the normals itself. Unreal and FBX Review have no issues importing these normals (unreal will complain about no smoothing information in this case, but that can be remedied by exporting with FACE smoothing enabled).I think this is a Unity bug because changing these normals to export with the
Direct
FBX reference mode works without issue and the only difference betweenDirect
andIndexToDirect
is how the data is stored in the FBX file:IndexToDirect
can be used to remove duplicates and adds a second array of indices into the deduplicated array of normals that allows the full array, like would be exported with theDirect
reference mode, to be reconstructed. Notably, the FBX SDK Documentation specifically states that normals should be exported asIndexToDirect
.Attached are two FBX models of a plane with per-vertex normals, one using the
Direct
reference mode and the otherIndexToDirect
.Unfortunately, none of the models I tested with when testing the export of per-vertex normals had multiple vertices with exactly the same normals, so this wasn't noticed sooner.
In this case, it looks like Unity is recalculating of the normals is using an
Area Weighted
normal calculation which does not work well for this model. As a workaround for this issue, changing the normal mode in the FBX's import settings in Unity toAngle Weighted
gives a much better result:Thx a lot for the info @Mysteryem !
How did you change it from
IndexToDirect
toDirect
? Change the exporter code here?I've updated my findings because it seems that what Unity doesn't like is any normals being used by more than one vertex, which somewhat defeats the purpose of the
IndexToDirect
reference mode. Unity does not complain if I useIndexToDirect
without deduplicating the normals, so the indices array is just[0, 1, 2, 3, 4, ...]
.In this case I modified the file manually by converting it to json with the fbx2json.py script, adjusted the normals in a text editor and then converted back with the json2fbx.py script.
Here's a commit with changes to make the exporter use
Direct
instead ofIndexToDirect
:dc7c1add1d
@Mysteryem : do we have an explanation why this worked in 4.0.2? (that might be interesting to mention in !123186)
Normals export incorrectly to FBXto FBX Normals export issue (IndexToDirect interpreted wrong in Unity)Will confirm for now