# 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:** 1\
**Showing post:** 23

<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.

---

_[View the full topic](https://forums.unrealengine.com/t/how-can-i-change-a-texture-globally-in-a-material-function/227263)._
