Adjusting Parameter of specific functions in master material

Hi,

EDIT: Short and simple form of question :

My question is about using material functions within other material functions. For example, I have a material function that allow you to adjust the tiling of a material and I use it in a material function for a grass layer. I use the function for tiling again in another material function such as for a rock layer. Then I add both the rock and the grass layer to a material for my landscape.

How do I make it so that when I create an instance of the landscape material, I can adjust the tiling of the individual material functions? For example, I would able to change the tiling for the grass function to 0.5 and the rock function to 0.02. I can not change the parameter defaults in within the material because when I do that, thousands of shaders have to compile.

OLD:

I am trying to create an auto landscape material and I have having some difficulty with dealing with parameters and functions.

So in my landscape material, I have different material functions for layers such as grass, dirt, rock and snow. Each of these functions have their own parameters such as tiling, albedo controls, displacement controls, and many others.

However, these parameters are created and adjusted through their own functions. Specifically, I have a function called “MF_MapAdjustments” to adjust things such albedo, roughness, normal, ambient occlusion, and displacement of the material and I have another function called “MF_tiling” to adjust tiling. Since I am using these controls over multiple material functions (grass, dirt, rock…), it makes sense to make them into a function (Full disclosure: I did not create the entire functions myself. They came with an asset.).

The difficulty I am having is that I want to adjust the parameters inside of these functions (parameters such as tiling and displacement) for individual material functions inside of an instance of the master auto material. Say I want to change the tiling for the rock layer to 0.01 and the tiling for the grass layer to 0.25, I want to be able to do this in an instance of the master auto material.

My auto material is called “M_Landscape_Auto_Material” and I have an instance of this material called “MI_Callaghan_Terrain_Material.” One of my material functions is called “Grass_01”.
I want to be able to change the tiling for Grass_01 in MI_Callaghan_Terrain_Material. However, when I look inside MI_Callaghan_Terrain_Material, I see these variables (I see the tiling variable, etc) but these are global to the material and if I make any changes, they apply to all the material functions and the entire material.

How can I make it so that I can change the parameters of individual material functions within the material instance? I know I am repeating myself but I just want to be very clear with this question. I am pretty sure this is possible because I found a material from an asset that is similar and it allows you to adjust the parameters of individual material functions in an instance. I have attached images below:

Hopefully this question makes sense, if you need more clarification please comment below.

I edited your post to include line breaks as it was rather difficult to read as a wall of text, please use them in the future.

I haven’t played with materials much, is there a free asset or something I could look at to understand the issue?

Hi,

I got the functions “MF_tiling” and “MF_MapAdjustments” from the “MSPresets” folder that is created when you import Megascans assets. For unreal users, I think that all megascan assets are free if you log in with your account. I would try importing a surface asset to your project as it will create a “MSPresets” folder with the functions I am referring to.

There are some adjustments that I made to the “MF_MapAdjustment” function, adding in things such as parameters and adjustments for ambient occlusion and displacement.

The material that had similar properties was a landscape material that I got from an asset called “Spring Landscape” by “Pixel Perfect Polygons.” This assets was free for a month but I do not believe it is free anymore. If you do have it in your library (cause maybe like me, you get all of the free for the month assets lol), I would use that one as a reference.

Other than that, I would recommend quickly creating two material functions with the functions “MF_tiling” and “MP_MapAdjustment” (This is very quick because you can just copy and paste the stuff in the “MS_Default_Material” that also comes in the “MS_Presets” folder). Then I would add these material functions to a material and then you can create an instance of that material.

Thanks you for your help,

Yug

Sorry it’s taken a bit to get back to you. I’ve just gotten megascans installed so I’m investigating this now.

Always.


From what I can tell, instead of modifying the material functions you could add parameters to the materials that use it and modify it there?

I am not sure what you mean by that. Are you saying that I should not use the functions to adjust the tiling and other stuff such as albedo and roughness? If I have the parameters in the material functions, they will show up in the master material? I am not sure what you mean by adding the parameters to the materials that use it and modify it there.

I have 7 material functions that use the functions for tiling and map adjustments, and the functions themselves are very complex. I would not know how to take the things in the functions and transfer them into the material functions and still make it work.

Is there a way to keep the functions and show the parameters for the individual material functions? Within a material function, for example grass_01, I am able to change the parameter defaults but since I am changing the defaults, everytime I make minor changes, I has to compile thousands of shaders and I am not able to see the result right away. I do not want to have to change the default parameters inside the functions. I want to be change the values as in an instance of the master material. (I hate shaders compiling lol)

