Some DCC packages do not export this layer if there’s only one FBX material assigned to the node and all the mesh polygons use that same material. Simple fix in FbxSkeletalMeshImport.cpp:
if (LayerElementMaterial)
{
switch(MaterialMappingMode)
{
// material index is stored in the IndexArray, not the DirectArray (which is irrelevant with 2009.1)
case FbxLayerElement::eAllSame:
{
Triangle.MatIndex = MaterialMapping[ LayerElementMaterial->GetIndexArray().GetAt(0) ];
}
break;
case FbxLayerElement::eByPolygon:
{
int32 Index = LayerElementMaterial->GetIndexArray().GetAt(LocalIndex);
if (!MaterialMapping.IsValidIndex(Index))
{
AddTokenizedErrorMessage(FTokenizedMessage::Create(EMessageSeverity::Warning, LOCTEXT("FbxSkeletaLMeshimport_MaterialIndexInconsistency", "Face material index inconsistency - forcing to 0")));
}
else
{
Triangle.MatIndex = MaterialMapping[Index];
}
}
break;
}
}
else //if we dont have a material id layer, assume all triangles use the first material
Triangle.MatIndex = MaterialMapping[0];
The else branch at the end I added fixes the problem.
Also, both the times the _skinXX suffix is removed, the string manipulation is done WRONG.
In UnFbx::FFbxImporter::CreateUnrealMaterial
line
MaterialFullName = MaterialFullName.LeftChop(Offset+1);
should be
MaterialFullName = MaterialFullName.Left(Offset);
In UnFbx::FFbxImporter::SetMaterialSkinXXOrder
line
ImportData.Materials[MaterialIndex].MaterialImportName.LeftChop( Offset );
this line does NOTHING without an assignment operator, and also LeftChop should be just Left, like so
ImportData.Materials[MaterialIndex].MaterialImportName = ImportData.Materials[MaterialIndex].MaterialImportName.Left( Offset );
(if you didn’t actually want to remove the SkinXX suffix from the MaterialImportName, just remove this line and comment, as it is confusing)