OBJ and MTL files?

TimmothTimmoth Posts: 108
edited December 1969 in Technical Help (nuts n bolts)

Hi, I often buy products elsewhere that are in obj format, which is good because it loads on most programs.
These almost always come with their own .mtl file which has all the textures, etc.

In Daz Studio I import the .obj no problem, but it's always plain white.

How do I get the .mtl file to activate and give the object all it's textures?
Or is this not even how things works?

I'd be grateful for any help, thanks.

Comments

  • SimonJMSimonJM Posts: 5,982
    edited December 1969

    I've never, generally, had a problem - the only time i can recall I did it was the mtl file not having the correct pathing information to the texture files. If you point us to the item we might be able to have look if anyone else has it, or can get it.

  • TimmothTimmoth Posts: 108
    edited December 1969

    In this case it's this one:
    http://www.the3dstudio.com/ancient-babylon-422027

    but just about every obj that I import comes in white, even those that come with a mtl file. Are they supposed to be loaded at once or something? I've got no idea how this works.

  • SimonJMSimonJM Posts: 5,982
    edited December 1969

    If it were a freebie, I'd grab it ... but as it seems to be all .obj files is there a free one you have that we might both use?

  • ChoholeChohole Posts: 33,604
    edited April 2015

    It says that it has 3 zips and the jpg (texture) files are in zip 2 and 3. Did you download all 3 files?

    The MTL is quite often just a guide as to where the texture files are.

    Post edited by Chohole on
  • SpottedKittySpottedKitty Posts: 7,232
    edited April 2015

    There are several unobvious gotchas in the obj/mtl file format when it comes to object textures. Not all programs understand this file format in the same way; it's especially easy for another program to create files that D|S almost-but-not-quite understands properly. Note that the .obj and .mtl files are just plain text, you can open them in any text editor and fix most common problems. By default, the .mtl file is loaded along with the .obj file, but this can be changed with a tickbox in the .obj import dialog.

    * The .obj and .mtl file names are usually both the same. It isn't an automatic texture fail if they aren't, but it might indicate other problems.

    * The .obj file has a pointer reference to the .mtl file right at the beginning. Both obj and mtl files ought to be in the same folder. If the .mtl file reference indicated it's in a subfolder relative to the .obj file, the textures won't load. And, of course, vice-versa.

    * If the .mtl file name contains spaces, the textures won't load when you load the .obj file. Open the .obj file in a text editor, find the .mtl file reference at the top (in a line starting with "mtllib"), and either enclose the name in "quote" marks, or change_the_spaces_to_underlines. If you do the latter, remember to change the name of the .mtl file itself.

    * Check that the file references to the textures in the .mtl file do actually point to where the texture files are on your computer. Some .mtl files are created with full folder paths to each file, as they exist on the computer of the object creator. Some 3D graphics programs place all the textures in a subfolder of the location of the .obj file. If this doesn't match where you've actually placed the texture files, they won't load. Fix this by doing whichever is easier for you, move the texture files to match where the .mtl file says they should be, or edit the .mtl file so the texture references match where you've put the texture files.

    One final note: the .obj file format is very, very old, predating most 3D programs commonly used today, and some parameters are read in odd ways by D|S, especially Specular, Ambient and Bump. There might also be colour settings in Diffuse Color which D|S doesn't need. Watch out for surfaces rendering in odd ways, it usually means you'll need to tweak the parameters for that material.

    Post edited by SpottedKitty on
  • TimmothTimmoth Posts: 108
    edited December 1969

    Thanks for the explanation SpottedKitty, and evrybody else for your suggestions. I'm manually applying the textures myself atm, and fiddling around with my own bump, settings, etc. but you're right SpottedKitty, it does render with some odd angled lines through things...

  • algovincianalgovincian Posts: 2,613
    edited December 1969

    Timmoth said:
    Thanks for the explanation SpottedKitty, and evrybody else for your suggestions. I'm manually applying the textures myself atm, and fiddling around with my own bump, settings, etc. but you're right SpottedKitty, it does render with some odd angled lines through things...

    The .mtl file is just a text file - you should be able to edit the image file references to point to the actual places the images reside. There can be issues with relative/absolute directories, and how slashes/backslashes are used and handled.

    - Greg

  • mjc1016mjc1016 Posts: 15,001
    edited December 1969

    The basic fact is that the mtl file is a guide to what the creator of the item did...it's not something engraved in stone that has to be followed upon pain of death or anything. Sometimes it makes it easier...most of the time it doesn't, at least when it comes to setting up Studio materials. Also, unless it's a basic surface, it's not going have all the settings, anyway, so Studio is going to put in default values.

    More often than not, I just open them in a text editor and read which images go where and manually load them there in Studio...it's usually quicker than trying edit the mtl to remove absolute paths or other things to get the mtl to work.

    I also accept the fact that until I get the item in Studio, create Studio native materials for it and then save it in a Studio format, in a Studio content hierarchy it's not going to 'work'. It's just 'bare' geometry, until it's 'done'.

    It saves a lot of frustration, if going in, you realize it's not a finished product, but rather more like an Ikea dresser...

  • SpottedKittySpottedKitty Posts: 7,232
    edited December 1969

    Timmoth said:
    it does render with some odd angled lines through things...

    What kind of "odd angled lines"? Can you post a screenshot? It is possible there's a glitch in the mesh that other programs (e.g. Poser) gulp down without a hiccup, but D|S chokes a bit on. One of the more common is "reversed normals" — the polygons that make up 3D objects have definite "front" and "back" sides, and in the past some programs weren't too fussy about which way round things went. This can affect how textures applied to reversed polygons get rendered. It's usually fixable, with a bit of work, but it's annoying.
Sign In or Register to comment.