Texture array question

I’m creating a Texture array (for cascade shadows) with arraySize 4 and I’d like to render them for debugging purposes.

Is there a way for spriteBatch.Draw to select one of the 4 slices of the texture to render?

Thanks

Nope, SpriteBatch does not support drawing from a texture array out of the box.

You can write a custom Effect and pass it in SpriBatch.Begin().
I am not sure if it works but you can try.

Is this what you are looking for?

Texture2D[] shadowTextures;

void draw()
{

spritebatch.Draw(… shadowTextures[0] …

spritebatch.Draw(… shadowTextures[1] …

No, from context I think he meant Texture2DArray https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/sm5-object-texture2darray. It’s a 2d texture defined by slices.

thanks a lot for the answers, I think I’ll put a debug switch to render the maps twice (one into array another into simple textures). I think it’ll be simpler than the effect and after all it’s just for debug purposes.

(yes, I was refering to Texture2DArray)