When I create 2 materials on an object and assign one material and export it as OBJ file format then only the assigned material export with the file. Besides this, some Image textures get unlinked from the Principled BSDF. But if I export as FBX file format , 2 materials export with the object. Isn’t possible to export OBJ file like FBX file with packing all materials and texture images with properly linked?
Could you share a simplified .blend file ?
I have noticed that when I union three parts (with materials/textures) in Blender, I have to follow manual steps to first copy the materials mapping and textures from the additional parts to the destination part first if I want to preserve all of that, whereas some other tools like NetFabb or Meshmixer (if I recall correctly) will do that automatically; and those other tools will export a single OBJ, MTL, and JPG when complete whereas Blender will export an OBJ, MTL, and multiple JPGs (or maybe it just references the existing multiple JPGs).
Hi! Thanks for giving me a real testing file! It let me fix several issues with the material export/import.
There are three issues with the file you gave.
Material is a per-polygon attribute in OBJ. So if two materials are linked to an object and both of them apply to _all_ of the faces, then only one is referenced by the OBJ file.
# OBJ file usemtl mat 1 f 1 2 3 f 2 3 4
But if one material is assigned to one face, and the other to another, then you can expect
# OBJ file usemtl mat 1 f 1 2 3 usemtl mat 2 f 2 3 4
What happens in the MTL file is different. Python exporter stores only the materials used in the
usemtl lines and writes them to the MTL file. C++ exporter writes all materials linked to an Object to the MTL file even if they’re not referenced by the OBJ file. But in the OBJ file, only one material is referenced since you have not made any per-polygon distinction, so both importers grab only one material.
You use the same name for the materials! How is a parser supposed to disambiguate between two materials ?
# MTL file newmtl mat1 Ni 1 newmtl mat1 Ni 2
The python exporter uses Dictionary for material list and will override the material and keep only the last encountered material. C++ one writes one object’s all materials at once so it doesn’t know if a material with the same name has been written or not.
But any importer that uses a hashing container with material name as key will only import one of the materials. Python used dict for importing, C++ used Map.
map_Ns Main File/Textures/T_Corona_Virus_roughness.png This path doesn’t exist!
Python exporter will write this and expect user to create the folders and unpack images into them.
C++ exporter writes only the filename and expects user to unpack images in the current directory. (Or unpack into default
textures directory and move to the same folder as the MTL file).
We will not modify the blend file and inform user that a packed file is found and that they should do as they please.
When I use this mtl all texture do not import correctly.
Didn’t the importer raise an exception of unsupported type?
map_Ns is not supported.
Also, reflection defaults to base-color.
_generic_tex_set(mat_wrap.base_color_texture, image, 'Reflection', map_offset, map_scale)
Actually , I don’t know python language and even don’t know any program language . So if you give me the specific direction of what I should do to solve this issue so that I can export and import all texture correctly. I would be grateful to you…please.
The code is in the io_scene_obj add-on’s
import_obj.py file. You can try adding two similar lines in 429-472 and 186-224, for
I’ll try and add it to the C++ importer which should be in master soon and you can download it from nightly builds after that.