Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reverted from v. 23


Table of Contents
maxLevel1
outlinetrue
indent2em
stylenone


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.

Code Block
languagecpp
titleDefining Custom Shaders
linenumberstrue
collapsetrue
// Specifies a custom vertex shader: vsMyVertexShader.shd
customshaderVS vsMyVertexShader   

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

Anchor
material-renderhint
material-renderhint
Renderhint

Code Block
languagecpp
titleDefining Renderhint
collapsetrue
renderhint NormalAndSpecMapped

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

Code Block
languagecpp
titleDefining Textures
linenumberstrue
collapsetrue
// 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



Parameters


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

Code Block
languagecpp
titleDefining Parameters
linenumberstrue
collapsetrue
// 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  



Examples


Section


Column

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.


Column

View file
nameexample-plc_a01.zip
height150



Code Block
languagepy
titleplc_a01.mdl
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

Code Block
languagecpp
titletestmat.mtr
// textures0 overwrites bitmap or texture0 parameter in mdl
texture0 testtx
// Used by normal and spec mapping shaders
texture1 testtx_n
texture2 testtx_s