Also, I have an error message saying “Texture Streaming Pool Over MiB Budget.”

Anyway, I would like to thank you for your help because you really give amazing feedback and help. I would not think that anyone do so much to answer one question. Downloading megascans and recreating the issue in a project just to help me with this issue so thank you very much. And you have helped me on many other posts as well, so thanks for that. I always forget to reply back on older posts.

I think this is a simpler way to word the question and if any new people are reading this post, here is my question:

My question is about using material functions within other material functions. For example, I have a material function that allow you to adjust the tiling of a material and I use it in a material function for a grass layer. I use the function for tiling again in another material function such as for a rock layer. Then I add both the rock and the grass layer to a material for my landscape.

How do I make it so that when I create an instance of the landscape material, I can adjust the tiling of the individual material functions? For example, I would able to change the tiling for the grass function to 0.5 and the rock function to 0.02. I can not change the parameter defaults in within the material because when I do that, thousands of shaders have to compile.

It should come up in the instance.

Disregard that, thought it worked differently.


Granted I don’t know a lot about materials but this seems to be what you’re after for UVTiling

Here I created two scalar parameters in MF_Tiling and they come up in the grass instance material on the right.

Um I do not think you need to add those two parameters because the constant3 parameter “Tiling/Offset” already controls the tiling and the offset. You can see and control this parameter at the top in the “00 - Global” group for the parameters. That is not what I was looking for. Of course, I can change the parameter defaults in the material functions, but I want to able to change them in the master material’s instance.

I think there might be another way to do this without changing defaults and having to wait for compiling shaders every time. I could make an instance of the material functions and use those in the master material and if I needed to change something for a specific material function (such as the tiling), I could open up the instance for that material function and change it there. Even if that works and shaders don’t have to compile every time I make minor changes, it wouldn’t be that efficient as I was hoping to be able to change all the attributes of the individual material function in the master material instance.

I wish there was a way to group a function and its parameters. If in the functions, say for tiling, I change the grouping for the parameters, it would change across all material functions and it would make no effect. If I could somehow differentiate the functions used in different material functions, I think I would be able to change the parameters for individual material functions.

Anyway, I think my best bet to is to use material function instances and use them in the master material instead. This is risky, because first of all, I will have to wait for around 14 thousand shaders to compile and if after that, it does not work and I try to make changes to a function instance, it will have to recompile the shaders. Do you think this will work?

EDIT:
I just tried it with a test material and it did not work so disregard the part about using material function instances.

I think my only option is to break up the functions for map adjustments and tiling for every material function and differentiate the parameters so that they show up in the master material instance. I will have to copy everything from the function and paste it over and connect it properly for every material function. It will be a lot of work lol.

Before I do, are you sure there is no other way to do this? Could you reach out to someone who maybe knows more about materials and material functions?

Well I guess I’m too noob for this.
@Marc_Carlyon, don’t suppose you have enough experience with materials in Unreal to help here?

Sorry no i havent played with them in unreal.
Sounds like you are chadging the tiling at runtime BUT it doesnt like you nesting functions in functions.

This a very layman understanding and in all likeness incorrect.
I have posted this to our discord server to see if we can find some external help from other students on this as its a very niche thing that we havent covered exactly.

Hope that some help comes your way or maybe join the discord server too :slight_smile:

Hey guys,

I ended up breaking open the functions and differentiating every parameter by adding a prefix and grouping them. However, I have run into another problem. After redoing the material functions (for grass_01, dirt, rock…) I added them back to the master material. Then, I applied the instance of the master material to my landscape and waited for the shaders to compile. However, I got this really weird result with the material when applied to the landscape. In the preview inside of the material, it looks fine. However, I am getting weird shadows all over the place when I apply the material to the landscape.

The landscape without the material looks fine but it looks like this with the material :

Here it is without a material :

As you can see, there are random dark spots over the landscape when I apply the material and it is especially dark in the middle. Here is my material and the tiling variation setup inside the material. I think that the tiling variation that I am doing may be the reason for this weird effect because other than that and breaking open the functions adding prefixes to parameters for the material functions, I have not changed anything else. But I think it is more likely that this is just a bug, because before when I was testing the tiling variation, it also looked fine. I think it is probably a bug and I do not know how to fix it.

Yup, definitely out of my expertise, sorry. Maybe @Marc_Carlyon ??? :confused: