Bind all TextureArray slices as MRTs.

The docs here make it sound like it’s possible by binding the -1 slice index. (Unity - Manual: Texture arrays) When I try that it only renders into the first slice. -1 seems like it’s supposed to do something, since any other invalid index makes for some lovely random rendering patterns.

I tried being “clever” and building a list of RenderBuffer refs, but no real surprise that it doesn’t work. Graphics.activeColorBuffer saves the texture ref, but not the slice. You end up binding all targets to the same slice which seems to explode.

Graphics.SetRenderTarget(_rt, 0, CubemapFace.Unknown, 0);
buffers[0] = Graphics.activeColorBuffer;
...
Graphics.SetRenderTarget(buffers, _rt.depthBuffer);

What I’m trying to do is render some subsampled effects coefficients into screen space buffers that I sample in a bunch of other shaders. Having a texture Array would be great so I don’t have to bind a lot of textures in all my other shaders. Surely good for performance if I can avoid individually binding so many textures.

This is easy peasy in even GL 3.x. :-\ Is there something obvious I’m missing?

Speaking of OpenGL, switching to the GLCore renderer it doesn’t render anything into the texture array even when binding explicit slices. Hrm… TextureArrays are looking a bit crufty as a render target.

Further info: Rendering into a texture array is broken in GLCore on Mac is broken as well, so it’s probably not a Windows or driver bug. The Metal renderer does the same as the DX11 renderer where -1 binds slice 0 only.

Am I misunderstanding the docs?

I definitely don’t want to use geometry shaders, since I want to be able to target Metal and GLES3. Though both support “layered rendering” (i.e. glFramebufferTextureLayer(), or MTLRenderPassAttachmentDescriptor.slice) I assume this is also something that is easily supported by DX11, PS4, etc and not intentionally left out of the Unity API.