Page MenuHome

Re-Exported OBJ/MTL files mutate multiple parameters
Closed, ArchivedPublic

Description

System Information
Operating system and graphics card
MacBook Pro - NVIDIA GeForce GT 330M

Blender Version
Broken: tested not working - 2.73, 2.74, 2.75
Worked: (optional)

Short description of error
Re-Exported OBJ/MTL files mutate ambient lighting, diffuse lighting, specular exponent and optical density parameters. These show up in the MTL file as the Ns, Ka, Kd, and Ni lines.

Exact steps for others to reproduce the error
File->Export->Wavefront (.obj)
save default cube as test.obj
delete the default cube object in blender
Edit the resulting test.mtl file, change file to look like

  1. Blender MTL File: 'None'
  2. Material Count: 1

newmtl Material
Ns 75
Ka .1 .2 .3
Kd .4 .5 .6
Ks .7 .8 .9
Ke .1 .2 .3
Ni 0.52
d 0.75
illum 2

Import test.obj and then export as test2.obj
You should find that test2.mtl does not match test.mtl.

Based on a (as simple as possible) attached .blend file with minimum amount of steps
NA

Event Timeline

John Gilbert (John_G) raised the priority of this task from to 90.
John Gilbert (John_G) updated the task description. (Show Details)
John Gilbert (John_G) edited a custom field.

Blender will also change "illum 0" to "illum 2". While technically a bug, illumination model modes are almost never used so probably not a priority.

Bastien Montagne (mont29) changed the task status from Unknown Status to Archived.Aug 12 2015, 10:53 AM
Bastien Montagne (mont29) claimed this task.

Thanks for the report, but no bug here, Blender does not edit .obj files, it imports and exports them, which implies conversions. Since OBJ material model does not match exactly Blender’s one, you cannot expect at all to get same results here.

Let me be more specific - this is a bug in the import and export of obj/mtl files.

If you import an obj/mtl file with diffuse lighting set to .4 .5 .6, it correctly shows up with the material diffuse of .4 .5 .6, but if you export it out it saves it as .32 .40 .48 - the values are incorrect.

Specular set to .7 .8 .9 again correctly shows up inside blender, but when exported becomes .35 .40 .45 which is incorrect.

There seems to be an "Emit" and "Ambient" value in the material shading section of Blender but they are both set to a single value - not an RGB value like in an OBJ/MTL file, but even so a Ke of .1 .2 .3 becomes 0, but is not exported - see the other bug I filed. The ambient value of .1 .2 .3 also becomes a 0 inside blender, and saves out as 0 0 0.

map_Ka, map_Kd, and map_Ks all load proper texture files into Blender, map_Ke is ignored (even though there is a map_Ke keyword handler in Blender's export_obj.py file). When you export the object, you only find the map_Ka and map_Kd populated. This is incorrect.

To summarize, Emissive and Ambiant lighting values and emissive texture maps are being ignored on import, and diffuse and specular values are corrupted on export and specular maps are dropped.

Any OBJ file edited by blender and saved back out will have all of its material properties mangled. Please consider this a serious bug.

Blender diff/spec has both color and factor setting, while mtl only has colors for those. On export, we multiply Blender's color with matching factor to get mtl values, which is OK. Issue was with importer, which used to only load colors, without modifying the default (0.8) factor to needed 1.0 value, this has been fixed recently.

So I believe that issue is fixed, please check with the latest build from our buildbot.

PS: ke is for other report, and this is really more like a TODO than a bug.