6
$\begingroup$

I am confused by the content of OBJ Blender exports. When I export a (default) cube object (8 vertices, 6 faces) to OBJ and then inspect the OBJ file, the "vn" entries obviously correspond to face normals and not to vertex normals. That is clear from the values and the fact that there are only 6 "vn" entries. Every "f" entry then points to the very same normal for each vertex in that line. Should not there be exactly 8 "vn" entries (since for the cube model there will be exactly 8 distinct vertex normals) which represent vertex (not face) normals as specified by Wavefront OBJ format? Furthermore, should not each "f" entry point to a different normal for each vertex?

I used Blender versions 2.79 and 2.80, both act the same. While exporting the OBJ file, only "Write Normals" option is checked. Here is the content of the generated OBJ:

# Blender v2.80 (sub 37) OBJ File: ''
# www.blender.org
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
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
f 1//1 5//1 7//1 3//1
f 4//2 3//2 7//2 8//2
f 8//3 7//3 5//3 6//3
f 6//4 2//4 4//4 8//4
f 2//5 1//5 3//5 4//5
f 6//6 5//6 1//6 2//6
$\endgroup$

2 Answers 2

7
$\begingroup$

They are vertex normals. But because your cube is flat shaded, there are only 6 unique vector directions. In the obj file there are no duplicates. If you smooth shade your cube, you'll get 8 vn entries.

You can see that first face is made from vertices 1,5,7,3 and that they have normal vectors 1,1,1,1 (in same order)

$\endgroup$
2
  • $\begingroup$ Image for reference $\endgroup$
    – Robert Gützkow
    Aug 11, 2019 at 17:58
  • 2
    $\begingroup$ It never occurred to me that the choice of "Flat"/"Smooth" Shading would affect the export. Thank you! $\endgroup$
    – JanBed
    Aug 12, 2019 at 11:37
1
$\begingroup$

In addition to the great answer Jaroslav Jerryno Novotny, which helped a lot.

In edit mode select smooth like:

Blender 2.79:

enter image description here

Blender 2.8:

enter image description here

After that, the number of normals will increase during export *.obj file. This will improve lighting, refraction, reflection and other effects when using shaders.

$\endgroup$

You must log in to answer this question.

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