Tutorial: Intro to Unreal Engine Material Functions

Tutorial / 03 March 2023

This tutorial will go over Material Functions in Unreal Engine. What they are, how to make and use them. This is a beginner level tutorial.

1. What are Material Functions?

Material Functions are nothing more than network of nodes that will perform an operation, and return a result. Their main purpose is to simplify material creation. Instead of recreating a commonly used function (node network that does something) every time a new material is made, you can package those into a Material Function and use them in your graph as a single node.

In the above example the MF_Tile Material Function does exactly the same thing inside a Material Instance as the node network above it. I can simply use this node instead of rebuilding the network every time. It also means I now only need to edit one Material Function instead of every material in which the functionality is used. Makes life much easier.

Material Function needs at least one Output, to return the result of it's internal operations. But it does not need to have any Inputs, like our MF_Tile above which already contains everything it needs to work. See below.

Material Functions can have as many Inputs and Outputs as necessary. And be internally as complex as necessary (with some limitations we don't need to get into here). MF_ is the commonly used prefix for Material Functions in Unreal Engine. From now on I'll simply refer to them as MF.

2. Our first Material Function.

First things first, what do I actually want my MF to do? I would like my MF to take a Vector4[R,G,B,A] or TextureSample and output each channel separately as well as RGB and RGBA.

I'll be calling it MF_SplitComponentsWithAlpha, since there's already a SplitComponents inside Unreal that takes a Vector3 but ignores the Alpha channel.


We start by right clicking into our Content Browser and then going to Matarials -> Material Function. The node graph will look almost exactly the same as a regular material graph, only difference being fewer Details to edit on the left and only a simple Output node.

2.1 Adding Outputs and Inputs

First thing I need are my Outputs, one for each channel, RGB and RGBA. I give them Names, brief Descriptions (for hover over tooltip) and Sort Priority in descending order, so my Output RGB has priority 0 and my Output RGBA, priority 5.


I add my Input node. If I want a defualt value for this input I tick the Use Preview as Default. The MF will use the connected TextureSample as the default input. If nothing is connected to the Preview input, the Preview Values you set will be used instead.

Input Name seems self explanatory and Description will be displayed as a hover over tooltip for the input pin.

Input Type lets you select the type of value this MF Input will take. I set it to Function Input Vector 4. It'll try to convert whatever you plug into it into the Input Type specified and if it cannot do so, will thrown a compilation error.

2.2 Creating our Function

So we have our Inputs and Outputs made, now we need to actually create the operations that happen between them.


Here I use ComponentMask nodes to split individual channels as well as RGB and an unaltered RGBA (this is refered to as Passthrough). That's pretty much it. This will give me all the functionality I need.

2.3 Cleaning up and Material Function Library

I did a little test where I pulled my MF_SplitComponentsWithAlpha into a Material Graph and tested it with a Texture Sample to make sure it works. Now it's time for finishing touches.

I got rid of the Preview texture and unticked Use Preview Values as Default, this node should work with external inputs only.


I want it to be available in my Material Function Library, represented by the Palette window on the right of the Material Graph.
I also added it to 3 different Library Categories in the Library Categories Text Array. So they will appear under Misc, Math and Vector Ops in the Palette.

The new MF may not appear in the Palette until I restart Unreal Engine.

Keep in mind I can always simply pull the MF straight from the Content Browser into my Material Graph.

Lastly I wrote a short Description which will appear as a tooltip when you hover over the MF_SplitComponentsWithAlpha node.

3. Conclusion

After a restart my new Material Function can be searched for in the Palette and sits under the assigned Categories

This concludes the basic introduction to Material Functions in Unreal Engine. As always I encourage you to look deeper on your own.

Material Functions in UE documentation
Existing Material Function Reference



BTW, any Parameters inside your MF will be editable inside Material Instances. In your MF you can tick Prefix Parameter Names to prefix the groups containing them.