# How does OBJ format determine vertex normals?

I have a very simple obj file:

v -2.22045e-16 -0.291306 -2.22045e-16
v -0.24339 -2.22045e-16 -2.22045e-16
v -2.22045e-16 -2.22045e-16 -0.24339
v -2.22045e-16 -2.22045e-16 -0.24339
v 0.24339 -2.22045e-16 -2.22045e-16
v -2.22045e-16 -0.291306 -2.22045e-16
v -2.22045e-16 -2.22045e-16 -0.24339
v -0.24339 -2.22045e-16 -2.22045e-16
v -2.22045e-16 0.291306 -2.22045e-16
v -2.22045e-16 -2.22045e-16 -0.24339
v -2.22045e-16 0.291306 -2.22045e-16
v 0.24339 -2.22045e-16 -2.22045e-16
v -2.22045e-16 -0.291306 -2.22045e-16
v -2.22045e-16 -2.22045e-16 0.24339
v -0.24339 -2.22045e-16 -2.22045e-16
v 0.24339 -2.22045e-16 -2.22045e-16
v -2.22045e-16 -2.22045e-16 0.24339
v -2.22045e-16 -0.291306 -2.22045e-16
v -0.24339 -2.22045e-16 -2.22045e-16
v -2.22045e-16 -2.22045e-16 0.24339
v -2.22045e-16 0.291306 -2.22045e-16
v 0.24339 -2.22045e-16 -2.22045e-16
v -2.22045e-16 0.291306 -2.22045e-16
v -2.22045e-16 -2.22045e-16 0.24339
f 3 2 1
f 6 5 4
f 9 8 7
f 12 11 10
f 15 14 13
f 18 17 16
f 21 20 19
f 24 23 22


As you can see, there is no vn command. However, if I open it in meshlab and turn on the vertex normal rendering, it shows vertex normals (and some normals not attached to vertices).

Why does this happen?

It is common for modeling software to compute the normals when they aren't included in the loaded file (regardless of the format). This is usually highly dependent on the settings chosen when the file is loaded. Vertex normals can be computed fairly easily. The software can also compute smooth or faceted normals so you can switch between the two.

Your example includes faces...the f 3 2 1 is a face. Each number refers to one of the vertex values which are numbered starting from the top. v -2.22045e-16 -0.291306 -2.22045e-16 is vertex number 1 in this case. The software can easily use that information to compute normals.

A normal is computed from the cross product of the edge vectors. Stictly speaking the obj format doesn't compute the actual normals, it just provides the information that Meshlab needs so that Meshlab can compute the normals. which looks something along the lines of:

facted_normal = normalize( cross( 2-3, 1-3))

Where the numbers for 1, 2 and 3 are replaced with the actual values for those vertices. Other types of normals are usually computed based of that.

I loaded this file into Blender and it is well behaved, so odds are meshlab has some options turned on that are showing split normals or vertex normals or one of the many other possible variants out there.

Why does this happen?

If no normals are supplied, meshlab probably generates them. This is common behaviour of many 3D applications.

There are various techniques for generating normals (per-vertex, per-face, weighted, non-weighted etc) depending on the desired appearance (smooth/flat shading).

(and some normals not attached to vertices).

Sound possibly like a bug on meshlab's part. Can you post a screen-shot?

• oops we got the same basic answer at almost the same moment haha Mar 21, 2021 at 13:35
• @pmw1234 Indeed, I feel you may have ninja'd me slightly by a min ;) Mar 21, 2021 at 13:45