# OBJ file has more vertices than normals

Here is a Pastebin of my OBJ file created using Solidworks 3D https://pastebin.com/6MgQBF8J

I don't understand how the number of vertices (645) can be larger than the number of normals (306)

I understand that some vertices have the same exact coordinates, but how is a programmer supposed to know which normals correspond to which vertices?

Since there are no indexes to map normals to vertices, do I need to get rid of the duplicates first until the number of normals and vertices is equal? But then why are the duplicates there in the first place?

Or do I need to create normals equal to zero for the remaining vertices?

Thanks,

A .obj file has lists of vertices and normal that have an implicit 1 based index. The first item you read in is 1, the second is 2, etc.

Further down in the file, you will see a list of faces that look like F 1/1/1 2/2/2 3/3/3

Each tuple of numbers represents the index of the position/uv tex coords/normal that forms the information for that vertex. When you take all three tuples together, you get a single triangle. You will usually end up with far more information than is stored in the file because obj compresses duplicates.

See this page for a great analysis of the OBJ format. In an OBJ file, vertex normals are associated with vertices where the faces are defined. Faces are defined along the bottom of the file, on lines starting with f, e.g.

f 632/996/280 638/997/280 637/971/280


Each triplet consists of a vertex index, texture vertex index, and vertex normal index. So that answers how normals are mapped to vertices. So this example face has three vertices (a triangle).

The first part of your question I'm not 100% certain about. Since the vertex normals and vertices are referenced by index, we could reduce the file size by merging any duplicates into a single index. So for example, if this vertex normal appeared in the file 5 times

vn -0.66051400 -0.44590101 -0.60406399


we could prune the 4 duplicates and remap their indices to the first index. However, your OBJ file does still contain some duplicate vertex normals, so either duplicates are not pruned at all, or SolidWorks just doesn't do it thoroughly.