Material (decl)

What’s this?

Material shaders quick reference


Doom 3

Quake 4

Prey

Materials are a list of structured commands and parameters which define the appearance and physical properties of the surfaces to which a specific material is applied. They tell the id tech 4 engine how to combine a set of images to create a visible texture and how the player and other objects should interact with it. The textures you see on the different surfaces in the game are created using these materials.

Material shaders are similar to Quake 3’s shaders, but with much more power and flexibility. Almost all aspects of a material shader from stages down to individual keywords can be dynamically influenced through the use of simple conditional branching, expressions, and shaderparms . On hardware that supports them, materials can even have vertex and fragment programs applied to any number of their stages.

Syntax

[name] {
  [global]
  {
    [stage]
  }
}

Material shader declarations begin with a header which consists only of the name of the material.

The header is followed by the body of the declaration which is enclosed in curly brackets.

The body is composed of a global section and one or more stages .

The global section contains one or more global keywords . Global keywords affect a material as a whole.

Each stage is contained within its own set of curly brackets and contains one or more stage specific keywords and/or vertex and fragment programs. Stage keywords affect only the stage they are contained within.

You can use two forward slashes to insert comments anywhere in the material. Anything after these in the same line will be ignored by the engine:

// This is a comment

For more information on materials, refer to the Quick and Dirty Material Shader Primer at http://www.doom3world.org/phpbb2/viewtopic.php?t=6617 .