Page tree
Skip to end of metadata
Go to start of metadata

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


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.


Defining shaders is optional. If omitted, a default shader will be picked depending on content type.

Defining Custom Shaders
// Specifies a custom vertex shader: vsMyVertexShader.shd
customshaderVS vsMyVertexShader   

// Specifies a custom fragment shader: fsMyFragmentShader.shd
customshaderFS fsMyFragmentShader  


Defining Renderhint
renderhint NormalAndSpecMapped

The renderhint can also be added directly to a MDL file.


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*).

Defining Textures
// Binds a texture to texUnit0 in the fragment shader. Overrides bitmap/texture0 in the model.
texture0 myFirstTexture

// Binds a texture to texUnit1 in the fragment shader. Overrides texture1 in the model.
texture1 mySecondTexture


Optional definitions of parameters, which will be passed to the shader.

Defining Parameters
// Creates a float parameter that will be bound to a shader uniform of the same name (if it exists).
parameter float fModulator 0.5

// Creates an integer parameter that will be bound to a shader uniform of the same name.
parameter int iCount 2

// Creates a 4-float parameter that will be bound to a shader uniform of the same name. 
// Float parameters may have up to 4 dimensions (not supported for int)
parameter float vDiffuse 0.8 1.0 0.65 1.0  


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
// textures0 overwrites bitmap or texture0 parameter in mdl
texture0 testtx
// Used by normal and spec mapping shaders
texture1 testtx_n
texture2 testtx_s

Roughness, Heightmaps and Illumination are supported as well.  An mtr file can be defined in the mtr as such

renderhint NormalAndSpecMapped
texture0 * (Diffuse)
texture1 *_n (Normal)
texture2 *_s (Specular)
texture3 *_r (Roughness)
texture4 *_h (Height)
texture5 *_i (Illumination)

  • No labels