Texture arrays?

I know they’re usually frowned upon, but I have the following problem.

I have 10 items, and each of them have 5 animated states. So for each object I have 5 sprite sheets. Pretty large sprite sheets.

That means a grid (to visualise) 10 x 5, and each cell is a sprite sheet of 360 images.

Because of the game dynamics it would be really handy if I could put these sheets in a 2d array as object 1,3 will always ‘turn into’ 1,4 and then 1,5.

Is storing large graphics 2048x2048 in an array as bad as storing small textures in an array? Is the memory loss diminishing with size?

Would I be better with 10 lists?

Any ideas on a postcard please!

Thanks.

Why do you need arrays at all? Your items are seprate right? Or do you want to batch them all in one go?

It’s probably fine, just try it out. Performance will not be an issue because of using arrays (unless you are already hitting limits)

You have to draw your spritesheets into the texture array, which you can do like this

graphicsDevice.SetRenderTarget(_texArray, index);

etc.

In your shader instead of using Texture2D you use Texture2DArray

and

Tex.Sample(ShadowSampler, float3(uv, index))

If you don’t use custom shaders I see no point in using texture arrays

I think you’re overthinking this.

The first thing you should do is try doing it the way you want and see how it goes. 90% of the time (especially when you’re first starting out) the performance bottleneck won’t be where you think it is anyway.

The choice of array you use is rarely going to make much difference. Unless you’re writing performance critical code like say a particle system or physics engine, honestly, don’t worry about it.

I don’t need arrays at all, it just makes the code easier to understand and debug. But I could as easily bang everything on sprite sheets, it just adds code.

Interesting you should mention the particle system. I have written one, but I’m not sure how slick it is. Do you have any handy links to particle examples or tutorials?

Thanks folks.