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

**URL:** <https://forums.unrealengine.com/t/how-can-i-change-a-texture-globally-in-a-material-function/227263>\
**Category:** Asset Creation\
**Tags:** unreal-engine\
**Created:** [April 30, 2021, 3:48pm UTC](https://forums.unrealengine.com/t/how-can-i-change-a-texture-globally-in-a-material-function/227263 "2021-04-30T15:48:56Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![Poet\_11](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Poet\_11](https://forums.unrealengine.com/u/Poet_11)\
**Post date:** [May 10, 2021, 12:16am UTC](https://forums.unrealengine.com/t/how-can-i-change-a-texture-globally-in-a-material-function/227263/21 "2021-05-10T00:16:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![midgunner66](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/midgunner66/32/466711_2.png) [@midgunner66](https://forums.unrealengine.com/u/midgunner66)\
**Post date:** [May 10, 2021, 12:37am UTC](https://forums.unrealengine.com/t/how-can-i-change-a-texture-globally-in-a-material-function/227263/22 "2021-05-10T00:37:27Z")

</div>

> [@anonymous\_user\_232197e21](#):
>
> Sadly Material Parameter collection does not allow textures to be changed, only values and vectors.

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](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/9/098344d4a8adcbbe0378648e002a5f72551fe3dc.png)
> 
> 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:  
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/b/3/b3c644933404ac1b7e840573929f7e64bbf66c3f.png)  
> 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](https://d3kjluh73b9h9o.cloudfront.net/original/3X/b/3/b34319ef2858641d7867cda0a386dc677ced1dd4.png)  
> “Level Texture” is what the texture will be for the level.

Here’s the result:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/a/f/af35ea427d8abaf25435c422da132601a35b3324.jpeg)  
They use the same texture, one just modifies the colors to show they’re different materials.

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [May 10, 2021, 1:08am UTC](https://forums.unrealengine.com/t/how-can-i-change-a-texture-globally-in-a-material-function/227263/23 "2021-05-10T01:08:12Z")

</div>

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

> [@Dynamic flow control in materials](https://forums.unrealengine.com/t/dynamic-flow-control-in-materials/68393/63):
>
> I have tried to replicate your results, but I could not do so. I have tested in both 4.25.1 and 4.22.2, and both versions give me the same result, that no branching actually happens: You see the material has a bunch of very heavy noise nodes, to see if it works or not. I have placed a plane in the level with this material applied, and set the screen percentage to 200% to easily see any performance issues caused by the pixel shader. No matter if the Param …

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.

---

<div class="post-metadata">

**Author:** ![BiaXThePanda1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BiaXThePanda1](https://forums.unrealengine.com/u/BiaXThePanda1)\
**Post date:** [September 6, 2025, 3:29pm UTC](https://forums.unrealengine.com/t/how-can-i-change-a-texture-globally-in-a-material-function/227263/24 "2025-09-06T15:29:54Z")

</div>

Thank you so much, that worked like a charm.

In case someone come across to this and wonder why the textures look noisy (black) when they are in the distance it’s because of the RenderTarget’s mipmap settings.

First you should check the “AutoGenerateMipMaps“ in your render target.

Then instead of using “DrawTexture“, use “DrawMaterialToRenderTarget”. And yes, you’ll need to create a empty material with a texture sample that has your texture in it.

[Previous page](https://forums.unrealengine.com/t/how-can-i-change-a-texture-globally-in-a-material-function/227263.md?page=1)
