Material Mapping

Contents

mapTo

In TSE it is necessary to "map" a Material to each texture that is used in the art tools. Think of the textures used in the arts tools as "tags" that TSE uses to apply something more complex than just a texture.

The process of mapping a Material to a texture tag is done inside the Material itself by using the "mapTo" parameter. MapTo simply names the texture tag to apply the Material to. Like so:

new Material( Foo )
{
   mapTo = "bar";
   baseTex[0] = "~/data/textures/fubar";
};

In this case, TSE will apply the Material "Foo" to the texture "bar" that was used in a modeling app.

Automatic mapping

Materials do not require a mapTo parameter if the base texture name in the Material is the same as the texture tag.

So this:

new Material( Foo )
{
   mapTo = "bar";
   baseTex[0] = "~/data/textures/bar";
};

could be reduced to:

new Material( Foo )
{
   baseTex[0] = "~/data/textures/bar";
};

This is not true for CustomMaterials, every CustomMaterial needs a "mapTo" parameter. It is also not true for models that have been exported using Maya.

Mapping with Maya

Maya exports texture tags with the full filename including the extension. If a model has been exported using Maya, any Materials mapping to it will need a mapTo parameter that includes the full texture filename. Example:

new Material( MayaMat )
{
   mapTo = "bar.png"
   baseTex[0] = "~/data/textures/bar";
};

Note that it is not necessary to do this if you use Milo Cooper's build of the plug-in, which makes this optional. (See this forum post for more information.)

Mapping a single Material to multiple texture tags

You cannot map multiple materials to the same texture tag. You can, however, map the same Material to multiple texture tags. To do so, use the addMaterialMapping script call as follows:

addMaterialMapping("grate", "material: Grate");
addMaterialMapping("grate2", "material: Grate");

(You only actually need the second statement if the material is already mapped to "grate")

Mapping Materials to .ifl animations

Mapping a Material to an .ifl animation is a fairly simple process; just name the .ifl filename in the mapTo parameter:

new Material(TestIFL)
{
   mapTo = "explosion.ifl";
   baseTex[0] = "~/data/shapes/explosion/glauncher_exp0010";
   translucent = true;
   emissive = true;
};

The baseTex texture is replaced by the animating .ifl texture as it plays through. Even though the baseTex is replaced, the parameter must still point to a valid texture for this to work. In this case, the baseTex just points to the first frame of animation in the .ifl.