obj and mtl

Hello!

I have an object (obj) file that comes with an mtl file and a kit of separate material files in the formats of jpg and png.

the mtl should be used to load these png's and jpg's into the obj, how do I make that happen?

Comments

  • Unfotunately there seems to be some variation in mtl files, and there's no guarantee that one exported from application A will apply correctly in Application B. MTL is very limited anyway, you would need to do some work so you may as well try aplying your own settings from scratch (or use asn existing shader preset of the right types and switch the maps in).

  • The .obj file format is ancient, so it's developed a lot of slight variations over the years in the different programs that can import/export it. Not all of these variations play nice with each other. The main things to watch out for are:

    • The first or second line of the .obj file starts with "mtllib" and contains a link to the name of the .mtl file. If this contains spaces, D|S can't find the .mtl file.
    • If the .obj and .mtl files have had their names changed from original creation, the file name will not match the link name and D|S can't find the .mtl file.
    • If the file name link is actually a folder path, the .obj and .mtl files must be in the location stated in the path. If not, D|S can't find the .mtl file. There's a pattern here somewhere...
    • These can be fixed by editing the filename line of the .obj file (it's just plain text) to remove the filename spaces or change them to an underline or dash; or change it to match the current actual name of the file; or delete the folder path leaving only the "mtllib" and the .mtl file name.
    • The same glitches crop up again in the .mtl file, with the names of the texture image files. Use the same fixes.
    • If you've removed folder paths from the .mtl file texture links, remember that the .obj, .mtl, and texture files should all be in the same folder. When you import the .obj file, D|S will find and read the .mtl file and use that to find and load the texture files.
    • Unless you've set the import tickboxes to ignore the .mtl file. Don't just clicky-clicky-OK it, read those tickbox options.

    I can't guarantee this will work 100% of the time, there's always the occasional file that's just plain bad, but it does usually work with most obj/mtl file pairs I've come across.

  • Spaces in names can be handled by putting quotes around the name, to indicate it's all one string of characters for a name.

  • Ah, I didn't realise that worked with .obj file parsing as well.

Sign In or Register to comment.