Download

[Shaders] Is there a way to call a (Material Function) with in a (Material Instance)?

I am trying to build a blend shader that blends together 4 different tileable materials through a RGB texture or vertex color. Here it is working:

Right now its all hard coded into the shader and it works fine, but I want to organize it so I can use Material Instances.

Here is my issue, I want to be able use prepacked material functions because I can hook up all the tileable textures I need to the material function instead of hooking up every tileable texture to every layer of the material instance. Here are some screenshots to help show what I mean.
Material Function 1, for a tileable red brick:

Here is how I am using the material function of the tileable red brick in the base shader:

Here is what I want my material instance to look like:

I know I can individually hook up every texture in the material instance, but I really want to figure out how to use these material functions as quick presets to grab and change materials around.

Thanks for any help with this!

I hate to be that guy, but I don’t think it’s possible, sorry.

Yeah, a material isn’t a valid parameter for a material unfortunately. Once you start seeing how your material is converted into code and how it all fits together you realise what a monumental task that would be. It would undo so many optimizations as well.

However, there might be a better solution. Have you tried painting with material layers on landscapes? Is it possible to do this on meshes as well?

Make the texture samples in your function texture parameters. An instance of a material that uses the function should be able to change the textures.

Material Functions will pass their parameters along to any parent material that uses them. They’re just collapsed nodes, nothing more.

If like Mootjuh says you make the texture samplers in the function parameters (and ensure you name them uniquely across different material functions), they will show up when you instance the master material.

Thanks for the info guys. I figured it was worth asking.