Global Shaders and "Array of Textures"

Panos_Fakitsas
Wed, 23 Feb 2022 11:07:57 +0000
Asset Creation

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?

6 posts - 3 participants