Community
FBX Forum
Welcome to Autodesk’s FBX Forums. Share your knowledge, ask questions, and explore popular FBX topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unable to correctly import material applied on a 3D model FBX file

1 REPLY 1
Reply
Message 1 of 2
adn-mgr
396 Views, 1 Reply

Unable to correctly import material applied on a 3D model FBX file

We are unable to correctly import material applied on a 3D model FBX file. Other aspects like structure, geometry is imported properly but the appearances go missing for attached file.

The issue is observed in FBX SDK version 2020.3.2 and 2020.3.4. We used ImportScene sample from FBX SDK to validate the difference in behavior.

For earlier version of FBX SDK 2020.2.1 - materials in mesh was mapped "By Polygon Vertex" with an empty indices array.
Now, in version 2020.3.4 - same material is mapped to "All Same" and Indices for this has single value of -1. We also get a warning while reading the FBX file with ImportScene sample -

********************************************************************************
WARNING:
The importer was able to read the file but with errors.
Loaded scene may be incomplete.

Last error message: [LayerElement] Bad value in array (Materials) would cause an out of bounds access
********************************************************************************

Reporting for -
FBX SDK version : 2020.3.2 and above

1 REPLY 1
Message 2 of 2
regalir
in reply to: adn-mgr

I am not sure that, before the use of 2020.3.2 the material was effectively assigned to the geometry. Starting with the FBX SDK 2020.3 we introduced more strict checks to validate that the incoming data is valid and meaningful. In the case you present here, there is already a red flags that is raised. As you noticed : "materials in mesh was mapped "By Polygon Vertex" with an empty indices array". Basically, this means that something is wrong with the file definition; a mapping by polygon vertices expects the index array to contains values indicating which polygon vertex have the mapped material. Please note that a value of -1 indicates that the given polygon vertex has no material "mapped". For example, these are valid definitions:

 

 

		LayerElementMaterial: 0 {
			Version: 101
			Name: ""
			MappingInformationType: "AllSame"
			ReferenceInformationType: "IndexToDirect"
			Materials: *1 {
				a: 0
			} 
		}

		LayerElementMaterial: 0 {
			Version: 101
			Name: ""
			MappingInformationType: "ByPolygon"
			ReferenceInformationType: "IndexToDirect"
			Materials: *8 {
				a: 0,0,1,1,-1,-1,2,2
			} 
		}

 

The first one, is used to map one material to the whole mesh. The second one to map three materials (0, 1, 2) on 6 of the 8 faces of a mesh. FYI, "Materials: " is the index array and the number after the * is its size. Also, I am not sure that mapping by polygon vertex is fully supported by all 3D programs that read FBX files. Typically, to color vertices you would use the VertexColor layer element structure, not the Material.

 

Finally, the message you are getting is to inform you that, indeed, the reader found the that the Layer Element is "badly"defined but still managed to compensate by returning a valid structure definition that will do nothing. This is why you are now getting a mapping "All Same" and one single index of -1.

 

You may try to "recuperate" the materials from your file, if you are convinced that it was working before 2020.3.x 😉 by re-saving the file after you properly define the LayerElementMaterial in memory. In other words:

  1. read the file (using 2020.2.1)
  2. Edit the LayerElementMaterial structure to guarantee the correct mapping & indices
  3. save the "fixed" scene back to an FBX file

At this point, the new file should be properly read by any FBX SDK (including the most recent ones)!

Hope this answered your questions.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report