Alias/WaveFront Material (.mtl) File Format


The following documentation of the .mtl file format is from: http://www.fileformat.info/format/material/

Summary

Original documentation created by:
Diane Ramey, Linda Rose, and Lisa Tyerman
Copyright 1995 Alias|Wavefront, Inc.
All rights reserved

Modified and simplified by Donald House, 1/12/2011

Material Library File (.mtl)

Material library files contain one or more material definitions, each of which includes the color, texture, and reflection map of individual materials. These are applied to the surfaces and vertices of objects. Material files are stored in ASCII format and have the .mtl extension.

Each material description in an .mtl file consists of the newmtl statement, which assigns a name to the material and designates the start of a material description. This statement is followed by the material color, and texture map statements that describe the material. An .mtl file map contain many different material descriptions.

After you specify a new material with the "newmtl" statement, you can enter the statements that describe the materials in any order.

Format

The following is a sample format for a material definition in an .mtl file:

Material name statement:

newmtl my_mtl

Material color and illumination statements:

Ka 0.0435 0.0435 0.0435
Kd 0.1086 0.1086 0.1086
Ks 0.0000 0.0000 0.0000
Ns 10.0000
illum 2

Texture map statements:

map_Ka mapfile.png
map_Kd
mapfile.png

Material Name

An .mtl file must have one newmtl statement at the start of each material description. The material name statement assigns a name to the material description.

newmtl name

Names may be any length but cannot include blanks. Underscores may be used in material names.


Material color and illumination

To specify the ambient, diffuse and specular reflectivity of the current material using RGB values in the range 0.0 to 1.0:

Ka r g b
Kd r g b
Ks r g b


To specify the specular exponent for the current material. A high exponent results in a tight, concentrated highlight. Ns values normally range from 0 to 1000.

Ns exponent

To specify the illumination model to be used in shading calculations, the "illum" statement is used. The illumination model number can be a number from 0 to 2, described below

illum illumno 

0 This is a constant color illumination model. The color is the specified Kd for the material. The formula is:
      color = Kd
1 This is a diffuse illumination model using Lambertian shading. The color includes an ambient and diffuse shading terms for each light source. The formula is
      color = KaIa + Kd { SUM j=1..ls, (N * Lj)Ij }
2 This is a diffuse and specular illumination model using Lambertian shading and Blinn's interpretation of Phong's specular illumination model (BLIN77).
   The color includes an ambient constant term, and a diffuse and specular shading term for each light source. The formula is:
      color = KaIa + Kd { SUM j=1..ls, (N*Lj)Ij } + Ks { SUM j=1..ls, ((H*Hj)^Ns)Ij }

Term definitions are: Ia ambient light, Ij light j's intensity, Ka ambient reflectance, Kd diffuse reflectance, Ks specular reflectance, H unit vector bisector between L and V, L unit light vector, N unit surface normal, V unit view vector

Material texture map

Texture map statements modify the material parameters of a surface by associating an image or texture file with material parameters that can be mapped. By modifying existing parameters instead of replacing them, texture maps provide great flexibility in changing the appearance of an object's surface.

map_Ka mapfile.png
map_Kd
mapfile.png

The texture image should be square, with size a power of 2. For example 256x256, 512x512, 1024x1024. The material parameters are modified by a texture map by:

- Ka - (1-texture alpha) * material ambient + texture alpha * texture value
- Kd - (1-texture alpha) * material diffuse + texture alpha * texture value

Examples of Materials

1 Neon green

This is a bright green material. When applied to an object, it will remain bright green regardless of any lighting in the scene.

newmtl neon_green
Kd 0.0000 1.0000 0.0000
illum 0


2 Flat green

This is a flat green material that reflects lights in the scene diffusely.

newmtl flat_green
Ka 0.0000 0.2000 0.0000
Kd 0.0000 0.8000 0.0000
illum 1


3 Shiny green

This is a shiny green material that shows the green material with a white specular highlight for each light.

newmtl shiny_green
Ka 0.0000 0.1000 0.0000
Kd 0.0000 0.4000 0.0000
Ks 0.5000 0.5000 0.5000
Ns 200.0000
illum 2


3 Brazil flag

This is a green material with the Brazillian flag design texure mapped onto the surface.

newmtl green_flag
Ka 0.0000 0.2000 0.0000
Kd 0.0000 0.8000 0.0000
illum 1
map_Ka brazil_logo.gif
map_Kd
brazil_logo.gif