Incorrect material assignments of imported FBX meshes with duplicate materials #104669

Closed
opened 2023-06-04 19:44:12 +02:00 by Thomas Barlow · 2 comments
Member

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 531.41

Blender Version
Broken: version: 4.0.0 Alpha, branch: main, commit date: 2023-05-24 15:26, hash: 9acff4edabe5
Worked: 2.74

Caused by 8366db5686

Addon Information
Name: FBX format (5, 3, 0)
Author: Campbell Barton, Bastien Montagne, Jens Restemeier, @Mysteryem

Short description of error
Imported FBX with duplicate materials in one mesh import with faces assigned to the wrong materials.

This occurs because the importer skips adding duplicate materials, but the material indices are not adjusted to account for the skipped materials, so some faces end up assigned to the wrong materials.

if material not in done_materials:

This is the actual cause of the issue that was observed in #103976

Exact steps for others to reproduce the error
The attached .fbx can be produced by exporting the attached .blend as .fbx in Blender 3.4 and earlier (3.5 and newer currently have an export bug that affects this particular setup: #104665)

  1. Import the attached .fbx
  2. Compare the import with FBX Review, Unity, or other external software. The top and bottom faces should be green, 3 of the sides should be purple, and the last side should be red.
    image
    image
    image
**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 531.41 **Blender Version** Broken: version: 4.0.0 Alpha, branch: main, commit date: 2023-05-24 15:26, hash: `9acff4edabe5` Worked: 2.74 Caused by https://projects.blender.org/blender/blender-addons/commit/8366db568607ec20a5f087d3a156d2d4dd4f8f89 **Addon Information** Name: FBX format (5, 3, 0) Author: Campbell Barton, Bastien Montagne, Jens Restemeier, @Mysteryem **Short description of error** Imported FBX with duplicate materials in one mesh import with faces assigned to the wrong materials. This occurs because the importer skips adding duplicate materials, but the material indices are not adjusted to account for the skipped materials, so some faces end up assigned to the wrong materials. https://projects.blender.org/blender/blender-addons/src/commit/ace10568bf732164d22c2bcb92825a0b49b824cf/io_scene_fbx/import_fbx.py#L3332 This is the actual cause of the issue that was observed in https://projects.blender.org/blender/blender-addons/issues/103976 **Exact steps for others to reproduce the error** The attached .fbx can be produced by exporting the attached .blend as .fbx in Blender 3.4 and earlier (3.5 and newer currently have an export bug that affects this particular setup: https://projects.blender.org/blender/blender-addons/issues/104665) 1. Import the attached .fbx 1. Compare the import with FBX Review, Unity, or other external software. The top and bottom faces should be green, 3 of the sides should be purple, and the last side should be red. ![image](/attachments/f42a9a75-d3ff-4dc6-9fbb-54d2080d5b71) ![image](/attachments/c4d970ed-cc7e-4e71-a002-7254664b67f1) ![image](/attachments/31927c37-21e1-40de-aba0-f80ebddfb409)
Thomas Barlow added the
Type
Report
Priority
Normal
Status
Needs Triage
labels 2023-06-04 19:44:12 +02:00
Author
Member

I'm working on a fix for this.

Adjusting the material indices isn't viable because each Mesh can be used by multiple Objects and each Object can have different Materials or Materials in a different order. Though such Objects do not currently import correctly either.

Seeing as FBX Review doesn't support these Objects, it might be the case that they are deprecated.

The attached .fbx had to be manually created because Blender's FBX exporter gives each Object, that has materials linked to the Object instead of the Mesh, its own Mesh.

image
image
image
image

I'm working on a fix for this. Adjusting the material indices isn't viable because each Mesh can be used by multiple Objects and each Object can have different Materials or Materials in a different order. Though such Objects do not currently import correctly either. Seeing as FBX Review doesn't support these Objects, it might be the case that they are deprecated. The attached .fbx had to be manually created because Blender's FBX exporter gives each Object, that has materials linked to the Object instead of the Mesh, its own Mesh. ![image](/attachments/092873db-b345-4376-ba62-dd68acee48a6) ![image](/attachments/457fc247-de3c-4aad-9035-c41a6574fb26) ![image](/attachments/c4e0cb4b-00be-4316-b8aa-665b2dcbac24) ![image](/attachments/0883c686-9590-47b4-8cce-d6f58a8f244f)

I can confirm the problem.
Good to know a fix is being investigated :)

I can confirm the problem. Good to know a fix is being investigated :)
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-06-09 17:46:21 +02:00
Sign in to join this conversation.
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#104669
No description provided.