Material Parameter Collections are a super useful new feature in Unreal Engine 4. They are a collection of Scalar and Vector Parameters that can be referenced from any number of other materials or Blueprints. This means they change globally, so if you change the value, everything that uses them changes automatically. This also happens dynamically which makes them super handy!
You can create one like this:
A Scalar Parameter is a single floating point value, and Vector Parameter is four floating point values that could be used for setting a color with an alpha channel, as a vector, or whatever you would like really.
In the sample game Tappy Chicken, I used a Scalar Parameter Collection quite a bit to do things in the materials that would be more expensive otherwise. Since this is an unlit 8 bit looking 2D game, I wanted to simulate fog, time of day changes, and things like screen flash, and fading to black in the materials. This also allows you total control over where and how they are used as well. For example, when I’m tinting the screen to simulate time of day change, I only tint the UI graphics 50%.
Here is the setup I used:
In the material editor to use a Material Collection Parameter, right click in empty space, and select Parameter/CollectionParameter.
Here is the setup showing how I used these Scalar Parameters in the material for the panning background elements.
I used the red channel off the vertex colors of the meshes that make up the scene to add the fog color to the background hills to simulate scene depth.
In the Blueprint, I made a function called SetSkyColor to set all 3 colors so I could easily change the time of day.
Then I made another function called ChooseSkyColor that uses SetSkyColor to randomly choose a time of day.
This is what they look like in game.
These are just some examples of how you can use Material Parameter Collections. This is a great tool to have in your toolbox, so give them a shot and see what creative ways you can use them to enhance your games.
Questions or comments? We’re over in the forums so come swing by and let’s chat!