Materials Parameters in Blueprints - Tip of the Week

Michal Franczak 2019-10-09 11:39 tutorial  > Unreal Engine  > modeling

Unreal Engine 4 Tutorial.

Sometimes you may want to control material parameter in blueprint. It gives many advantages - you can control material parameter in sequence editor, or change it when you will approach certain area, change color of a wall with some input trigger (like gamepad or keyboard stroke). In this tip we will look at the part of creating material parameter and setting its value in blueprint. It's quite easy.

First, create Material Parameter Collection - it is kind of container for material parameters. 



Then, open Material Parameter Collection and create your variables. You can create scalar variable for controlling single values (like aplha, masks, roughness amount, metallic amount) or vector variables for controlling colors.



Here I have created Scalar Parameter with default value "0" and I gave it a name "PARAM01".


Now we can assign this parameter to some material property. Let's create new material and open node editor.



In node editor find "Collection Parameter" and add it.



We created material with some base color, metallic value of 1 and roughness assigned to Collection Parameter "PARAM01".


Now let's change the value of this parameter. We can do it in blueprint or in sequencer.


To control this parameter in sequencer, create a new sequence and press green "Track" button. Then choose "Material Parameter Collection Track" > choose material parameter collection that you created. In our case it is collection named "MPC01".



Choose "Parameter" > "PARAM01" from the list.


If you want to control parameter by blueprint, create new blueprint class > Actor and open it.



On the top of Blueprint window you will find three tabs: "Viewport, Construction Script" and "Event Graph". We are interested in the third one. Click on "Event Graph" and let's start adding nodes. you can do it similar to material editor - by pressing right mouse button in editor window. Our first node will be "EventBeginPlay". This node launches the script after we press "Play" button in main editor window. 



Our second node is "Timeline". We use timeline when we want to change some value in time. I want to change my material parameter value over time, so the timeline is the node I want. We connect EventBeginPlay with "Play from Start". This way each time when we press "Play" script will start from the very beginning of timeline. If we would plug it to "Start", with each press of "Play" we would start from some timeline moment.



By doubleclicking Timeline node we open Timeline editor. We can create a new curve by rightclicking and creating points. Curve can be linear or bezier, it depends of shape of points we will choose. I created triangle linear wave. On the top you can see length: 3.00 seconds. I also checked "Loop", so timeline will play indefinitely after launching script, changing our value from 0 to 1 and back. Note that our track has the name "New Track_0".




Our last node is "Set Vector Parameter Value" which is used to target our parameter in material. You can see "Collection" box, where we can choose MPC01 collection and Parameter name "PARAM01".



Last but not least - connect white triangle from Timeline to "Set Vector Parameter Value" node. Triangles in blueprints are for updating events. They generally control the flow of the script, order of operations. You can save the script and drag and drop your blueprint to viewport. Without dragging it will not work.



The result: after pressing "Play" our monkey changes roughness in 3 seconds intervals.


Author: Michal Franczak Editor: Michał Franczak
You may also like...
ZBrush 2021.7 released!

ZBrush 2021.7 released!

A free upgrade packed with new features.


You need to be logged in to leave a comment. Don't have account? Register now.
  • ul. Przedzalniana 8, 15-688 Bialystok, POLAND