Material Mapping

In Torque, Materials (note capital M) are TorqueScript objects that define properties used when rendering a surface. Each Material object is mapped to a single material (note lowercase m) target. These targets are the names of the materials defined in the model itself (DTS, DAE etc), and are usually the same as the material names in the application that exported the model.

For example, a model containing a single material target soldier might have a Material defined as follows:

singleton Material( Mat_Soldier )          // Object name is arbitrary (though must be unique)
   mapTo = "soldier";                      // This is the material target name
   diffuseMap[0] = "soldier_armor.jpg";    // Texture name is arbitrary

For Materials that consist of only a diffuse texture, the Material object definition can be omitted entirely and Torque will automatically create and map a simple Material. For this to work, the diffuse texture must be in the same folder as the model, and must have the same name as the material target. In this case, the diffuse texture would have to be named soldier.png (extension is not important, only the base filename).

Torque's Material system requires artists to be careful when naming materials in their modeling application prior to export; any models that share the same material target names will also share the same script Materials.

Target names are also important if the model is to support skin swapping.

Material and Skin Swapping

Generally this is only done during level editing and is not the recommended way to dynamically change Materials on an object at runtime.


Last updated