In my compute shader, I’ve defined an array of textures:
Texture2D _ColorTextures[22];
In my code, I’ve got an array of 22 RenderTextures (each created by a camera render). How can I pass this array to the compute shader? ComputeShader.SetTexture takes a string (or ID) of a single variable.
One option I’ve seen mentioned is to use a Texture2DArray, but as far as I can tell, in Unity you can’t create a Texture2DArray completely on the GPU, you have to transfer data to CPU and then back, which would be incredibly slow.
Then Texture array may not be right for you. Either you can use an array but have wasted space on some slices, or consider using an atlas (a single 2D texture with the images laid out on it)