Can you use Parameters in Material Functions?

I was excited about Material Functions because I was kindof envisioning them as a way to encapsulate common graph configurations. So, for example, I was going to make a function for UV tiling so I could just keep reusing that subgraph in all my materials. But I couldn’t actually make parameters in the material function, so I don’t understand what they are really for. Am I just missing something? As a more specific example, I was trying to add a vector2parameter so that I could have X and Y tile amounts that would then be multiplied by the respective channels of the texture coordinate node and then this function would just be plopped in to any material that needed tiling and that vector 2 would be accessible through the material function node in the material.

1 Like

Very good question i also waiting for information.

I presume you’d put your parameters outside of the material function and then link them up to the function inputs. Just a guess though.

No, it supports only Input parameters:

I would say Yes, but it only supports input parameters :slight_smile:

You can’t have the actual parameter exist within the function; you would use function inputs and then you would assign default values to those. And then you could drop that tiling function into any material and it would work without new parameters, but if you wanted to change the parameters, you would hook up scalar or vector parameters in the base material.

I’m necro-ing this rather old thread for a reason. I’ve noticed since a couple months that you can now place parameters in material Functions. You can then access these from the instance material where they are exposed.
Now this is quite useful for plenty of reasons. Encapsulating all the parameters and settings into the function, allows the function to be placed in a master material without the need of creating and hooking up any explicit parameters in the material and all parameters are exposed and can be changed through the instance material. It also allows to author the parameters from within 1 function propagated in all the materials that function is used. (Instead of maintaining all the external hooked up parameters in a material, if that function is used in several materials and has several parameters that can be hooked up to the function this can quickly ramp up and be unruly to maintain)

Avoid hooking up and having both a parameter hooked up into a inputFunction in a function, as it will still work and be exposed in the instance material. However if you then hook up also another parameter in the material in the exposed inputfunction input, (which overrides the parameter you have placed in the function into the functionInput node) both the parameter in the function and the one placed in the material will now be exposed in the instance material. The parameter from in the function however will be redundant but still visible and appearing to work (with appearing to work i mean you can change the input value’s and enable/disable the setting but it actually doesn’t change anything) in the instance material. The one in the material will work as expected. This can be confusing as you can’t see from the instance material that the parameter from within the function is now overwritten by the one placed in the material. (As you would expect) and no longer working.

Anyway the question is now you can use parameters in material functions is this legit to do? It seems to work and work very well. But would like a reply from epic on this matter before we use it extensively.

Kind Regards,
Ing

Edit: In answer to my own question if its legit or not. It is. Since 4.6 Added links with information just in case someone (like me) stumbles upon this thread and wants to know.

Under: Expose Parameters from Material Function heading.

Nifty! That’s a nice change. Saves making inputs and params to match.

You can also use parameter collections for params you want to be shared between many materials at once. Check that out too.

I did :slight_smile: Even tried my luck and placed an MPC in material function, but to no avail. They don’t get exposed to instance materials. MPC also don’t get exposed to instance materials when placed in a material. (Unless I’m missing something) They are still good for global params and to dynamically change via blueprint or code though. But not good for shared dynamic settings for many variations of instance materials kind of thing.

Material parameter collections don’t get exposed via instances, they’re entirely independent which is sort of the point. You just call “set scalar parameter” without a material input in any blueprint, then choose the parameter collection you want to adjust.

Just so you know:

“However if you then hook up also another parameter in the material in the exposed inputfunction input, (which overrides the parameter you have placed in the function into the functionInput node) both the parameter in the function and the one placed in the material will now be exposed in the instance material.”

If you care to write the exact same name (and i guess also the Group), Unreal replaces the original Input so it only shows one parameter.