Skip to content
We are updating the documentation, some information may be outdated or incomplete

Multi-Textures

Introduction

DynamX allows you to use the same OBJ model (and therefore the same MTL) to have different textures applicable to vehicles, wheels, blocks, props, and armor.

Prerequisites

You must have properly configured the MTL file; otherwise, go back to the model export step of the tutorial you are following. You should also be familiar with the concept of objects and materials on OBJ models.

Danger

This version of the tutorial works only with DynamX versions 4.0.0 and later.

Model Configuration

DynamX allows you to use the same OBJ model (and therefore the same MTL) to have different textures applied to your blocks, props, vehicles, and armor.

You can choose to put multiple textures on the same material (recommended configuration, the simplest one), or put multiple materials on the same object (allowing you to use colors without PNG textures).

Create different textures for your model, and then, in the MTL file, add your textures like this:

newmtl Material
...
map_Kd textures/block_orange.png
map_Kd textures/block_red.png Rouge
map_Kd textures/block_greeen.png Vert
map_Kd textures/block_blue.png Bleu

The first line map_Kd corresponds to the default texture, which is already present in the MTL after exporting.

The second line corresponds to a texture variant, where textures/block_red.png is the path to the texture from the MTL folder, and Red is the name of the texture (visible on the associated in-game item). You can add as many as you want (though too many textures can saturate your computer's memory).

Warning

If you create a vehicle, and if the wheels can have different textures, you must do the same in their MTL.

Using Multiple Materials on the Same Object (Advanced)

This method offers more flexibility than the first and allows, for example, to use different colors on each material.

To use it, you simply need to copy the "base" material and then rename it. For example, with the previous example:

newmtl Orange
...
map_Kd textures/block_orange.png

newmtl Rouge
...
map_Kd textures/block_red.png

newmtl Vert
...
map_Kd textures/block_green.png

newmtl Bleu
...
map_Kd textures/block_blue.png

In the next step, you must add BaseMaterial: Orange to the MaterialVariants block.

The operation is as follows: the default material is the orange material, indicated with the BaseMaterial property, and the other textures will use the corresponding material instead of the Orange material.

Vehicle/Block/Armor Configuration

Now, let's go back to the vehicle/block/armor configuration: add a MaterialVariants block like the following in your configuration file.

MaterialVariants{
    Variants: Red Green Blue
}

Variants is used to list all the texture variants you have used in the mtl file, with each variant separated by a space. If you are using multiple textures on the same material, there is no need to specify the default texture, which is named Default. However, if you want to replace it, you can still add BaseMaterial: Green, for example.

Info

If you are using a 2D item render, these variants will also apply there by creating a json file (pointing to a .png texture) for each variant.

If you are configuring a vehicle, you can add the same lines to the wheel file to apply the variants to the vehicle's wheels as well. The names of the variants must always match the variants of the vehicle, or do not include these lines if you don't have them for the wheel (but only for the chassis).

Conclusion

The multi-texture configuration is now complete, and you can return to your initial tutorial!