FBX Export: Duplicate materials cause material indices to be offset #103976

Closed
opened 2023-01-18 18:36:03 +01:00 by Mysteryem · 3 comments

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 516.94

Blender Version
Broken: version: 3.4.1, branch: blender-v3.4-release, commit date: 2022-12-19 17:00, hash: blender/blender@55485cb379, version: 2.80.75
Worked:

Short description of error
When meshes have duplicate materials in their slots, the material is added to the fbx only once, but the material index for that material is incremented each time the material is found. This causes the material index to increase beyond the number of materials, offsetting subsequent material indices and causing material indices to go out of bounds.
image.png
image.png
The polygons assigned to either slot containing Duplicate Material were given a material index of 2, which now corresponds to Other Material in the exported FBX. (green has become red)
The polygons assigned to Other Material were given a material index of 3, which is now out of bounds, so the FBX importer has reassigned them to the first slot. (red has become purple)
image.png
Exact steps for others to reproduce the error

  • Create a mesh with the same material in at least two material slots
  • Assign some polygons to one of the material slots containing a duplicate material or a subsequent material slot
  • Export as FBX (default settings)
  • Open the system console
  • Import the exported .fbx
  • Observe the warning in the system console and that the polygons have been assigned to the wrong materials
    Attached is the .blend file shown in the description (authored in 3.4.1) and the .fbx exported from it
    FBXDuplicateMaterialTest.blend
    FBXDuplicateMaterialTest.fbx
**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 516.94 **Blender Version** Broken: version: 3.4.1, branch: blender-v3.4-release, commit date: 2022-12-19 17:00, hash: `blender/blender@55485cb379`, version: 2.80.75 Worked: **Short description of error** When meshes have duplicate materials in their slots, the material is added to the fbx only once, but the material index for that material is incremented each time the material is found. This causes the material index to increase beyond the number of materials, offsetting subsequent material indices and causing material indices to go out of bounds. ![image.png](https://archive.blender.org/developer/F14172352/image.png) ![image.png](https://archive.blender.org/developer/F14172262/image.png) The polygons assigned to either slot containing `Duplicate Material` were given a material index of 2, which now corresponds to `Other Material` in the exported FBX. (green has become red) The polygons assigned to `Other Material` were given a material index of 3, which is now out of bounds, so the FBX importer has reassigned them to the first slot. (red has become purple) ![image.png](https://archive.blender.org/developer/F14172354/image.png) **Exact steps for others to reproduce the error** - Create a mesh with the same material in at least two material slots - Assign some polygons to one of the material slots containing a duplicate material or a subsequent material slot - Export as FBX (default settings) - Open the system console - Import the exported .fbx - Observe the warning in the system console and that the polygons have been assigned to the wrong materials Attached is the .blend file shown in the description (authored in 3.4.1) and the .fbx exported from it [FBXDuplicateMaterialTest.blend](https://archive.blender.org/developer/F14172357/FBXDuplicateMaterialTest.blend) [FBXDuplicateMaterialTest.fbx](https://archive.blender.org/developer/F14172358/FBXDuplicateMaterialTest.fbx)
Author

Added subscriber: @Mysteryem-2

Added subscriber: @Mysteryem-2

This issue was referenced by 5c9ecad1d2

This issue was referenced by 5c9ecad1d29edd8ba9ebaaad8f71839bd5d88324

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Bastien Montagne self-assigned this 2023-01-23 15:52:19 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#103976
No description provided.