mtr files define a material which can be referenced from within models/ mdl files. There are two ways to reference an mtr file:
materialname myMaterialFile
or
bitmap myMaterialFile
The latter enables using materials with existing textures and models. If an mtr file is present it takes precedence over image textures - be it dds, plt or dds.
Shaders
Defining shaders is optional. If omitted, a default shader will be picked depending on content type.
Renderhint
Specifying a renderhint in the material file will instruct the game to handle the associated content in a certain way. Currently, only two renderhint tokens are supported, which have identical function and can be used interchangeably : "NormalAndSpecMapped" and "NormalTangents". Specifying either of these will make the game generate vertex tangent and handedness information (provided that the associated model is not already compiled), as well as picking a shader variant with normal mapping if no custom shader is specified.
The renderhint can also be added directly to a MDL file.
Textures
Texture definitions are optional. Any texture defined in the mtr file takes precedence over the one in the model/ mdl file. Up to 11 textures are supported: texture0 - texture10 (numbering doesn't need to be continuous). Specifying a texture makes it available in the shaders in the corresponding uniform sampler (texUnit*).
Parameters
Optional definitions of parameters, which will be passed to the shader.
Examples
Overwriting Textures
The following example overrides the standard armoire placeable (plc_a01.mdl). The new placeable is a simple square and references a mtr file with three textures. The files have to be placed into the override folder.
node trimesh a01_planeA parent plc_a01 ... bitmap ttr01_grass02 # Old style texture reference, overwritten in mtr texture1 null # texture will be overwritten in mtr texture2 null # texture will be overwritten in mtr renderhint NormalAndSpecMapped # Enables normal and specular mapping materialname testmat # Reference to mtr file ... endnode
// textures0 overwrites bitmap or texture0 parameter in mdl texture0 testtx // Used by normal and spec mapping shaders texture1 testtx_n texture2 testtx_s