# Global Shaders and "Array of Textures"

**URL:** <https://forums.unrealengine.com/t/global-shaders-and-array-of-textures/501357>\
**Category:** Asset Creation\
**Tags:** UE4-25, hlsl\
**Created:** [February 23, 2022, 11:07am UTC](https://forums.unrealengine.com/t/global-shaders-and-array-of-textures/501357 "2022-02-23T11:07:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Panos\_Fakitsas](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Panos\_Fakitsas](https://forums.unrealengine.com/u/Panos_Fakitsas)\
**Post date:** [February 23, 2022, 11:07am UTC](https://forums.unrealengine.com/t/global-shaders-and-array-of-textures/501357/1 "2022-02-23T11:07:57Z")

</div>

Hi there people, this has to do with global shaders and hlsl code.

I declare in the global shader file a parameter struct like this:  
BEGIN\_SHADER\_PARAMETER\_STRUCT(FParameters, )  
SHADER\_PARAMETER\_TEXTURE\_ARRAY(Texture2D, Textures, [4])  
END\_SHADER\_PARAMETER\_STRUCT()

And then I am passing it though the pixel shader to sample the textures. In the shader.usf file I must to declare each one of the textures separately as one texture to sample them.  
For example:  
Texture 2D Texture\_1;  
Texture 2D Texture\_2;  
…

This way is not practical and convenient. If I define a Textures array like “Textures[4]”, the shader throws an error and it says that the Textures array is not bound.

Can you recommend me a way where I can use in the shader.usf file an array of Textures?  
Is there any solution to my problem?

---

<div class="post-metadata">

**Author:** ![ProCeeDor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ProCeeDor](https://forums.unrealengine.com/u/ProCeeDor)\
**Post date:** [April 17, 2024, 1:47pm UTC](https://forums.unrealengine.com/t/global-shaders-and-array-of-textures/501357/2 "2024-04-17T13:47:14Z")

</div>

Me too, Have you solved this problem?

---

<div class="post-metadata">

**Author:** ![Panos\_Fakitsas](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Panos\_Fakitsas](https://forums.unrealengine.com/u/Panos_Fakitsas)\
**Post date:** [April 25, 2024, 3:43pm UTC](https://forums.unrealengine.com/t/global-shaders-and-array-of-textures/501357/3 "2024-04-25T15:43:18Z")

</div>

I had to implement the shader to take only 1 texture, and in the rendering thread call drawPrimitive for each one texture… shaders are not designed to take an array of elements to be honest to you.

---

<div class="post-metadata">

**Author:** ![Cloud\_a\_Knight](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Cloud\_a\_Knight](https://forums.unrealengine.com/u/Cloud_a_Knight)\
**Post date:** [July 31, 2024, 1:45am UTC](https://forums.unrealengine.com/t/global-shaders-and-array-of-textures/501357/4 "2024-07-31T01:45:31Z")

</div>

Hi! Does your textures from external such as a png picture load in game thread to UTexture2D and the pass it to render thread to FRDGTexture? And how did you get it in your shader?

---

<div class="post-metadata">

**Author:** ![Panos\_Fakitsas](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Panos\_Fakitsas](https://forums.unrealengine.com/u/Panos_Fakitsas)\
**Post date:** [January 20, 2025, 10:11am UTC](https://forums.unrealengine.com/t/global-shaders-and-array-of-textures/501357/5 "2025-01-20T10:11:03Z")

</div>

Unfortunately not because there is no such a way

---

<div class="post-metadata">

**Author:** ![Panos\_Fakitsas](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Panos\_Fakitsas](https://forums.unrealengine.com/u/Panos_Fakitsas)\
**Post date:** [January 20, 2025, 10:14am UTC](https://forums.unrealengine.com/t/global-shaders-and-array-of-textures/501357/6 "2025-01-20T10:14:49Z")

</div>

Yes I create it as a Utexture2D and then passing render command (ENQUEUE\_RENDER\_COMMAND) I am getting the FRHITexture to load it in the shader. There is a specific way of how you pass the texture to the shader, see engine’s source.
