2
\$\begingroup\$

Is there a way to expose material parameters in Unreal 4 so that they are accessible from the level editor?

As far as I know, I can only do this through the Material Editor, but I wish to do it more fluently.

E.g. to edit a color for the currently selected object in a level:

enter image description here

\$\endgroup\$
2
  • 2
    \$\begingroup\$ You can also use vertex colors and paint the whole object \$\endgroup\$
    – Rotem
    May 20, 2020 at 12:12
  • \$\begingroup\$ That sounds like a good idea, especially since I'm only using base colors for this project. \$\endgroup\$
    – 01F0
    May 21, 2020 at 11:02

1 Answer 1

5
\$\begingroup\$

In order to properly display parameters from the Detail Panel in the Unreal Editor, you need to create a Blueprint and set a Dynamic Material Instance with multiple Set (Vector & Scalar) Parameters from the Construction Script. Here’s a step by step guide:

  • Mat-1: Create a Material and add a Constant3Vector for the Base color, and Constant1Vector for the other Parameters (let’s say Roughness, Metallic and Specular for this guide).
  • Mat-2: Left-click on each added Constant node (Base Color, Roughness, Metallic and Specular), and convert each one to a Parameter with a specific Name (this name will be used in the Blueprint).
  • BP-1: Create a new Blueprint and add a Static Mesh Component to be able to change your Mesh directly from the Editor. The next steps are always done from the Construction Script.
  • BP-2: Add a Set Static Mesh node and promote the New Mesh pin to a public variable (promote it to a variable and either click on the closed eye inside the My Blueprint Tab or check the Instance Editable parameter from the Detail Panel).
  • BP-3: Add a Create Dynamic Material Instance node, and set the target to the Static Mesh component added earlier. You can also add multiple Dynamic Material Instances on the same Mesh, if it has multiple materials (each mat should have a different Element Index). Promote the Source Material pin to a public variable to select the material from the Editor. Promote also the Return Value pin to a variable (leave it private).
  • BP-4: Add a Set Vector Parameter Value, but make sure it targets the Material Instance (the sentence Target is Material Instance Dynamic should be displayed under the title of the node). Set the Parameter Name to the Base Color Parameter name in the material created before.Promote the Value pin to a public variable to edit it from the Editor.
  • BP-5: do the same with Set Scalar Parameter Value for Roughness, Metallic and Specular values.

Now you can add the Blueprint in the Editor, choose the right Static Mesh and the Material (you can have different materials but they should have the same Parameters nodes, so you can theoretically optimize each of them while still reuse the same Blueprint). Beware that the Blueprint will not check the name in the Set Scalar/ Vector Parameter Value, so if it’s not the exact same name, it will not work while not displaying any message whatsoever.

I’ve added two Pics (one for the Blueprint, the other for the Material) and pasted the Blueprint in BlueprintUE website. The last picture is the result.

Unreal Blueprint Picture Unreal Material Picture

How it looks in the end:

enter image description here

\$\endgroup\$
4
  • \$\begingroup\$ Thanks, material instances are useful! However, I can't see that any of these guides exposes the parameters to the level editor? (directly under StaticMeshActor -> Details -> -> Materials) \$\endgroup\$
    – 01F0
    May 18, 2020 at 17:04
  • \$\begingroup\$ You're welcome! I've added a step-by-step guide to display parameters inside the Editor. \$\endgroup\$
    – user139486
    May 20, 2020 at 10:02
  • 1
    \$\begingroup\$ Awesome, a very nice guide. Thanks a lot for putting it together. I think you should remove the two initial bullets points and stick with the guide! :) I'll make an edit and add an image of the result, to make it more complete, if you don't mind. \$\endgroup\$
    – 01F0
    May 21, 2020 at 10:49
  • 1
    \$\begingroup\$ You're welcome, I was happy to help! Your edit was really good, I accepted it and removed the two initial bullet points, so only the complete answer remains :) \$\endgroup\$
    – user139486
    May 21, 2020 at 11:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .