Texture2D Arrays, get textures count

Hi !

I’m wondering how I could get the number of textures stored in a Texture2D Array … It seems there is no node to get this information :confused:

I use an array of bools to keep track of used tex2darray elements.

Sorry, I don’t understand what you mean ;p

Here I’m talking about a node in the Shader Graph.
I’ve created a Texture2DArray asset with 30 textures in it.
When I assign this asset to a Texture2DArray node in the shader graph, I would like to get this 30 value from a node, and not using any script outside.

There is no node, or any built in functionality for this even outside of Shader Graph that I’m aware of.

If you only need this for Direct3D 11 you could use a custom function node to get this information in the shader.

Tex2DArray.GetDimensions(Width, Height, Elements);

Thank you so much ! :slight_smile:

HA ! No !
This is not working for me … The “Elements” output gives 0 :frowning:
I’m under Linux, could this be the cause ? (some kind of incompatibility with a DX11 function)

Yep, that’s why I said “only for Direct3D 11”. Linux means OpenGL or Vulkan.

Ok ! Thanks !
I suppose there is no workaround for that ?

The usually work around is to write a c# script to set the value on the material when you assign the texture array. But there’s not really a good way to do that with texture arrays assigned not via script.

Ok thanks !
I’ll do that :wink: