When I export .obj files from scenes that use Cycles (and thus, materials with nodes etc), the material colours are not preserved in the .mtl file.

So, what can I do to avoid this?

  • 1
    $\begingroup$ Have you tried setting the veiwport color? $\endgroup$
    – Vader
    Oct 24, 2013 at 20:37
  • 1
    $\begingroup$ I can confirm that the viewport color in Materials > Settings > Viewport color does get exported as obj colors. (to make setting viewport colors easier, you can cut and paste colors by pressing Ctrl+C and Ctrl+V while hovering over color selectors.) $\endgroup$
    – gandalf3
    Oct 24, 2013 at 22:12
  • $\begingroup$ I never noticed that option! Weird... $\endgroup$ Oct 24, 2013 at 22:41

1 Answer 1


As mentioned by Jebediah Kerman, the viewport color in Material > Settings is exported to the .mtl file:

enter image description here

If you only have a few simple materials, it can be quite trivial to copy the colors by using CtrlC and CtrlV while hovering over the color selection boxes.

If you have many materials, you could write a python script to take colors from the node tree and set the viewport color accordingly.

For example, here is a simple script that looks for diffuse shaders and sets the viewport color to the color of any diffuse shaders found:

import bpy

for mat in bpy.data.materials:
    if mat.use_nodes == True:
        tree = mat.node_tree
        for node in tree.nodes:
            if node.type == "BSDF_DIFFUSE":
                col = node.inputs["Color"].default_value
                mat.diffuse_color = (col[0],col[1],col[2])

Note that the Viewport color is actually diffuse_color.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .