I'm working on a 3D map that is cut as a simple grid of textures. The idea is to draw only one object with all those textures, instead of having a tile object for each of them. Correct me if I'm wrong, but only one big call is preferable to many small calls in terms of speed. Considering that textures loaded and shown are based on the camera view, ideally, it's not such a huge call.

Problem though, I need to put the corresponding textures altogether in a single Texture2D object I can pass to the shader. So I was thinking of having a rendertarget to create this Texture2D, but this beats the purpose of having only one draw call.

So basicaly, what I thought about is to load each texture, get their data and copy all of them in a new ordered Texture2D I can then pass to the object. Only thing is I have no idea on how to do that.

Any sample or suggestions on the matter? Or maybe someone tell me this is terribly wrong.

Thank you!


1 Answer 1


What you're talking about is called a "texture atlas". The simplest way to do it is to create a static, precomputed atlas, containing all the textures in your whole game world. Each tile would have UVs set up to point to wherever its texture is in the atlas. It's a quite common technique to allow combining draw calls together.

The idea you had of a dynamic atlas - using a render target to build an atlas of just the textures to be used in the current frame - is workable, but overkill unless you have a really enormous number of textures, so that you can't possibly fit them all into a static atlas. This is a bit like a megatexture system, although there the emphasis is on streaming data from the hard drive into memory while the game is running, because the texture data for a level is too large to fit all in memory at once.

  • \$\begingroup\$ true, I didn't think of presenting it as a dynamic atlas, as it is indeed. As you point it out, the render target is pretty much over kill, but as a fact, the number of textures is enormous (several thousands). So yeah, the point is I can't litteraly load all the data into memory, so I need to stream from hard drive the required data and show it on screen with as few draws as possible. I'll check if the render target is really viable in realtime, I need around 500 textures updated when the camera moves. Is it more optimized to go through d2d calls to create this target? \$\endgroup\$
    – Tuxic
    Jun 14, 2013 at 7:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .