I need to set an array of textures in my GLSL shader from Unity, but seems there is no support for this?
In my shader:
uniform sampler2D textureArray[512];
Then setting the array with this:
for (int i=0;i<512;i++)
mySharderMaterial.SetTexture("textureArray"+i, textures[i]);
But this does not work, and I tried many other variants as well. How to do this in Unity?
I am aware of Texture2DArray / sampler2DArray, but those cannot be used in this case as the textures will need to be in many different formats (size and type). I also tried to use individual textures and then select them using a long range of if’s, but this also does not work as my shader is very complex and the GPU ran out of instructions. The shader works fine with arrays as described above, but I cannot find a way to set the array elements in Unity.
Will I need to write an OpenGL wrapper myself to do this, or is there a sensible way to set textures in an array in Unity?