RawTexture2DArray and Procedural Textures

So I was looking into storing multiple images in a 2d texture array awhile back for the use case of a compressed spritesheet.. Lo and behold compressed textures in rawtexture2darray aren’t supported yet and I started another thread about it here:

If you’re okay with doing some preprocessing with your images, this might be helpful. I ended up using basis encoding with a node script. Basis supported 2d texture arrays so it ends up with one file (one network call) to fetch all the images. There is a binary wrapper in Node with npx basisu. Here is the script I use to create atlases:

And here is a lot of the work tied together to combine loading basis files in runtime and either completely decompressing to flat RGBA (worst case scenario) or using the available compression based on engine caps and uploading compressed textures to the GPU. Then you can upload as a sampler2DArray and do your work in the shader. There’s a lot more going on in this PG but I hoisted all the relevant code to the top, lmk if this is something that might fit your case.

1 Like