Constant vs. Dynamic Material Instance

I would appreciate some clarification about when to use constant or dynamic material instances for material variables.

First of all, I’m working mostly in code, if that makes any difference…

Second, I need to change/set material parameters at runtime. But, in general, I don’t need any values that change all the time (per frame), only very rarely: stuff like skin color, that can be set by the user in a character editor.

So, in case someone tells me I can’t create constant material instances at runtime (without editor) or change their variables/parameters (again, without editor), that would already answer my question.

I am not sure what dynamic really means. Are dynamic MIs for parameters that constantly change or for any variables that need to be set at runtime?

The names stand for itself. Constant means constant. They are instances you create in Content Browser. Once you set parameters and click play they become constants.

If you need something that changes in game just use Dynamic instances. They are created by “Create dynamic material instace” in BP and then you set its parameters by names. Pretty sure it should work the same in code.

Also pretty sure they dont run every frame, but just when you change variables. Any way Ue4 documentaion pretty poor so I cant tell 100%.

If you only need it for 1 or few characters you can freely do it not fearing perfomance drops.

Ok, so I don’t have to worry about what class to use. It’s always dynamic.

There’s some kind of input node for dynamic parameters in the material editor (it’s red…). Maybe that one is for truly dynamic values that change all the time. Although I wouldn’t know how to use it yet or if I need to.

I just want to set body parameters for a character generation system like skin color, “glossiness” etc. However, I won’t be needing a few instances, more like dozens to hundreds of them. Well, I will have to see what performance I will get.

I think it should be dynamic instance in creation character scene and then when you start game level create constant instance with this parameteres. Just don’t know if you can create constant instance in real-time