MTL Import

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  06 June 2013
Hi Jack,

I don't mean to hi-jack the thread - just to help - but having said that, I did want to mention that my Riptide Pro plugin [among hundreds of other useful things...] does of course read .mtl files (you can even select them directly, and read them instead of a .obj + .mtl, if you want).

With that out of the way, your script is useful for people who don't use my plugin, so...

Originally Posted by c4d-jack: I also noticed, that materials from many MTL come out transparent even though it makes no sense. The problem is: That is correct. The MTL file contains a transparency value of 1.0, which (according to the Wikipedia article) means 100% transparent.
I can imagine that some applications mean to interpret that as 100% opaque, but since there is no way to recognize that from the MTL file, I can't help it.

This is actually incorrect. The 'd' ("Dissolve" / transparency) record: 0 = completely transparent, 1 = completely opaque. As far as I know, there is no "Tr" keyword in the file format. I may not have seen the Wikipedia article you mention, but it sounds incorrect. This link is about the closest thing you'll find for the actual/original spec, although this link might be a little easier to follow.

Originally Posted by c4d-jack: You mean the textures, right? Well, the path is taken directly from the MTL file, and should be relative to the MTL file. Open the file with a text editor and take a look (the relevant lines start with "map_").
If a program exports MTL files with wrong paths, then I can't help it.

Technically, there should be NO path information in a .obj or .mtl file... (at least that is my contention). Note that the file format is so old that it didn't ever even address things like "spaces" in file names - spacing (white space) is instead used to separate record statements and qualifiers. Riptide Pro strips out any path information and let's Cinema 4D find texture files based on properly set up Cinema 4D "Texture Paths" preferences and/or it's own local searching (local tex folder, etc). I'd recommend doing the same.

Originally Posted by c4d-jack: MTL is just a very old, rather crappy and definitely outdated format. The script should simply help with getting the basic colors and textures assigned. Don't expect any high-end ready-to-render materials to come out of it.

Good point... just to add to that, you'll find that there are various levels of "horrible" implementations of importing/exporting .mtl files. Daz Studio (D|S) is notorious for "not following the spec", for example. Everything from including (it's own idea of) path information to inventing it's own keywords (and capitalization) for records.

To make a robust reader, Riptide Pro has the following "work-arounds":

  • as mentioned above, it strips any file-path info from texture map names
  • accepts "map_bump", "map_Bump" (and actually any capitalization of that) as meaning (the proper) "bump" keyword/record.
  • now (next update) parses keywords entirely case-insensitive (I got tired of patching up behind Daz Studio)'ll also find that some applications (the 3ds to obj converter program comes to mind) tend to write out more information than needed. The .mtl file format is a 'sparse' file format. If you don't need transparency, there shouldn't BE a 'd' record - but many applications just write one out, regardless. There are a few other similar issues (how "ambient" is interpreted, for example), that I try to account for in my plugin.

Anyway, I haven't seen/looked at your script yet, but I'll be interested in trying it out.



Last edited by Keith Young : 06 June 2013 at 04:24 AM.
  06 June 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 04:09 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.