Back To Pinshape   |   Blog   |   Contests

3D Printing Forum - Pinshape

Editing MTL files for color Clara.io viewing

I figured I’d post something about how to get your textures visible in the Clara.io viewer since people seem to be stuck on this. First off the trouble comes from your 3d program having a sucky exporter for .OBJ files (specifically Maya & 3DSMax). It basically will always export a default .MTL that you will need to edit in order to be able to view the textures. I use Notepad++ to edit my files, you can download it here.

So for starters lets say I just exported my mesh as a .OBJ with the default settings, this is what I see when I open up my .MTL in Notepad++:

newmtl bodySG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd kaijulow_dif.png
Ni 1.00
newmtl eyeSG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd eyeBlue.png
Ni 1.00
newmtl lowerjawSG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd lowerjaw_dif.png
Ni 1.00
newmtl lowerteethSG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd lowerteeth_dif.png
Ni 1.00
newmtl pedistalSG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd pedistal.png
Ni 1.00
newmtl tongueSG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd tongue_dif.png
Ni 1.00
newmtl upperjawSG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd upperjaw_dif.png
Ni 1.00
newmtl upperteethSG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd upperteeth_dif.png
Ni 1.00

It looks like a bunch of junk, but stick with me, I’ll explain:

newmtl - Is the material that was applied to the mesh so each time you see newmtl (Name) thats a material that was in your Hypershader

Ka - Ambient settings (R,G,B)

Kd - Diffuse settings (R,G,B)

Ks - Specular settings (R,G,B)

map_Ka - If you had a texture map for your shaders ambient channel

map_Kb - If you had a texture map for your shaders diffuse channel

map_Ks - If you had a texture map for your shaders specular channel

illum - This defines what kind of shader you are using

ex. of illum:
0 Color on and Ambient off
1 Color on and Ambient on
2 Highlight on
3 Reflection on and Ray trace on
4 Transparency: Glass on
Reflection: Ray trace on
5 Reflection: Fresnel on and Ray trace on
6 Transparency: Refraction on
Reflection: Fresnel off and Ray trace on
7 Transparency: Refraction on
Reflection: Fresnel on and Ray trace on
8 Reflection on and Ray trace off
9 Transparency: Glass on
Reflection: Ray trace off
10 Casts shadows onto invisible surfaces

We only really care about 0 and 1, Maya always defaults to 4 when a .OBJ is exported.

Tf - transmission filter of the current material (we won’t be using it)

Ni - specifies the optical density for the surface. This is also known as
index of refraction (we won’t be using this either)

Ok so now back to Notepad++, I’m focusing on just newmtl bodySG to show as an example.

Change This:
newmtl bodySG
illum 4
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
map_Kd kaijulow_dif.png
Ni 1.00

To This:
newmtl bodySG
illum 1
Kd 0.00 0.00 0.00
Ka 0.00 0.00 0.00
Ks 0.00 0.00 0.00
map_Kd kaijulow_dif.png

I set the illum to 1, remove Tf and Ni since they are unnecessary and add in Ks 0.00 0.00 0.00 since I want my model to be flat shaded and not have any specular. Also please check to make sure you aren’t using targas. since TGAs won’t upload.

You can read more indepth about .MTL editing here. Also don’t thank me, thank Paul Bourke, since he’s the one who I referenced for all my information.

GOOD LUCK!

Also I use Maya but if you’re using 3DSMax this link should help you out.

Hi JanaBee,

Thanks for the outlining the trouble you are running into and your fixes. I’m from Clara.io and I’m looking at the code of Clara.io right now.

It looks like we were not supporting at all the Tr parameter. I have just added support for it. And we are now interpreting it as Autodesk’s products save it – Tr 1 1 1 is assumed to be not transparent, where as Tr 0 0 0 is transparent.

I have looked and we are not supporting the illum parameter, we just always read all aspects of the MTL file and use what is specified.

You are correct that if you do not want a white specular highlight, you need to edit Ks or edit it directly in Clara.io (which I think is easier.) This is the most important edit you suggest!

You can leave Ni if if you want as it only affects transparent materials and thus will have no effect on solid printable objects.

Also TGA files are supported these days by Clara.io - we added support in roughly around June/July 2014. Do you have some TGA that are not importing?

Best regards,
Ben Houston

EDIT: I replaced a more generic response with a specific response after doing some research in the Clara.io code base.

Thanks for writing this up.

I’m having an issue where only one texture map is being read and is being applied to the entire model. There are two PNGs used for the diffuse. Not sure if this is something that would eventually apply to the print (suspecting it wouldnt).

https://pinshape.com/items/1523-3d-printed-shuttle-launch-xl

Hey Skye,

It looks like for printing purposes, it should be working as expected and there shouldn’t be issues due to this, even though the viewer isn’t showing it.

@Ben Houston - I haven’t had an issue with Clara.io directly, I’ve used your site to generate my own scene file, the problems stem from the automatically generated clara.io scene.

@schuylerwhite - I have a similar issue where the kaijulow_dif.png is being applied to the whole model instead of it recognizing the other materials.