Add prefix to material function parameters?

It’s possible to add a prefix to the material function parameter.

If I have a material function with parameters and want to use that material function multiple time in a material it’s not possible because the parameter name will be same.

If I have:

MF_Something:
Param: Factor

Material:
MF_Something
MF_Something

It will show only that in the material instance:

Material Instance Params:
Param

I need to be able to do this:

MF_Something:
Param: Factor

Material:
MF_Something (Prefix1_)
MF_Something (Prefix2_)

Material Instance Params:
Prefix1_Factor
Prefix2_Factor

It’s possible?

Hi Mathieu,

This isn’t currently possible, no. There isn’t a way for the parameter expressions to know that they’re within a particular instance of a material function until we traverse the graph during material translation, so it would have to change it’s parameter name on the fly. Typically the material graph and the contained data should remain constant during traversal.

If you go down this route I’d suggest making it opt-in per material function call to preserve the existing behavior. Changing the name would likely need to happen during the expression’s Compile() call, appending a user-defined prefix to ParameterName and caching it locally, handled for each parameter expression type. It may then need to notify anything still referencing the expression that it had updated. This would also have to re-evaluate the name on every compile call or risk issues with stale data moving and re-connecting the node across the graph(s). For a starting point I’d create a simple test graph with a scalar parameter, place a breakpoint in UMaterialExpressionScalarParameter::Compile() and become more familiar with how the graph translation occurs, where the parameters are stored and so on to ensure you’ve covered all the relevant code with the change.

The current intended workflow would be to pass non-shareable parameters as inputs to the material function instead, defining the data at a higher level with unique names.

Thanks,
Chris