Pros and Cons to control Material parameters via MPCs as opposed to DMIs

I was working on exposing a scenes Blueprint variables to the Blueprints Detail Panel so that I could control some Material Scalar Parameters on the Detail Panel, when I realized that instead of using the standard method of using a Dynamic Material Instance to control the Materials Scalar Parameter that I could instead do the samething using a Material Parameter Collection.

The standared DMI method is to publically expose the blueprints variable so that it shows up in the Details Panel.

Create a Material using the Scalar Parameter.

Create a Dynamic Material Instance within the blueprint so that the material parameters are accessible to the blueprint, which then allows you to modify the materials parameter in the blueprint using a Set Scalar Parameter Value node

MPC Method is pretty much the same with a few changes. Publically expose the blueprints variable so that it shows up in the Details Panel.


Create a Material Parameter Collection with the variable that will be passed to the Material.

Create a Set Scalar Parameter Value in the Blueprint that can be executed along a path, which allows you to modify the value stored in the Material Parameter Collection.

Read the Material Parameter Collection value into the Material

Both methods work fine, but I am wondering what the pros and cons of each approach are.
I do know that when using the MPC method, the Material Parameter does not show up in any Material Instance created from the Material. Does anyone know what the resource difference between them are?

Hi @Cr3ap3r1,

While there are benefits and drawbacks to both, you are missing the third option: Custom Primitive Data. I’ll attach a link below so you can learn more about it.

To summarize:

Dynamic Material Parameters

Pros:

  • Easily control any single parameter at runtime
  • Does not require extra setup in the material

Cons:

  • Creates a new material instance to run parameter (aka extra draw call)
  • Can not be modified/previewed in-editor

Material Collections

Pros:

  • Adjusts a parameter globally that can be used in many materials
  • Great for things like global wind or values you want many materials to read
  • Also great for getting the player location, since you only need to get it once to pass it to many places
  • Works better than the other two options for Sequencer

Cons:

  • Can not be instanced, so does not work well for changing values for single materials
  • Creates an extra reference to the MPC in your blueprint
  • Logic must be set up in material ahead of time

Custom Primitive Data

Pros:

  • Values can be set in-editor and in-game, making it previewable
  • Does not create a new material when using
  • Arguably easier to set in-blueprint than the other two
  • Can be set on the mesh, no blueprint required
  • Since the values are stored per-primitive, this is a great method for altering foliage or instances

Cons:

  • Needs to be set up in material ahead of time
  • Less intuitive to set up and use

Personally, I almost exclusively use Custom Primitive Data, as it’s the most cost-effective and comes with a lot of great usability. Every method definitely has it’s time and place, though.

More info on Custom Primitive Data:

2 Likes

Wow. I believe this is the best answer I have ever received in the five years I have been learning Unreal.
I did not know about the Custom Primitive Data. I have run across references to it a few times but have not looked up what it was. I am surprised it was never mentioned in the thousands of videos that I have watched. Thank you for pointing it out.

And thank you for the time you spent answering my question.

2 Likes

Happy to help! I work a lot with integrating materials into gameplay functionality, so I was excited to see your post!

Quick side note- if you start working with Custom Primitive Data, if you are setting it in the construction script, you need to use the “Set Default Custom Primitive Data” instead of the regular “Set Custom Primitive Data”, otherwise your changes won’t be persisted into gameplay. This was a bit of a headache for me when I first started using it, so hope that helps!

2 Likes

Since you pointed it out to me, I have been doing a lot of research about Custom Primitive Data and Instance Custom Data. I wish I had known about this years ago; they add so much functionality.

I did catch the need to use “Set Default Custom Primitive Data” in a Construction Strip, but thanks for the tip in case others who read this post don’t.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.