OBJ and MTL files



.OBJ files contain structural information for a 3D Model, i.e., the object mesh.

vGeometric vertices with (x, y, z [, w = 1.0]) coordinates.
vtTexture coordinates with (u [, v = 0, w =0]) where all values are in the inclusive range [0, 1]
vnVertex normals in (x, y, z) form. They may not be unit vectors
fFaces defined using lists of vertices identified by the index of how they were defined in the file. Indices start at 1 inside of OBJ files.


.MTL files contain the graphical information to color in a 3D Model, i.e., colors, texture maps, bump maps, etc.

KaThe ambient color of the material. RGB format.
KdThe diffuse color of the material. RGB format.
KsThe specular color of the material. RGB format.
NsThe specular exponent of the material. f32 format in range [0, 1000].
dDissolved (transparency). f32 in the inclusive range [0, 1]. 1 means fully opaque.
TrThe inverse of d: 1.0 - d. Transparency.
map_KaThe ambient texture map.
map_KdThe diffuse texture map (usually the same as ambient texture map).
map_KsThe specular texture map.
map_BumpThe normal texture map.

When the map_Ka, map_Kd, and map_Ks texture maps are used, after getting the RGB color using a 2D sampler, the RGB values should be component-wise multiplied against the material RGB colors for Ka, Kd, and Ks respectively.

Vertex Normals vs. Normal Maps

When the map_Bump exists and is used to calculate normal vectors, their values replace the vertex normals (and the interpolated vertex normal values per fragment).

The vertex normals are still useful for calculating the tangent space to world space transformation matrix.

See page in the Kb on normal maps for more information on this transformation matrix.