<p>I try to render extreme large landscapes, which are deformed by height-maps. Each area has several level of detail height-maps. Other textures are structured like the height-maps as well, so that all textures together are way more than 4GB. I wrote a texture class, which loads textures which are needed to GPU and remove them again, when they are not used several frames. With this technique the GPU Memory is not full.</p>
<p>Now each landscape patch is rendered by its own draw-call, where the correct texture is loaded first.
But each patch has the same geometry, so I thought, that an instanced rendering would push my FPS due to not having so many draw calls each frame (GPU activity is at around 20% by 10 FPS).
To do so, I need to load a lot of textures to my shader but <code>GL_TEXTUREi</code> is limited to 32.</p>
<p>My idea is to use texture 2D arrays, so I can hold several textures in one <code>GL_TEXTUREi</code> slot. This also simplifies my shader code...</p>
<p>Now I can see two solutions,</p>
<p>first: store neighboring patches (patch clusters) to one texture 2D array. I would not like to do so, because a patch holds several textures, and only the needed textures should be loaded (most of the time I don't need the neighboring textures). This solution slows down my program due to loading high amounts of textures from CPU to GPU. It also fills my GPU memory without any need.</p>
<p>second: On the fly combining several textures to one texture 2D array every few frames. So loading the textures is working fine, the only thing I need to do would be to combine them to an array.</p>
<p>So the big question:
Is it possible to combine textures (same format, same amount of channels, same resolution ...) to an array, without copying the pixels? Like having a buffer holding the texture-IDs to define an array. Is this possible? Or is there something similar I can use?</p>

CC BY-SA 4.0
2022-02-10T08:27:36.717Z
I don't want to loose the sampler (LINEAR filtering) possibilities
Thomas
CC BY-SA 4.0
2022-02-10T14:23:52.247Z
"*but GL_TEXTUREi is limited to 32*" [No, it isn't.](https://stackoverflow.com/a/46428637/734069) Granted, it's still subject to limitations that make this non-functional for your use case, but that statement is still incorrect.
Nicol Bolas
CC BY-SA 4.0
2022-02-10T14:30:56.453Z
ohh you're right... it is limited to 196 on my machine... but is it possible to combine several textures to one texture array without copying them`?
Thomas
CC BY-SA 4.0
2022-02-10T14:32:46.997Z
and yes, it is unpractical as well...
Thomas
<opengl><texture>
OpenGL: storing several textures to texture2dArray and exchange them continuesly
Thomas
# OpenGL: storing several textures to texture2dArray and exchange them continuesly

(Asked by: username_0 on 2022-02-10)

I try to render extreme large landscapes, which are deformed by height-maps. Each area has several level of detail height-maps. Other textures are structured like the height-maps as well, so that all textures together are way more than 4GB. I wrote a texture class, which loads textures which are needed to GPU and remove them again, when they are not used several frames. With this technique the GPU Memory is not full.

Now each landscape patch is rendered by its own draw-call, where the correct texture is loaded first.
But each patch has the same geometry, so I thought, that an instanced rendering would push my FPS due to not having so many draw calls each frame (GPU activity is at around 20% by 10 FPS).
To do so, I need to load a lot of textures to my shader but `GL_TEXTUREi` is limited to 32.

My idea is to use texture 2D arrays, so I can hold several textures in one `GL_TEXTUREi` slot. This also simplifies my shader code...

Now I can see two solutions,

first: store neighboring patches (patch clusters) to one texture 2D array. I would not like to do so, because a patch holds several textures, and only the needed textures should be loaded (most of the time I don't need the neighboring textures). This solution slows down my program due to loading high amounts of textures from CPU to GPU. It also fills my GPU memory without any need.

second: On the fly combining several textures to one texture 2D array every few frames. So loading the textures is working fine, the only thing I need to do would be to combine them to an array.

So the big question:
Is it possible to combine textures (same format, same amount of channels, same resolution ...) to an array, without copying the pixels? Like having a buffer holding the texture-IDs to define an array. Is this possible? Or is there something similar I can use?

**Tags:** opengl, texture

> **Comments:**
> **username_0**: I don't want to loose the sampler (LINEAR filtering) possibilities  
> **username_1**: "*but GL_TEXTUREi is limited to 32*" [No, it isn't.](https://stackoverflow.com/a/46428637/734069) Granted, it's still subject to limitations that make this non-functional for your use case, but that statement is still incorrect.  
> **username_0**: ohh you're right... it is limited to 196 on my machine... but is it possible to combine several textures to one texture array without copying them`?  
> **username_0**: and yes, it is unpractical as well...  

---

## 0 answers

