This guide will teach you how you can use .mi files to re-use materials across multiple meshes. By combining this with ArchiveXL: dynamic materials, this mechanic allows maximum flexibility.
Instead of copy-pasting six properties, you now copy-paste only two.
Only add the properties that you want to change in relation to the .mi file
The Daisy Chain illustrated
Look at this example of two chained .mi files:
Step 1: _emissive_base.mi
This file is an external material instance of metal_base.remt. Any Material properties that are not defined will take the default values from the shader template.
No BaseColor attribute is defined - the default value is engine\textures\editor\grey.xbm
EmissiveEV > 0 makes the material glow
A white texture as the Emissive mask means that all of the material glows
TL;DR: Anything using this material will look like a white neon tube.
Step 2: emissive_blue.mi
This file is an external material instance of _emissive_base.mi. Any properties that are not defined will use the defautl values from the .mi file.
No EmissiveEV is defined, so it will use the baseMaterial's value of 4.31680632
No Emissive mask is defined, so it will take engine\textures\editor\white.xbm from the .mi
A blue BaseColorScale overwrites the white glow from the .mi file, changing the glow colour
TL;DR: Anything using this material will look like a blue neon tube.
In other words, this is how emissive_blue.mi actually looks:
... and everything else that's defined inside metal_base.remt
Making material templates
Let's take it another step further – we can make a bunch of different colours to re-use across your files. An example for this are hair files, or the plastic materials I've used in my toy prop pack.
For this, I first created a plastic_base.mi with all the common properties, and then created one additional .mi file for each shade of plastic, setting plastic_base.mi as baseMaterial, leaving me with the following folder structure:
If I decide that my plastic is too shiny, I can edit _plastic_base.mi instead of touching every template individually. Pretty neat, isn't it?
And if one of my items happens to have a custom normal map and/or texture, then I just add them in the values array of my material and call it a day.
Maximally lazy: external materials
But we can take this approach even further! If you don't have any properties, your mesh doesn't even need materials! You can simply use the externalMaterials list instead. You do this by unticking the isLocal property in the materialEntries definition:
material entries and indices
Warning
You can of course mix and match local and external materials! Just make sure that the materialEntries indices are pointing at the correct material.
However:
If you are using preloadLocalMaterials, you need to use preloadExternalMaterials instead of externalMaterials.