Global Shaders and "Array of Textures"

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?

2 Likes

Me too, Have you solved this problem?

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.

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?