0
$\begingroup$

I've exported a model out and trying to import it into Blender. However, the Texture is missing. I manually looked in the obj file to find something regarding mtllib, but a search did not find this phrase at all.

Must all textured obj files contain the keyword "mtllib" at least somewhere?

$\endgroup$

1 Answer 1

0
$\begingroup$

Yes they should, as textures aren't handled/described by the .obj format. The file uses the mtllib to reference the .mtl which in turn should contain at least one material definition. The usemtl in the .obj says which of the materials in the .mtl are used for the 3D object in question. The material definition of the .mtl can have the map_Kd attribute which references a texture file.

Here is an example how the file formats look like when storing the default cube with a texture as .obj and .mtl files.


The .obj file

# Blender v2.80 (sub 74) OBJ File: ''
# www.blender.org
mtllib test_with_texture.mtl
o Cube
v 1.000000 1.000000 -1.000000
v 1.000000 -1.000000 -1.000000
v 1.000000 1.000000 1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 1.000000 -1.000000
v -1.000000 -1.000000 -1.000000
v -1.000000 1.000000 1.000000
v -1.000000 -1.000000 1.000000
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.250000
vt 0.375000 0.250000
vt 0.625000 0.250000
vt 0.625000 0.500000
vt 0.375000 0.500000
vt 0.625000 0.750000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.625000 1.000000
vt 0.375000 1.000000
vt 0.125000 0.500000
vt 0.375000 0.500000
vt 0.375000 0.750000
vt 0.125000 0.750000
vt 0.625000 0.500000
vt 0.875000 0.500000
vt 0.875000 0.750000
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
usemtl Material
s off
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/6/2 7/7/2 8/8/2
f 8/8/3 7/7/3 5/9/3 6/10/3
f 6/10/4 2/11/4 4/12/4 8/13/4
f 2/14/5 1/15/5 3/16/5 4/17/5
f 6/18/6 5/19/6 1/20/6 2/11/6

The .mtl file

# Blender MTL File: 'None'
# Material Count: 1

newmtl Material
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
map_Kd texture.png
$\endgroup$
1
  • $\begingroup$ What is the correct way to relink textures to imported .obj files using that .mtl data? $\endgroup$
    – tomh
    Oct 14, 2022 at 9:20

You must log in to answer this question.

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