StaticMesh export to FBX crashes if UVElements has more channels than VertexInstanceUVs

As I indicated in the repro steps, we have a StaticMesh asset that, for some reason, has a mismatch in its serialized bulk data where:

  • MeshDescription->GetNumUVElementChannels() == 2
  • FStaticMeshConstAttributes(MeshDescription).GetVertexInstanceUVs().GetNumChannels() == 1

When exporting to FBX with bExportSourceMesh = true, in FFbxExporter::ExportStaticMeshFromMeshDescription:

  • TexCoordSourceCount = 2, so the loop that creates UV layer runs with TexCoordSourceIndex = 1
  • It calls VertexInstanceUVs.Get(VertexInstanceID, TexCoordSourceIndex)
  • As VertexInstanceUVs has only one channel, it crashes.

Have you seen this on your end? Should the call to MeshDescription->GetNumUVElementChannels() be changed to VertexInstanceUVs.GetNumChannels() instead?

(cc: Alexis Matte)

[Attachment Removed]

Steps to Reproduce

  • Note: I don’t know how to create an asset that matches this first step - somehow one of our project assets ended up in that state: In the Content Browser, pick a StaticMesh asset that has its bulk data serialized such that its MeshDescription’s UVElements has more channels (e.g. 2) than FStaticMeshConstAttributes::GetVertexInstanceUVs (internally, VertexInstanceAttributes().GetAttributesRef<FVector2f>(MeshAttribute::VertexInstance::TextureCoordinate):wink:
  • Right-click on the asset in the Content Browser and select Asset Actions -> Export
  • Check the option to “Export Source Mesh”
  • Export to FBX.
  • Observe the crash, where the log says “Array index out of bounds: 1 into an array of size 1”
    [Attachment Removed]

Hi Manu,

Sorry for the inconvenience.

I have opened a bug to track this issue.

We will do our best to fix it for next new version of UE.

Thanks for your patience.

Regards,

Jean-Luc

[Attachment Removed]