Support 2D array textures (GL_TEXTURE_2D_ARRAY)

As far as I can tell Babylon yet doesn’t expose array textures, although it does use them internally. Array textures different to Texture arrays, confusingly.

I made an attempt to implement it, just to see what would be involved (although I don’t really know what I’m doing), it seems that the implementation would be very similar to 3D textures.

Hello and welcome!

What is your use case?

The use case is that you can pass a texture atlas to your shader and sample from it without artefacts.

I’m making a voxel game and I want to pass a texture atlas (imagine something like this but in the right shape) to my shader so that I can use 1 mesh and 1 material per chunk instead of N meshes and M materials.

Currently I’m using texture arrays but there are significant issues compared to proper array textures, e.g. if I turn on mipmaps I get seaming, and also there are limits on the number of textures. The alternative hack is to use a single 2D non-array texture but this also has issues with artefacts because now there is just 1 sampler and it doesn’t understand the layout of the atlas.

I found another thread here on PBR texture splatting where they discuss using array textures for splatting terrain.

Would you be ok to prepare an PR?

Okay I think I have it working, I will send a PR later.

1 Like

I’ve been trying to implement this as well for some time, without any luck.
I’m pretty good at sharing textures throughout my scenes, but for some projects, it’s just not feasible.

The PR is here btw: Implement 2D Array textures by atg · Pull Request #7001 · BabylonJS/Babylon.js · GitHub

1 Like