My shader need a texture2darray but I don’t know how to construct a valid object. Though texture class in panda3d provides setup2dTextureArray(), I have no thought how to fill the data.
TexturePool class has a load2dTextureArray method, but I want to create it using existing texture in memory, instead of in disk.
I have tried concatenating texture datas as following:
a_textures_array = Texture() a_textures_array.setup2dTextureArray(750, 750, texture_amount, Texture.T_float, Texture.F_rgba) # 750, 750 is the pixel amount of the textures I intend to use ptr = a_textures_array.modifyRamImage() size = 786465 # bytes for n, texture in enumerate(list_of_textures): # This list contains several textures ptr.setSubdata(n * size, size, texture.getRamImage().getData()) ptr.clear()
However, running this code would get a error, which comes from function graphicsEngine.renderFrame, saying AssertionError: image_ptr >= orig_image_ptr && image_ptr + view_size <= orig_image_ptr + tex->get_ram_mipmap_image_size(n).
And I found texture2darray object has a strange size as 33 when texture_amount == 0 and 9000033 when texture_amount == 1, while a single texture occupy 786465 bytes.
There is another topic with the same question, but it has not been properly answered:
So I am asking again for a solution. Any help would be greatly appreciated.