Canada
Joined: Jun 15, 2023
Post Count: 8
Status:
Offline
Textures not importing
Hey all,
I'm attempting to import a piece of furniture as an .obj file that has its texture image files separate, but within the same folder. When I import the .obj file it doesn't bring in the textures, its only the model itself.
Am I missing something that will import the textures as well?
Netherlands
Joined: Sep 26, 2009
Post Count: 3972
Status:
Offline
Re: Textures not importing
An SH3D model with textures comes as several files: - the model in an OBJ file - the description of materials in an MTL file - the textures in separtate JPG or PNG files.
These files can come separate or zipped into one single file.
If the files are not zipped, you must make sure that the files stay together and that their relative addresses do not change.
Example: If you download the files in the folder Downloads, and move the OBJ file to the House folder, the relative addresses will change. If you copy all files in one go from Downloads to House, the relative addresses will stay the same.
Other possibilities may include missing fioles, or files with incorrect description.
Netherlands
Joined: Apr 8, 2022
Post Count: 1065
Status:
Offline
Re: Textures not importing
To understand the relation between obj, mtl, and texture images:
Usually the obj and mtl file have the same filename with the extensions .obj and .mtl. Possible cause for not seeing material: the mtl file is missing.
The obj file has a line close to the top "mtllib filename.mtl". This means that it has to use the file "filename.mtl" for material references. Possible cause for not seeing material: the reference to the mtl file is wrong.
The mtl file has one or more sections "newmtl materialname" where each section has a unique material name. After the line "newmtl" the material and it's properties are described. Sections are separated by a empty line so it's easy to see the sections. Possible cause for not seeing material: the mtl file formatting is wrong. Very unlikely but still a possibility.
In the obj file you will see lines "usemtl materialname". That means that from that point on the described surfaces (faces) will use that referenced material name. Possible cause for not seeing material: the material named in the obj file doesn't exist in the mtl file. Note that the material names between the obj and mtl file are case-sensitive which means that "MaterialName" and "materialname" are references to different materials.
The section newmtl in the mtl file can contain a line starting with "map_Kd " followed by a path and file name to a texture image file. Usually there is no path and just a filename which indicate the texture images should be in the same folder as the obj and mtl file. Possible cause for not seeing a texture: the referenced texture image doesn't exist, is named differently, has an invalid image format, or has a wrong path.
If Sweethome3D shows a single material "default" after import this means that it couldn't find the references to the material for one of the above mentioned reasons.
If you imported an obj file not generated by Sweethome3D you can export it from Sweethome3D and then look at the obj and mtl files. Sweethome3D creates a very clean format where each group ("g ..." line in the obj file) is followed by the "usemtl ..." line. That way you can easily see which group uses what material. This doesn't always work because not every third party software creates clean obj files. Since both obj and mtl files are plain text files you can correct errors you find with a simple text editor. Don't use MSWord or LibreOffice Writer, just a simple text editor.
---------------------------------------- Dodecagon.nl 750+ 3D models, manuals, and projects
Canada
Joined: Jun 15, 2023
Post Count: 8
Status:
Offline
Re: Textures not importing
The section newmtl in the mtl file can contain a line starting with "map_Kd " followed by a path and file name to a texture image file. Usually there is no path and just a filename which indicate the texture images should be in the same folder as the obj and mtl file. Possible cause for not seeing a texture: the referenced texture image doesn't exist, is named differently, has an invalid image format, or has a wrong path.
This was the solution! I managed to get the basic texture now loaded onto the model I was trying to import, thank you!
Now just out of curiosity, the model I downloaded included 4 different texture files: a basic one (which is what I used), but also included a "cavity", "normals", and "occlusion" version. I assume these remaining 3 files are for other purposes and not for use here?
Netherlands
Joined: Apr 8, 2022
Post Count: 1065
Status:
Offline
Re: Textures not importing
The other three files are not used by Sweethome3D. They are special overlay images used by programs like Blender and other 3D software to add specific characteristics to a model like shading and reflection. Sweethome3D only uses the base image for a texture.
---------------------------------------- Dodecagon.nl 750+ 3D models, manuals, and projects
Canada
Joined: Jun 15, 2023
Post Count: 8
Status:
Offline
Re: Textures not importing
No, it's one I downloaded from CGTrader.
On a hunch I tried loading it into Blender and adding a decimate modifier in the thought that maybe there were too many faces or it was too high quality, but this didn't change anything sadly.
Netherlands
Joined: Apr 8, 2022
Post Count: 1065
Status:
Offline
Re: Textures not importing
Some advise when you download from CGTrader: always download all formats available (obj, mtl, 3ds, dae, fbx, blend). In many cases importing a 3ds or dae model in Sweethome3D works better than importing the obj file. Also be aware that some models require downloading the textures in a separate file. You can see that in the list of available downloads.
You use the fbx file when all else fails: import it in Blender en export it as obj or 3ds. Then you can import the model in Sweethome3D. Sometimes it even works better to import first in Blender and export it to obj or 3ds. (Often the export to 3ds is more accurate then the obj export.)
You will probably have to learn some Blender anyway if you download more from 3D model sites: sometimes parts are shifted and you need Blender to fix those mistakes.
---------------------------------------- Dodecagon.nl 750+ 3D models, manuals, and projects