Description

Hello!

When importing .mtlx files that contain textures with the same name (but different filepaths), only the first texture is imported.

This seems to be due to the function CreateTextureNode() in MaterialXSurfaceShaderAbstract.h:

Line 342:

 if(MaterialX::InputPtr InputFile = Node->getInput("file"); InputFile && (InputFile->hasValue() || InputFile->hasInterfaceName()))
 {
 FString Filepath{ InputFile->hasValue() ? InputFile->getValueString().c_str() : InputFile->getInterfaceInput()->getValueString().c_str()};
 const FString FilePrefix = GetFilePrefix(InputFile);
 Filepath = FPaths::Combine(FilePrefix, Filepath);
 const FString Filename = FPaths::GetCleanFilename(Filepath);
 const FString TextureNodeUID = TEXT("\\Texture\\") + Filename;
 //Only add the TextureNode once
 TextureNode = const_cast<UInterchangeTexture2DNode*>(Cast<UInterchangeTexture2DNode>(NodeContainer.GetNode(TextureNodeUID)));
 if(TextureNode == nullptr)
 {
 TextureNode = NewObject<TextureTypeNode>(&NodeContainer);

As scene above, the TextureNodeUID is made unique only by the clean filename of the texture. This means it will fail to generate the right number of nodes when your textures are organized:

../diffColor/texture.tif

../opacity/texture.tif

Would it be possible to support the above file structure? Or is there a work around that can be done?

Steps to Reproduce
  • Import test_same_name.mtlx
  • Only one baseColor texture is imported

Expected results:

  • both baseColor.png texture should be imported

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-264945 in the post.

0
Login to Vote

Fixed
Fix Commit41522031
CreatedApr 2, 2025
ResolvedApr 10, 2025
UpdatedApr 16, 2025
View Jira Issue