Unreal Engine 5 Crashing when using texture sample as parameter in material function instance

Hi,

I’m trying to create a landscape material (M_Landscape) using a master function (MF_LandscapeLayer) as material layer and creating instances for each layer (grass, dirt, rock…)

M_Landscape:

MF_LandscapeLayer:

MFI_LayerGrass:

MFI_LayerRock:

When i plug in the LayerGrass BaseColor into the M_Landscape BaseColor the editor don’t crash but it does when i plug in the LayerRock BaseColor instead.

I don’t know if it’s a bug or if i’m doing something wrong as i’m a beginner but trying it in 4.27 don’t crash the editor.

Error:


Waiting for any advice :slight_smile:
Thanks

Hi,
I have a question, what do you want to achieve with Material Function Instance ? I don’t know their usage.

Until now, I have always used Material Instance, so I instantiate the Material M_Landscape.
In the instance I have access to all the parameters, including subfunctions parameters and I don’t know if it’s not sufficient for your needs.

I’ve made a try with Material Instance in a test project and it’s functional.

Hi,

I’m trying to use material functions instances so I don’t have to make the same logic multiple times and just replace the TextureSamples references for each instance instead.

Doing this crash the engine so I’m forced to make my base layer into my M_Landscape, duplicate it for the other layers and change the Textures references.

It’s just time consuming if i want to add more features because i need to duplicate it everywhere instead of having a master function with all the logic and the instances with the Textures references.

I’m using the surfaces from megascan but i can’t import the material instance directly into my landscape material right ?

Thanks

Ok I’ve understood, I don’t work with the same process.

In my shaders, I use the same function and expose the two inputs as params in my main M_Landscape in this case bu I understood the interest to avoid the exposition of too much parameters in the main shader.
I’ve tried and obtained the same result, I don’t know if it is a bug or a normal situation. There is something in the parameters, because with the usage of the two instances of the function you expose two times a variable with the same name in M_Landscape. When you link MFI_Grass, you can see that diffuse is exposed in the material parameters. So when you link MFI_Rock, you make a conflict with a second parameter Diffuse.

That’s why in my case a solution could be to make this modification.

I understand the reference issue better I will do as you showed then thanks :slight_smile: