MTL Files
Material Definitions for OBJ Files
MTL is a data directory which contains examples of MTL files. An MTL file is an auxilliary file containing definitions of materials that may be accessed by an OBJ file. The OBJ file must specify the name of the MTL file by a command such as
mltlib file_name
It is presumed that the MTL file names and defines various materials, such as, perhaps, "shinyred" or "iron". Then, within the OBJ file, the command
usemtl shinyred
indicates that all subsequence faces should be rendered with this material, until a new material is invoked.
An MTL file contains a sequence of definitions of materials. Each definition begins with a newmtl statement that defines the name of the material, followed by lines specifying particular properties.
Example MTL File:
newmtl shinyred
Ka 0.1986 0.0000 0.0000
Kd 0.5922 0.0166 0.0000
Ks 0.5974 0.2084 0.2084
illum 2
Ns 100.2237
MTL File Characteristics:
ASCII;
Comments begin with a '#' character in column 1. Blank lines may be inserted for clarity. Otherwise, the file consists of a sequence of newmtl statements, followed by a definition of various properties for that material.
The quantities that may be defined for a material include:
Ka r g b
defines the ambient color of the material to be (r,g,b). The default is (0.2,0.2,0.2);
Kd r g b
defines the diffuse color of the material to be (r,g,b). The default is (0.8,0.8,0.
;
Ks r g b
defines the specular color of the material to be (r,g,b). This color shows up in highlights. The default is (1.0,1.0,1.0);
d alpha
defines the transparency of the material to be alpha. The default is 1.0 (not transparent at all) Some formats use Tr instead of d;
Tr alpha
defines the transparency of the material to be alpha. The default is 1.0 (not transparent at all). Some formats use d instead of Tr;
Ns s
defines the shininess of the material to be s. The default is 0.0;
illum n
denotes the illumination model used by the material. illum = 1 indicates a flat material with no specular highlights, so the value of Ks is not used. illum = 2 denotes the presence of specular highlights, and so a specification for Ks is required.
map_Ka filename
names a file containing a texture map, which should just be an ASCII dump of RGB values;
Examples
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.
newmtl flat_green
Ka 0.0000 1.0000 0.0000
Kd 0.0000 1.0000 0.0000
illum 1
3 Dissolved green
This is a flat green, partially dissolved material.
newmtl diss_green
Ka 0.0000 1.0000 0.0000
Kd 0.0000 1.0000 0.0000
d 0.8000
illum 1
4 Shiny green
This is a shiny green material. When applied to an object, it shows a white specular highlight.
newmtl shiny_green
Ka 0.0000 1.0000 0.0000
Kd 0.0000 1.0000 0.0000
Ks 1.0000 1.0000 1.0000
Ns 200.0000
illum 1
5 Green mirror
This is a reflective green material. When applied to an object, it reflects other objects in the same scene.
newmtl green_mirror
Ka 0.0000 1.0000 0.0000
Kd 0.0000 1.0000 0.0000
Ks 0.0000 1.0000 0.0000
Ns 200.0000
illum 3
6 Fake windshield
This material approximates a glass surface. Is it almost completely transparent, but it shows reflections of other objects in the scene. It will not distort the image of objects seen through the material.
newmtl fake_windsh
Ka 0.0000 0.0000 0.0000
Kd 0.0000 0.0000 0.0000
Ks 0.9000 0.9000 0.9000
d 0.1000
Ns 200
illum 4
7 Fresnel blue
This material exhibits an effect known as Fresnel reflection. When applied to an object, white fringes may appear where the object's surface is viewed at a glancing angle.
newmtl fresnel_blu
Ka 0.0000 0.0000 0.0000
Kd 0.0000 0.0000 0.0000
Ks 0.6180 0.8760 0.1430
Ns 200
illum 5
8 Real windshield
This material accurately represents a glass surface. It filters of colorizes objects that are seen through it. Filtering is done according to the transmission color of the material. The material also distorts the image of objects according to its optical density. Note that the material is not dissolved and that its ambient, diffuse, and specular reflective colors have been set to black. Only the transmission color is non-black.
newmtl real_windsh
Ka 0.0000 0.0000 0.0000
Kd 0.0000 0.0000 0.0000
Ks 0.0000 0.0000 0.0000
Tf 1.0000 1.0000 1.0000
Ns 200
Ni 1.2000
illum 6
9 Fresnel windshield
This material combines the effects in examples 7 and 8.
newmtl fresnel_win
Ka 0.0000 0.0000 1.0000
Kd 0.0000 0.0000 1.0000
Ks 0.6180 0.8760 0.1430
Tf 1.0000 1.0000 1.0000
Ns 200
Ni 1.2000
illum 7
10 Tin
This material is based on spectral reflectance samples taken from an actual piece of tin. These samples are stored in a separate .rfl file that is referred to by name in the material. Spectral sample files (.rfl) can be used in any type of material as an alternative to RGB values.
newmtl tin
Ka spectral tin.rfl
Kd spectral tin.rfl
Ks spectral tin.rfl
Ns 200
illum 3
11 Pine Wood
This material includes a texture map of a pine pattern. The material color is set to "ident" to preserve the texture's true color. When applied to an object, this texture map will affect only the ambient and diffuse regions of that object's surface.
The color information for the texture is stored in a separate .mpc file that is referred to in the material by its name, "pine.mpc". If you use different .mpc files for ambient and diffuse, you will get unrealistic results.
newmtl pine_wood
Ka spectral ident.rfl 1
Kd spectral ident.rfl 1
illum 1
map_Ka pine.mpc
map_Kd pine.mpc
12 Bumpy leather
This material includes a texture map of a leather pattern. The material color is set to "ident" to preserve the texture's true color. When applied to an object, it affects both the color of the object's surface and its apparent bumpiness.
The color information for the texture is stored in a separate .mpc file that is referred to in the material by its name, "brown.mpc". The bump information is stored in a separate .mpb file that is referred to in the material by its name, "leath.mpb". The -bm option is used to raise the apparent height of the leather bumps.
newmtl bumpy_leath
Ka spectral ident.rfl 1
Kd spectral ident.rfl 1
Ks spectral ident.rfl 1
illum 2
map_Ka brown.mpc
map_Kd brown.mpc
map_Ks brown.mpc
bump -bm 2.000 leath.mpb
13 Frosted window
This material includes a texture map used to alter the opacity of an object's surface. The material color is set to "ident" to preserve the texture's true color. When applied to an object, the object becomes transparent in certain areas and opaque in others.
The variation between opaque and transparent regions is controlled by scalar information stored in a separate .mps file that is referred to in the material by its name, "window.mps". The "-mm" option is used to shift and compress the range of opacity.
newmtl frost_wind
Ka 0.2 0.2 0.2
Kd 0.6 0.6 0.6
Ks 0.1 0.1 0.1
d 1
Ns 200
illum 2
map_d -mm 0.200 0.800 window.mps
14 Shifted logo
This material includes a texture map which illustrates how a texture's origin may be shifted left/right (the "u" direction) or up/down (the "v" direction). The material color is set to "ident" to preserve the texture's true color.
In this example, the original image of the logo is off-center to the left. To compensate, the texture's origin is shifted back to the right (the positive "u" direction) using the "-o" option to modify the origin.
Ka spectral ident.rfl 1
Kd spectral ident.rfl 1
Ks spectral ident.rfl 1
illum 2
map_Ka -o 0.200 0.000 0.000 logo.mpc
map_Kd -o 0.200 0.000 0.000 logo.mpc
map_Ks -o 0.200 0.000 0.000 logo.mpc
15 Scaled logo
This material includes a texture map showing how a texture may be scaled left or right (in the "u" direction) or up and down (in the "v" direction). The material color is set to "ident" to preserve the texture's true color.
In this example, the original image of the logo is too small. To compensate, the texture is scaled slightly to the right (in the positive "u" direction) and up (in the positive "v" direction) using the "-s" option to modify the scale.
Ka spectral ident.rfl 1
Kd spectral ident.rfl 1
Ks spectral ident.rfl 1
illum 2
map_Ka -s 1.200 1.200 0.000 logo.mpc
map_Kd -s 1.200 1.200 0.000 logo.mpc
map_Ks -s 1.200 1.200 0.000 logo.mpc
16 Chrome with spherical reflection map
This illustrates a common use for local reflection maps (defined in a material).
this material is highly reflective with no diffuse or ambient contribution. Its reflection map is an image with silver streaks that yields a chrome appearance when viewed as a reflection.
ka 0 0 0
kd 0 0 0
ks .7 .7 .7
illum 1
refl -type sphere chrome.rla
Full details can be found at..
http://www.fileformat.info/format/material/