Jump to content

[SOLVED] Importing OBJ+MAT issue


photo

Recommended Posts

Hello,

I have *a lot* of legacy textured objects to import (>500). These are in wavefront OBJ format with their companion .OBJ.MAT file.

Attached two objects with their Mat and Textures:

  • objobj.zip
    • obj/Manoeuvres: the obj and mat
    • obj/Txt: the textures

 

  • If I import the object by drag'n dropping the OBJ to a folder in the Asset browser, only the mesh is imported, not the material and the texture.
    • But this is the only way I found to have a chance to configure the Importer (eg setting the axis)
  • If I import all objects at once by dropping their "obj" folder into the Asset browser, then the mesh and textures are imported, but they are incorrectly assigned
    • eg. MAT reference ../Txt/red.png but the material assigned will use "AnotherOne.png" in albedo.

What is the correct procedure?

Link to comment

Hi Stephane,

To import .OBJ and get correctly assigned textures and created materials you will need to drag and drop both .OBJ and .MAT file to the asset browser simultaneously (or drop the whole directory). After that you can tune import settings and hit a reimport button. That's not an ideal pipeline, but this is limitation of FBX SDK that we are using. We have couple of ideas how to improve this behavior and probably the process will be simplified in the future.

Now moving to the wrongly assigned textures. If you check both files you will see that they have overlapping material names:

// MTL: slalom_8.obj.mtl and tracking.obj.mtl
newmtl 0
newmtl 1
newmtl 2

// OBJ: slalom_8.obj and tracking.obj
usemtl 0
usemtl 1
usemtl 2

By default meshes are trying to use already existing materials in the project, so when you import second mesh it will reuse the material (and it's textures) from the first imported file.

To fix this you either can:

  • Write tool for parsing and fixing overlapping names inside .MTL/.OBJ files (or fix them manually)
    OR
  • Use material prefix in the asset import settings to generate unique material name:
    image.png

Final results:
image.png

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Ok, I understand now! In my case, I think I will go with a script that simply rename the material in the MAT files.

A small suggestion: "add prefix" could use an option to be either a fixed string (as it is now) or an automatic string based on the object name, so one could import a full folder (like I do), because the fixed string is only useful if you import OBJ one by one.

Thanks!

Link to comment
  • silent changed the title to [SOLVED] Importing OBJ+MAT issue
×
×
  • Create New...