Download

Possible to read the Parameter Name of a material using blueprints?

Hi guys,
I am working on a game and I’m trying to read “Parameter Name” from materials that are assigned to the object.
So instead of hardcoding the parameter name, I’d like to read them from the material.

Currently I have this:
615d4716fec7e2df668627727ef89434b03d1ba7.png

But my problem is that the node “Scalar Parameter Values” returns an empty array, even though there are scalar parameters on the material.
Is there any other way to read the parameter names?

Thanks for your help,
Andrej

There is, but its a bit roundabout and I believe it’s a bug that you cannot reference the name using your method. You should post a bug report on Answerhub about it.

The GetScalarParameterValues node can get parameter names from a constant material instance, not a dynamic one. So while it may be a pain in the ***, you need to use a material instance constant, rather than a base material, on any objects you want to create a dynamic material instance from, as in your post. Or, you need to create a variable map(I just noticed this in 4.15, you can now set this like you would set a variable as an array) between base material names, and a material instance constant derived from it.

If the dynamic material instance is derived from a constant one, you can first call get parent, which returns a material interface. Then cast that to a material instance, and use a GetScalarParameters node. Since the constant and dynamic material instances have the same names, you can use the array of names from the constant one to access the values of the dynamic one.

584daeace42c2b9bb67bf5f390baedfda0d8d067.png

Tested it, it works like a charm. Thank you xnihil0zer0:)

Thanks for the workaround, works great until this bug gets fixed.