Fix #104665: FBX Export: Duplicate materials cause material indices to be offset #104667

Merged
Member

The export of duplicate materials was changed to skip incrementing the
material index for each duplicate in (0), however the connection was
still being added for each duplicate. Because the connections to
materials are what are indexed by the material indices, the material
indices would no longer match up with the materials, resulting in
incorrect exports.

The original code before the change in (0) was actually exporting FBX
files that worked in external software. The issue was instead in the
FBX importer where it removed duplicate materials without updating the
material indices. Changing the exporter in (0) appeared to fix the issue
because the importer would cause the duplicate materials and material
indices to realign.

Reverting (0) would also have fixed the export issue, however, removing
both the duplicate materials and their connections additionally avoids
the importer issue when these exported files are imported back into
Blender, and makes more sense because only one of each duplicate would
have been used by the exported file in the first place.

(0): 5c9ecad1d2

The export of duplicate materials was changed to skip incrementing the material index for each duplicate in (0), however the connection was still being added for each duplicate. Because the connections to materials are what are indexed by the material indices, the material indices would no longer match up with the materials, resulting in incorrect exports. The original code before the change in (0) was actually exporting FBX files that worked in external software. The issue was instead in the FBX importer where it removed duplicate materials without updating the material indices. Changing the exporter in (0) appeared to fix the issue because the importer would cause the duplicate materials and material indices to realign. Reverting (0) would also have fixed the export issue, however, removing both the duplicate materials and their connections additionally avoids the importer issue when these exported files are imported back into Blender, and makes more sense because only one of each duplicate would have been used by the exported file in the first place. (0): 5c9ecad1d29edd8ba9ebaaad8f71839bd5d88324
Thomas Barlow added 1 commit 2023-06-04 05:39:48 +02:00
The export of duplicate materials was changed to skip incrementing the
material index for each duplicate in [0], however the connection was
still being added for each duplicate. Because the connections to
materials are what are indexed by the material indices, the material
indices would no longer match up with the materials, resulting in
incorrect exports.

The original code before the change in [0] was actually exporting FBX
files that worked in external software. The issue was instead in the
FBX importer where it removed duplicate materials without updating the
material indices. Changing the exporter in [0] appeared to fix the issue
because the importer would cause the duplicate materials and material
indices to realign.

Reverting [0] would also have fixed the export issue, however, removing
both the duplicate materials and their connections additionally avoids
the importer issue when these exported files are imported back into
Blender, and makes more sense because only one of each duplicate would
have been used by the exported file in the first place.

[0]: 5c9ecad1d2
Thomas Barlow requested review from Bastien Montagne 2023-06-04 05:42:40 +02:00
Bastien Montagne approved these changes 2023-06-06 17:35:45 +02:00
Bastien Montagne left a comment
Owner

LGTM, thanks for the fix.

LGTM, thanks for the fix.
Bastien Montagne merged commit 0a4e4f2704 into blender-v3.6-release 2023-06-06 17:36:14 +02:00
Bastien Montagne deleted branch fix_duplicate_material_export_pr 2023-06-06 17:36:15 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 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#104667
No description provided.