When we change a parameter directly on Material in Unreal Engine, you’ll notice that it takes a while for us to preview the effect. That’s because under the hood, UE has to compile our materials before they can be rendered, which is computationally expensive and creatively annoying. Thankfully EPIC have thought of a snazzy solution to this problem called Material Instances. Let’s take a look what they are and why we should use them.
Much like the class/instance relationship in programming, a Material Instance is an instantiation of a Material Class. This means we still need a somewhat abstract base material, declare what parameters can be overridden, then create an instance of the base material on which we set our parameters. Although this sounds complicated, it means better performance and quicker previews.
To demonstrate this workflow, let’s create a new material and call it BaseMAT.
Open it up and create a Vector 3 node (hold 3 and left click), then connect it into the Base Color channel of our material. So far so good.
We need to turn the constant value into a parameter so that it can be overridden on the instance in a moment. To do this, right-click on the node and choose Convert to Parameter. This will let us specify a name, which will appear on the instance. I’ll call mine Base Color.
Head back to the Content Browser and right-click on the material to create a Material Instance from it. I’m calling mine BlueMAT as I’d like to create a blue material for my scene. Open the file and see something like this:
No nodes, just a table of values. At the top under Global Vector Parameter Values, we can see our exposed Base Color value. Tick the box and pick a colour, and we’ve made a working instance of our material.
I can now drag this material onto an object just as it were a regular material, and my object will appear blue. Nothing new about this. However, when I go back into my instance and change the colour value, the result appears in my viewport immediately without a length re-compilation process. That is neat and handy!
This works with other material properties as well, like textures and emissive values, just as long as they’re defined as overridable parameters on the original material. So remember: if you do create your own materials, it’s better to create an abstract parametrised base material, then create instances from it and apply your changes to those for better performance.
Happy rendering!