Details and Options
The MTL format is a human-readable ASCII text file.
ImportMTL uses
Import to first load the data from
source as
"Text", then parses the text for any materials.
The ImportMTL
source supports all of the same first arguments as
Import.
If the source file cannot be located, then ImportMTL parses a string as if it were MTL data.
Elements supported by ImportMTL include:
"Elements" | a list of supported element names |
"Text" | the raw text from the file including any comments |
"Data" | an Association of the data's key-value pairs where key's are all lowercase |
"Dataset" | same as "Data" but viewed as a Dataset |
"Directive" | (default) a set of Graphics3D directives |
The emission color "ke" is not part of the original MTL specification but supported by some 3D software.
A texture map can be specified for the diffuse color and maps to the following
Directive expression:
MTL scalar parameters are a single numerical value and map to the following
Directive expressions:
The transparency "tr" is not part of the original MTL specification but included as a convenience and is opposite in value to the dissolve property "d".
The illumination model "illum" has 10 possible integer values but only the first three are representable in
Graphics3D:
The extended MTL specification provides attributes for physically-based rendering and includes the following additional parameters and colors:
"aniso" | MaterialShading[…,"SpecularAnisotropyCoefficient"→val,…] |
"anisor" | MaterialShading[…,"SpecularAnisotropyCoefficient"→{…,val},…] |
"ke" | MaterialShading[…,"EmissionColor"→color,…] |
"pm" | MaterialShading[…,"MetallicCoefficient"→val,…] |
"pr" | MaterialShading[…,"RoughnessCoefficient"→val,…] |
"ps" | MaterialShading[…,"SheenColor"→color,…] |
The following texture maps are also possible using MaterialShading:
"map_ka" | MaterialShading[…,"AmbientExposureFraction"→Texture[image],…] |
"map_kd" | MaterialShading[…,"BaseColor"→Texture[image],…] |
"map_ke" | MaterialShading[…,"EmissionColor"→Texture[image],…] |
"map_ks" | MaterialShading[…,"SpecularColor"→Texture[image],…] |
"map_pm" | MaterialShading[…,"MetallicCoefficient"→Texture[image],…] |
"map_pr" | MaterialShading[…,"RoughnessCoefficient"→Texture[image],…] |
"norm" | MaterialShading[…,"SurfaceNormals"→Texture[image],…] |
Color maps include "map_kd", "map_ke", and "map_ks".
Parameter maps include "map_ka", "map_pm", and "map_pr".
The color maps are expected to be images in the RGB or XYZ color space.
The parameter maps are expected to be images in the Grayscale color space and act as an intensity map or image mask.
If a texture map in the RGBA or XYZA color space is provided for a parameter texture map then only the
AlphaChannel is used.
The "norm" maps an image but the color channels are interpreted as vector coordinates.
If both a texture map and a corresponding color or parameter are specified, the texture map is multiplied by the corresponding color or parameter.
For example, if "kd" and "map_kd" are provided, the resulting texture is
Texture[ImageMultiply[image,color]].
ImportMTL uses the following option:
"BaseDirectory" | Automatic | the file path used to find texture map files |
Possible settings for "BaseDirectory" are:
Automatic | use the directory where the.mtl file resides |
"path" | use the provided directory path |
If a verbose path is used for "BaseDirectory", then only the filename of a texture map is used to resolve the full path.