Obj's and mtl's?

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

Hello,
I often buy non-Daz products, sometimes made for other programs, like Vue, etc. but as long as they mention that an Obj version is included I don't mind, because Daz is capable of handling that basic format.

I keep the .obj, .mtl and all texture files in a single folder together - except then when I import the .obj's many of them load without textures. :shut:
Which means digging up the folder the textures are in and applying them manually, but also then having to figure out custom bump, transparency, displacement settings, etc. for every single surface.
I believe the .mtl file is supposed to do all this automatically? but I often find it doesn't, which is the problem.

If I've got it wrong then what is an .mtl file?
and is there a way to get the textures automatically / properly applied?

Thanks. :cheese:

Comments

  • KhoryKhory Posts: 3,854
    edited December 1969

    Your correct that .mtl files are material files but the reality is that there is not perfect continuity across programs. While ideally it should at least load maps you would still end up fixing all the settings so that they looked right.

  • MattymanxMattymanx Posts: 6,879
    edited December 1969

    In theory, the program loading the OBJ SHOULD read the MTL file and load things so you dont have as much work to do. However, I cannot count the number of times that an OBJ saved out of Carrara does NOT show up in DS with any colour or maps, but then the next model will. Usally, I can use PoseRay to load the same file and export a new OBJ and DS will load it fine with colours and maps. Just my experiance!

  • niccipbniccipb Posts: 483
    edited December 1969

    Hi...

    I agree with what both Khory and Mattymanx have said and my experience with OBJ and MTL files has always been hit or miss with any given App.

    What I generally do is import into an App that it works in and can export usable files to the App I want to use. Although sometimes it could take running it though a few different Apps to reach it's final destination and I only do that if I reeeally want to use it...

  • TimmothTimmoth Posts: 108
    edited December 1969

    Okay, thanks everyone.
    I'll have to dig out Poseray again, and learn how to use it this time. :)

  • macleanmaclean Posts: 2,438
    edited August 2012

    Nevermind. I misunderstood the OP.

    mac

    Post edited by maclean on
  • Takeo.KenseiTakeo.Kensei Posts: 1,303
    edited December 1969

    It can happen when the textures are not found in the path the mtl file points to. Just edit the mtl file and delete all path reference since you put them in the same folder

  • BejaymacBejaymac Posts: 1,848
    edited August 2012

    DS is actually reading the MTL, the problem is that the pathway to the texture in MTL isn't what DS needs it to be, most programs only save the texture name and can quite happily load the textures from the same folder that the MTL is in, DS however needs the full pathway including the drive letter before it can find and load the texture.

    I should add that MTL's have even less usable surface info for us than we get from an MC6, so your probably better off loading the textures yourself.

    Post edited by Bejaymac on
  • WendyLuvsCatzWendyLuvsCatz Posts: 37,867
    edited August 2012

    I have a related question regarding mtl files
    I did a capture from GTA San Andreas usind 3D ripper dx, the resulting texture maps were .dds format
    converted them to .jpg and replaced dds with jpg in the mtl file but still will not load on the obj

    and before some one posts with an irrelevant comment about mesh copyright BLAH BLAH BLAH ad nauseum
    this is for personal use, no redistribution, prob no renders but I cannot promise that (posted a couple already), certainly not for commercial use, just fan art.

    anyway a daz export getsa mtl file like this, example LB strawberry

    newmtl SBerry1
    d 1
    Ns 0.95
    Ni 0
    Ka 0 0 0
    Kd 1 1 1
    Ks 0.6 0.6 0.6
    Km 0.02
    map_Kd /Maps/LB_SBerry01.jpg
    
    newmtl SBLeaf1
    d 1
    Ns 0.95
    Ni 0
    Ka 0 0 0
    Kd 1 1 1
    Ks 0 0 0
    Km 0.02
    map_Kd /Maps/LB_SBerry01.jpg
    map_D /Maps/LB_SBerry01TR.jpg
    
    

    the GTA one (jpg replacing dds looks like this
    (partial extract, has 900+ textures!!0
    newmtl material_0
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.0
    illum 2
    map_Kd 00000000.jpg
    #
    newmtl material_1
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.0
    illum 2
    map_Kd b8c4e313.jpg
    #
    newmtl material_2
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.0
    illum 2
    map_Kd 56cdf600.jpg
    #
    newmtl material_3
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.0
    illum 2
    map_Kd 236023d5.jpg
    #
    newmtl material_4
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.0
    illum 2
    map_Kd 19920393.jpg
    #
    newmtl material_5
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.0
    illum 2
    map_Kd 112cf947.jpg
    #
    newmtl material_6
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.0
    illum 2
    map_Kd 69bae049.jpg
    #
    newmtl material_7
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.0
    illum 2
    map_Kd 6afd279c.jpg
    #
    newmtl material_8
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.0
    illum 2
    map_Kd 1fa394e8.jpg
    #
    newmtl material_9
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.0
    illum 2
    map_Kd 4409b764.jpg
    #
    newmtl 

    so other than the # 's maybe, what must I change in notepad?
    help, suggestions appreciated :)
    Post edited by WendyLuvsCatz on
  • WendyLuvsCatzWendyLuvsCatz Posts: 37,867
    edited December 1969

    I have tried without succes using find and replace to imitate the Daz example

     newmtl_0
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.02
    map_Kd / 00000000.jpg
     
    newmtl material_1
    Ka  
    
    0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.02
    map_Kd / b8c4e313.jpg
     
    newmtl material_2
    Ka  0.6 0.6 0.6
    Kd  
    
    0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.02
    map_Kd / 56cdf600.jpg
    
    newmtl_3
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  
    
    1.0
    Ns  0.02
    map_Kd / 236023d5.jpg
    
    newmtl_4
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.02
    map_Kd / 
    
    19920393.jpg
    
    newmtl_5
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.02
    map_Kd / 112cf947.jpg
    
    newmtl_6
    Ka  
    
    0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.02
    map_Kd / 69bae049.jpg
     
     newmtl_7
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  0.02
    map_Kd / 6afd279c.jpg
    
    newmtl_8
    Ka  0.6 0.6 0.6
    Kd  0.6 0.6 0.6
    Ks  0.9 0.9 0.9
    d  1.0
    Ns  
    
    0.02
    map_Kd / 1fa394e8.jpg
    
    
  • niccipbniccipb Posts: 483
    edited December 1969

    Hi Wendy...

    Well first off I'll have to admit that I never really bothered to learn the details of the MTL file :red: , but I do know my way around an OBJ

    So I decided to have a read of the MTL file format specs and the one you posted as an example looks okay off hand. The # are for comment lines and make no difference on the workings of the file.

    So as Takeo.Kensei and Bejaymac have said, the paths for the textures need to be correct.

    From your example : GTA.obj , GTA.mtl and GTA.jpg would all need to be in the same folder
    ie: folder/GTA.obj folder/GTA.mtl folder/GTA.jpg

    or since the line that lists only the texture JPG and not a folder structure like the DS export does, the JPG files should just live in the same folder right next to the OBJ and MTL files

    The only other thing that I could think of that may be a problem is in the OBJ if the material or surface grouping lines are named differently and not calling the MTL file.

    Sorry if this was a bit on the confusing side, my brain tends to wonder that way when I thinking to much... anyway Maybe one of the others can further aid in this... :)

  • WendyLuvsCatzWendyLuvsCatz Posts: 37,867
    edited December 1969

    if I open the obj file in notepad, it is all in japanese! usually they are mathematical functions, symbols and stuff, the textures load ok manually, it is uv mapped but finding which of the 900+ images map to which surfaces rather daunting. I have tried them in the same folder as well as under maps.

  • niccipbniccipb Posts: 483
    edited December 1969

    Notepad is not a good viewer for OBJ's or MTL's in general. The formatting is horrid. Try Notepad++ or PSPad they keep the file formatting intact.

    There are text lines in the OBJ and they name the matlib and surface groups. If the mesh has a large vert count the OBJ can be ten's of thousand of lines long. But a word search can find the lines quickly.

    I'm not sure that the problem is in the OBJ though, it was a thought I was grasping at.

    With 900+ maps matching those to the surfaces manually will be like doing one of those 1000 piece puzzles...maybe worse... and the OBJ and MTL file info won't be of any help in doing it.

    So if the maps are in the correct relative paths according to the MTL file... I'm kind of back to square one with my earlier suggestion... :down:

    Anyone else have an idea...

  • Takeo.KenseiTakeo.Kensei Posts: 1,303
    edited December 1969

    @Wendy : Your mtl file seems good to me. You don't have to bother with the # sign it's just the comment sign

    There may also be some corrections to bring to the obj file as stated niccipb

    At the beginning of the obj file you must have a reference to your material library used with the following declaration :

    mtllib YOURMATERIALLIB.mtl


    then it will also declare geometries and which material to use in your library for all declared objects or groups.

    Look for "usemtl" in your object file and see if the material names match your mtl file.

  • WendyLuvsCatzWendyLuvsCatz Posts: 37,867
    edited December 1969

    I will have another look at it later (not on computer)
    the reason I want to solve this is 3d ripper dx will grab mesh from any directX app and while it can only be for personal use I find it fascinating getting the objects into Carrara etc and playing with them, it is interesting to see how low poly they are and how complex scenes you see in games are basically cubes and transmapped planes.

  • macleanmaclean Posts: 2,438
    edited December 1969

    This might help you. It's a quote from Rob Whisenant from some years back explaining how DS reads a .mtl file. I copied it at the time as being useful information.

    Here is what the mtl statements mean to D|S... both import & export. Whether the information carries over to another application is up to that application and whether it supports a given statement (and/or how).

    d = Dissolve (aka Opacity/Transparency)(some may read 'Tr' instead - D|S reads both)
    Ns = Shininess (aka Glossiness - Focus of Specular Highlight)
    Ni = Optical Density (aka Index of Refraction)
    Ka = Ambient Color
    Kd = Diffuse Color
    Ks = Specular Color
    Km = Bump Strength (some may read 'bump' instead)

    map_Ka = Ambient Color Map Path
    map_Kd = Diffuse Color Map Path
    map_Ks = Specular color Map Path
    map_D = Dissolve Map Path (some may read 'map_d' instead)
    map_Bump = Bump Map Path (some may read 'map_bump' or 'map_Km' instead)
    map_refl = Environment Map Path (some may read 'refl' instead)

    D|S supports both relative and absolute paths for maps. Paths which contain spaces should be enclosed by quotes. Typically, importers expect the map to be in the same directory as the obj and mtl (or at a path specified by an environment variable)... D|S doesn't care as long as the path is correct.



    mac
  • WendyLuvsCatzWendyLuvsCatz Posts: 37,867
    edited December 1969

    @Wendy : Your mtl file seems good to me. You don't have to bother with the # sign it's just the comment sign

    There may also be some corrections to bring to the obj file as stated niccipb

    At the beginning of the obj file you must have a reference to your material library used with the following declaration :

    mtllib YOURMATERIALLIB.mtl


    then it will also declare geometries and which material to use in your library for all declared objects or groups.

    Look for "usemtl" in your object file and see if the material names match your mtl file.
    it is the obj file that is the issue
    I added mtllib frame_18.08.2012_17.44.16.mtl to the begining now it says material library cannot be found upon loading
    (and no, NOT in "Japanese or heiroglyphics" that was the .dr file oops that you use with the 3ds Max plugin that everyone on the net uses instead!!!)
    it is just a list of values/parameters, here is an extract, I added the name of the mtl frame at the begining
    mtllib frame_18.08.2012_17.44.16.mtl#AR=1.34039, FOV=55.98316(height), Xscale:0.71245, Yscale:0.53152,

    Zscale:1.0
    #**************************************************
    #ALPHABLENDENABLE: No
    #ZENABLE: No
    #ZWRITEENABLE: No
    #TWOSIDED: Yes
    #INVALID: No
    #THIN: Yes
    #RENDERTARGET_IS_BACKBUFFER: No
    #WIDTH_DO_MATCH: No
    #RGBWRITEDISABLED: No
    # object DrawCall_0 to come ...
    g
    v -0.08441 -0.18842

    1.00000
    v 0.07255 -0.18869 1.00000
    v -0.01966 -0.17910 1.00000
    v 0.09744 -0.18640 1.00000
    v 0.05269 -0.18170

    1.00000
    v 0.08095 -0.18174 1.00000
    v -0.09219 -0.18596 1.00000
    v 0.03662 -0.19215 1.00000
    v -0.04607 -0.19104

    1.00000
    v -0.00502 -0.18987 1.00000
    v -0.00502 -0.18987 1.00000
    v 0.06366 -0.56252 1.00000
    v -0.02577 -0.53031

    1.00000
    v 0.03222 -0.55923 1.00000
    v -0.02750 -0.53779 1.00000
    v -0.01248 -0.55285 1.00000
    v -0.01248 -0.55285

    1.00000
    v 0.06969 -0.56314 1.00000
    v 0.01558 -0.54229 1.00000
    v 0.03794 -0.55807 1.00000
    v 0.03794 -0.55807

    1.00000
    v -0.08916 -0.18636 1.00000
    v -0.05329 -0.18297 1.00000
    v 0.08870 -0.18730 1.00000
    v 0.05319 -0.19066

    1.00000
    v -0.03269 -0.53252 1.00000
    v -0.00544 -0.53536 1.00000
    v -0.01739 -0.54391 1.00000
    v 0.02728 -0.57466

    1.00000
    v 0.02728 -0.57466 1.00000
    v 0.01400 -0.56422 1.00000
    v -0.00439 -0.55226 1.00000
    v 0.05337 -0.59564

    1.00000
    v 0.04497 -0.57989 1.00000
    v 0.05464 -0.58995 1.00000
    v -0.02481 -0.56706 1.00000
    v 0.04713 -0.61512

  • WendyLuvsCatzWendyLuvsCatz Posts: 37,867
    edited August 2012

    success! yay, happy dance
    I exported the imported obj from Daz studio!!!!
    then
    Replaced the Daz studio mtl file with the original!!
    with mtllib name of file.mtl at the begining and all the textures loaded upon reimport!
    needs tweaking ie opacity maps etc but a start

    Untitled.jpg
    1920 x 1080 - 779K
    Post edited by WendyLuvsCatz on
  • niccipbniccipb Posts: 483
    edited December 1969

    Hi Wendy...

    I was looking over your screen shots trying to find a problem and the only thing that catches my eye off hand is that there is no space after the MTL file name and the # comment

    Try entering a return after mtllib frame_18.08.2012_17.44.16.mtl so that #AR=1.34039, FOV=55.98316(height), Xscale:0.71245, Yscale:0.53152,Zscale:1.0 is on a separate line

    mtllib frame_18.08.2012_17.44.16.mtl
    #AR=1.34039, FOV=55.98316(height), Xscale:0.71245, Yscale:0.53152,Zscale:1.0

    It's thinking the whole thing is the file name.

  • niccipbniccipb Posts: 483
    edited December 1969

    success! yay, happy dance
    I exported the imported obj from Daz studio!!!!
    then
    Replaced the Daz studio mtl file with the original!!
    with mtllib name of file.mtl at the begining and all the textures loaded upon reimport!
    needs tweaking ie opacity maps etc but a start


    Congrats!!! :cheese:

    glad you got it working.

Sign In or Register to comment.