Download

Can I have a Material as a function input?

Full context:

I have a project with multiple objects that each have tons of different materials. Now I need to add an opacity mask to each and every one of them.
I know that one way would be to create a new material for every single old material, copy/paste the nodes from the old one to the new one, then add my opacity mask function. This would take way too long though.

What I need is to create a material with another material as a parameter, then, at runtime, obtain my list of materials that are on the objects, then create dynamic material instances for each one with the original material as an input.

Is there a way to do something similar? I know that you can have MaterialAttributes as a function input but I don’t know how to connect a material to that.