An .mtl file is a material library: plain text in the same style as OBJ,
with one statement to a line and # for comments. A model names its
libraries with mtllib and picks a material with usemtl.
Texture maps are on the MTL texture maps page.
newmtl Painted_Steel
Ka 0.1 0.1 0.1
Kd 0.8 0.1 0.1
Ks 0.5 0.5 0.5
Ns 96
Ni 1.45
d 1
illum 2
map_Kd steel_diffuse.png
newmtl – A material
newmtl name starts a material. Every statement until the next
newmtl describes it. A name cannot contain spaces, though underscores are
fine.
Colours
| Statement | Meaning |
|---|---|
Ka | The ambient colour. |
Kd | The diffuse colour. |
Ks | The specular colour. |
Tf | The transmission filter: which colours pass through a transparent surface. |
Ke | The emissive colour. It is not in the original specification; the physically based extension, which many programs use, adds it. |
Each takes one of three forms. Do not mix them in one statement.
| Form | Meaning |
|---|---|
Kd r [g b] | RGB, usually from 0 to 1. If only r is given, g and b equal it. |
Kd spectral file.rfl [factor] | A spectral curve in an .rfl file, multiplied by factor, 1.0 by default. |
Kd xyz x [y z] | CIEXYZ values, usually from 0 to 1. If only x is given, y and z equal it. |
illum – Illumination model
illum number picks one of eleven models.
| Model | Meaning |
|---|---|
| 0 | Colour on, ambient off |
| 1 | Colour on, ambient on |
| 2 | Highlight on |
| 3 | Reflection on, ray trace on |
| 4 | Transparency: glass on; reflection: ray trace on |
| 5 | Reflection: Fresnel on, ray trace on |
| 6 | Transparency: refraction on; reflection: Fresnel off, ray trace on |
| 7 | Transparency: refraction on; reflection: Fresnel on, ray trace on |
| 8 | Reflection on, ray trace off |
| 9 | Transparency: glass on; reflection: ray trace off |
| 10 | Casts shadows onto invisible surfaces |
A material needs model 3 or above for reflection maps to appear.
d and Tr – Transparency
d factor is the dissolve. 1.0, the default, is fully opaque; 0.0 is fully
clear. It applies to every illumination model.
d -halo factor makes the dissolve depend on the angle between the
surface and the viewer: it runs from 1.0 where the surface faces the viewer down to
the given minimum.
Tr is written by some programs instead of d, with the
meaning inverted: 0 is opaque and 1 is clear, so Tr = 1 − d.
It is not in the original specification.
Ns, Ni and sharpness
| Statement | Meaning |
|---|---|
Ns exponent | The specular exponent, usually from 0 to 1000. Higher values give a tighter highlight. |
Ni density | The optical density, or index of refraction, from 0.001 to 10. 1.0 means light does not bend. Glass is about 1.5. Values below 1.0 are not recommended. |
sharpness value | How sharp reflections are, 0 to 1000, 60 by default. Values above 100 can cause aliasing on flat surfaces seen at sharp angles. |
Physically based extension
These statements are not part of the original format. They were proposed by the creators of Clara.io to add physically based rendering, and have been adopted by Blender and tinyobjloader, among others. They take one number.
| Statement | Meaning |
|---|---|
Pr | Roughness |
Pm | Metallic |
Ps | Sheen |
Pc | Clearcoat thickness |
Pcr | Clearcoat roughness |
aniso | Anisotropy |
anisor | Anisotropy rotation |
The extension’s texture maps, and the normal map norm, are on the
MTL texture maps page.