How to use Dynamic Material Instance on Landscape?

I want to implement a game like Crusader Kings, I need to use Dynamic Material Instance to show dynamic border and territorial limits by transfer a dynamic texture as parameter.
To us Dynamic Material Instance on Landscape,I follow this article:

But it doesn’t work on landscape!
This is my test implementation:

  1. A Simple Test Material With a Parameter(Default Red)

  1. Set MID to Landscape Comps and Set Color to Green.

Finally,
It is correct on landscape material’s detail panel.

But it is still RED…

343258-ans.png

Use a material parameter collection.

Yup, this worked. The landscape actor even has a field “Use Dynamic Material Instance”, but clicking that field has no apparent effect.

For this question that somehow was never answered:

For using a dynamic material WITHOUT MPC/Whatever, if for example you need to use dynamic textures, like in my case, dynamic render texture heightmaps.

  1. UE 5.5
  2. Set ‘UseDynamicMaterialInstance’ in the UI to ‘True’

  1. In order to use the dynamic MID do NOT use ‘CreateMaterialInstance’ dynamic or the ilk, but use the special material function called ‘GetMaterialInstanceDynamic’ that is specific for landscape components!

I required it for dynamic heightmaps added to terrain components and terrain fade out.

It doesn’t work on NANITE landscape. I tried everything.

everything works theoritically but NO actual changes is applied to the materials at runtime. it’s just the baked material when you rebuild nanite for the landscape.

Use a material parameter collection. These work on nanite landscapes, they reflect changes in the materials that sample them in real-time, they can be updated in BPs, they can be accessed by almost anything not just materials.

They give you a shared-table for MANY different data-objects that can then drive the material to do things it was not sensitive-to before.

It’s the same thing a RVT gives you: horizontal-information-exchange; multiple things outside a shader can read/write to a common information sink.

This is hugely powerful in allowing the GPU to ‘communicate’ with other-things.

Skip the material-instance, i doubt whatever you want to do cannot-not be done via an MPC.

There is at least one thing you can’t do using MPC but you can do using MID. Is texture changing by texture parameter.
This is what I need on my Nanite tesselated landscape (provide a dynamically created Render Target to displace some parts of a landscape and those parts may change at runtime). I spent almost a week to figure it out and I failed.
Nanite tesselation and displacement works great with material instance dynamic and static meshes. But not with landscapes. It seems that is UE limitation for now, that we have to wait to be solved (maybe in the future).

Use a collection/texture-array and the texture-slot itself becomes a parameter (a 3rd-UV, or Z-coordinate). This can be anything including an MPC-value if you want it to be.

Nanite and tessellation/displacement seems to work great for me, it was pretty straightforward to feed heightmap data into the displacement RVT and then just-sample it in the landscape-material (which is the same shader).

Image

On the LANDSCAPE side of things, after sampling the Displacement RVT, I can do additional maths, like with that render-target to independently track water-levels, snow, dirt, etc, anything who’s height is ‘above’ the landscape and it’s collision, and can dynamically play with post-RVT calcs. I used this as a basis for the trails: Creating Interactive Grass in Unreal Engine 4 | Kodeco

Still sound, still works in 574.

Your suggestions are perfectly hitting my problem. But… :frowning:

Texture Collection is still marked as experimental and, not working at all. Shader with Texture Collection node do not compile, here’s the error (same on 5.7.4 and 5.6.1):

LogShaderCompilers: Warning: Failed to compile Material  for platform PCD3D_SM6, Default Material will be used in game.
Shader debug info dumped to: "F:\Unreal Projects\Testing547_New\Saved\ShaderDebugInfo\PCD3D_SM6\FMatExpressionPreview MaterialExpressionTextureSample_0_c51ba1cf8c3c820f\Default\FLocalVertexFactory\TBasePassPSFNoLightMapPolicy\0"
G:\Data\EpicGames\UE_5.7\Engine\Shaders\Generated\UniformBuffers\Material.ush(10,1): Shader TBasePassPSFNoLightMapPolicy, Permutation 0, VF FLocalVertexFactory:
    /Engine/Generated/UniformBuffers/Material.ush:10:1: error: unknown type name 'FResourceCollection'
FResourceCollection  Material_TextureCollection_0;
^

So I tested Texture Array and it worked, but… :frowning:

I need Render Targets to be in this material. There will be a constant number of them, but they have to be able to be swapped, replaced by new render targets etc. So Texture Array could perfectly fit in this, but it only handle UTexture2D and UTextureRenderTarget2D do not inherit from UTexture2D (as I thought and as it would seem to be), but from UTexture. So, it is impossible to cast UTextureRenderTarget2D to UTexture2D. Yes, I know there are ways to extract content from Render Target as UTexture2D, but my Render Targets contents will be updated every frame, so copying more than one RT constantly every frame to UTexture2D will kill my game :frowning:

Still looking for clean solution for this and still can’t figure it out :frowning: Only if Texture Collections would work or just Material Instance Dynamic on nanite landscapes :frowning:

EDIT:

Found this Bindless Resources - UE 5.4 - #5 by koloved So far so good. Materials with Texture Collection nodes starts compiling and working. Now will try to put dynamically created render targets to the Texture Collection and see what happens. Will let you know here about the results.

Don’t dynamically change the render target itself inside the collection. Add static entries for RTs X, Y, Z, etc so you have the fixed number of slots you need ahead of time. Change what the Render Target points to dynamically. Eg, if your 1st render-target is set to have a camera at place X, use code to move that camera so anything else down-stream, that consumes that RT, would never be wiser. It’s the CONTENT of the RT that’s changing the way we want and not the reference-to or the RT itself.

This way the collection/shaders are completely unaware. To them on any given frame, they just read-the-RT; it always looks ‘the same’ to them.

I owe another guy a tutorial on a floor-tile shader, but I will also use cycles to see if I can jimmy-up an example here too..