Material System/Materials
A material is a .mat
key-values text file that defines a two-dimensional surface. It contains all of the information needed for engine to simulate the surface visually, aurally, and physically.
The contents of a material will fall into some or all of these categories:
- Texture names
- Physical surface types
- Shader parameters
- Special compile properties
- Fallbacks
- Proxies
Simple Example
"Base"
{
BaseTexture "grass/grass_lawn" usage:diffuse;
surfaceprops "grass";
};
This is a very basic grass ground material.
- The
Base
shader is used, which means that the material is for use on surfaces of static models. - The { character opens a set of parameters
- The
BaseTexture
parameter is given withgrass/grass_lawn
, which is the location of a texture. This is what will be drawn on the screen. surfaceprops
gives the material the physical properties of grass.- The } character closes a set of parameters
It's important to remember that this material can only be used on static world models. If it needed to be used on models, for instance, another version would need to be created using the BaseSkinned
shader.
Most of the time switching materials from one shader to another is as simple as changing their first line, since a great number of parameters are shared between them. Some params only work with certain shaders, like Variation effects, which are only available with Base
, but unfortunately you won't encounter any critical errors if a param isn't understood by the shader. It just won't have any effect.