Update of TextureArrays

Hi fellows,

I noticed that TextureArrays upload all their image data to the GPU at once if they have the isUpdateNeeded flag set. Wouldn’t it be better and more efficient if only the really changed ByteBuffers (= layers) would get uploaded instead?

My problem is that I have a voxel world which consists of a lot of blocks with each of them belonging to a certain block type. Each of these block types uses a different texture of the texture array. Some block types need their texture to be updated on the fly, while others don’t. So everytime one block type updates its texture then all the other texture layers of the TextureArray are getting uploaded to the GPU as well (although they have not changed at all).

While at the moment this is not a problem (because I have just a few block types), this might get a problem when I add more block types to the game.

So basically what I’m asking for is:

  1. is it possible to just upload separate layers of a texture array with OpenGL (I haven’t looked into this yet)
  2. If so, could we add this feature to jme?

IMO it’s not possible. A TextureArray is a single texture unit and I can’t see how you could partially upload it.
However, maybe you need to look into sparse texure arrays.

Use one material and mesh for your static textures and one material and mesh for your dynamic ones.

You could actually update specific slices of a texture array, and even specific sub parts of an array slice, via OpenGL. The Renderer.modifyTexture() method in jME3 is designed to modify only 2D textures at the moment though.

I already considered this option, but it doesn’t solve my problem because the game engine does not know in advance which textures will be changed dynamically (this is defined in a user moddable javascript file).

Okay. That’s something I can start with. I will try to make the appropriate changes to the JME and send you guys a pull request via github if I succeed.