I am trying to create a procedurally generated 3D terrain. Terrain is 1 static mesh (not UE Landscape) in my implementation, so I need some way to use multiple materials on one mesh.
I chose Material Layers, and everything works fine in editor, until I try to pass mask textures to Material Layer Blends. I am doing it like this:
UMaterialInstanceDynamic* MaterialInstance = RMComp->CreateAndSetMaterialInstanceDynamicFromMaterial(0, Material);
FMaterialParameterInfo Info(*ParamName, BlendParameter, 0);
MaterialInstance->SetTextureParameterValueByInfo(Info, BiomeMaskTexture);
And if I open that instance in editor, I can clearly see my parameter names there and my mask textures. But the material just ignores them - and keeps using default texture parameter value.
In this screenshot of DynamicInstance you can see parameters are set to my generated mask textures.
I can’t figure out why material doesn’t use updated parameters, so any help is appreciated.
P.S Any alternative methods to solve problem of passing masks to material in runtime are welcome too. I know I can create my own material functions to blend everything in master material, but that results in immense amount of spaghetti and basically unreadable material, so I am trying to avoid it.