1
$\begingroup$

I'm on Blender v2.83.1 and I want to export obj to upload into an other software.

When the software is run, I get an error saying that it cannot find the texture files that are stored in the .mtl file. I have a hunch that this is due to the way blender stores file paths in an .mtl when we export an .obj.


In such a situation, a fix is to manually copy paste the image files into the obj folder, and manually change the mtl file in order to remove the file path to only keep the file name

ex) changing "map_Kd c:\folder\image_name.png" into "map_Kd image_name.png" for all image path.

Is there a way to export my obj file so that my .mtl file will work correctly with the software?

$\endgroup$
2
  • 1
    $\begingroup$ Set Transform > Path Mode to Copy on the OBJ export screen. I'm pretty sure that does what you're asking for. $\endgroup$
    – scurest
    Aug 25, 2021 at 8:28
  • 1
    $\begingroup$ Hi scurest thank you I should have figured that myself... It is not perfect though I only get the bump image files copied into the folder but at least the mtl has correct paths! $\endgroup$
    – Lea
    Aug 25, 2021 at 8:45

2 Answers 2

0
$\begingroup$

For those that export to .obj frequently and don't like to have to select 'Copy' every time try this:

Blender 2.79 change default Path Mode to Copy

  1. Navigate to the io_scene_obj folder in your addons folder <YOUR PATH>\scripts\addons\io_scene_obj

  2. Open the __init__.py file in Notepad

  3. Find the following import line:

    from bpy_extras.io_utils import (
        ImportHelper,
        ExportHelper,
        orientation_helper_factory,
        path_reference_mode,
        axis_conversion,
        )
  1. Add a new line right after that as follows: path_reference_mode[1]['default'] = 'COPY'

Another helpful thing to change is having Selection Only on by default

  1. Find the following line :
    use_selection = BoolProperty(
        name="Selection Only",
        description="Export selected objects only",
        default=True,
        )

And make sure default=True

$\endgroup$
0
$\begingroup$

When exporting to obj with mtl there are few things to keep in mind.

Firstly when exporting a blender project to obj with mtl you must use principled BDSF on your surfaces, without this the mtl file will not even contain correct paths to your textures.

Now when we get to the export page for .obj we note the following:

enter image description here

As of Blender 4.0.2 we have the following export options:

  • Auto: Will use relative paths if the textures are located in a subdirectory with respect to the blend file. This means that if your textures are stored in a parent directory, an absolute file path will be used.
  • Absolute: The filepath specified from the root directory of your computer is used, if you share your export (with textures) to someone else it will likely not work because they have a different directory structure
  • Match: When you select a texture in your blender project, if it was selected through an absolute path then that is what gets stored in the .mtl file, if a relative path is used for selection then a relative path is stored in the .mtl file.
  • Strip: Write the filename only ignoring the path that gets it there.
  • Copy: Same as strip, but for every texture used it is copied to the output directory where you are exporting your obj, note that if you have a texture directory it will copy the textures from there to this export directory.

Personally I use the relative setting. When I share my work with others, I send them a directory which contains the textures and also the obj files in the correct relative hierarchy so that they can load in objs with mtl's correctly.

$\endgroup$

You must log in to answer this question.

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