How can I change a texture globally in a material function?

Ah that is interesting, didn’t know that, I always thought any texture sample you plug into the material regardless of nodes will always occupy that space.

Thanks again.

1 Like

Ah oops, yeah.


Tbh, I think @MostHost_LA’s render target idea is the way to go. It’s actually super simple and would have no runtime cost (cuz render targets are just like textures). Just make a single render target in you’re asset folder and put that into the material function. Then, for each level in the level blueprint, draw a texture to the render target. You don’t need the materials to be instances since the render target is a texture.

Instructions

All the assets you will need:
image

Steps:

  1. Make a render target called global_tex_rt. Make sure its resolution is set to what your textures will be.
  2. Make a blueprint function library called global_tex_func_lib and put this in it:

    This is what will draw the texture to the render target.
  3. Make a material function called global_tex_mat_func and put a texture sample that uses global_tex_rt in it. NOTE: If the material function only contains a texture sample, don’t use a material function; just use the texture sample directly in the material itself.
  4. Put the material function in your materials (global_tex_mat1 & global_tex_mat2 in the example). The materials do not need to be material instances since the render target is a texture and will update itself.
  5. In the level blueprint, put this:
    image
    “Level Texture” is what the texture will be for the level.

Here’s the result:
image
They use the same texture, one just modifies the colors to show they’re different materials.

You can actually use a custom function to do the same thing at runtime.
Optimizing dynamic landscape materials doing this (although a bit of a nightmare) worked very well for .24

Basically the landscape default stuff always uses texture samples.
Using the custom node you can try (because it’s not always a guarantee) to stop that from happening when layers aren’t painted in at all.

You can find some info along with the flames here

Using a static parameter will definitely work with the a custom node containing an if and 2 inputs.

Using a scalar may or may not depending on who knows what.

As I said there (or if not I’ll say it here now again) there was a definite performance benefit when checking if a layer painted and valid or not for landscapes.