When I export the .obj file, the generated .mtl does not specify the texture image used by the model.

I expected it to have

map_Kd texture.png

but it does not have it. If I write map_Kd texture.png manually, it works fine.

How can I automate to include the texture image when exporting from blender?

This is my shading scheme:


  • 1
    $\begingroup$ Displacement socket on Material Output is now a Vector field and should typically never be connected without a 'Displacement' node (Displacement or Vector Displacement). I don't know whether MTL supports such displacement connections. $\endgroup$ Jun 17 '20 at 11:30
  • $\begingroup$ This has already been answered here, including a link to the relevant manual page. $\endgroup$
    – Robert Gützkow
    Jun 23 '20 at 13:22

The textures color output should be attached to the color input of the shader (Diffuse BSDF in your example), for it to be exported into the mtl file.

Edit: It seems the PrincipleBSDF shader node (instead of DiffuseBSDF) is needed for the .obj / .mtl export to function properly!


  • $\begingroup$ According to the Wavefront mtl specification map_Kd is the diffuse texture. So the texture that you want to be exported as map_Kd should be set as an input to the diffuse color. $\endgroup$ Jun 17 '20 at 10:36
  • $\begingroup$ I cant do this. Im using the model in 'babylonjs' and I need the ability to change the color of the texture programmatically by changing diffuse color = x then the texture color will change. If I assign the texture image as color, when I change the color programmatically, the texture will be gone. $\endgroup$ Jun 17 '20 at 16:18
  • $\begingroup$ Agree with Simon, this would result in map_Kd texture.png (what you are asking for in your question). Sounds like an issue with 'babylonjs' rather. Can you elaborate on that? @AlvinStefanus $\endgroup$
    – brockmann
    Jun 18 '20 at 10:00
  • $\begingroup$ There is no problem with babylon.js at all. The exported .mtl is the problem. I have found a way to fix it by connecting the image texture into both displacement and pricipled BSDF (which will produce the correct mtl file). The base color of Principled BSDF is changed within the babylon.js and produce what I want. The texture is shown and also the flexibility to change the base color of the texture. $\endgroup$ Jun 21 '20 at 9:25
  • $\begingroup$ Glad you found a solution! $\endgroup$ Jun 23 '20 at 11:07

I solve the problem with this schema

enter image description here

  • $\begingroup$ How this is different to Simon's answer one week ago? $\endgroup$
    – brockmann
    Jun 21 '20 at 23:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.