1
\$\begingroup\$

I'am currently developing text rendering & some kind of tile based texturing for simple landscape with textures blending. e.g. something like this but in 3D.

In first realization I have been used 2D texture arrays to achieve problem of texture switching to be able to draw whole landscape mesh at one opengl draw call and it works great, but this should run on opengl es 2.0 devices and they are don't have 2 texture array support. So my question is - what can I do to deal with that kind of problem?


Of course i can just draw every landscape quad separately, but I'm pretty much sure, that this solution will really, really heart the performance. (mb i wrong?)

Also i know about texture atlases, but can I guarantee that I can put all possible textures into fragment shader for every possible tiles combination?(terrain tiles for landscape & every possible text chars with different sizes, I think you get the point) I almost sure that i can't, that's basically why I'm asking this question here.

Sorry for my horrible english, I'm working on that.

\$\endgroup\$
1
\$\begingroup\$

The first thing you should do is to just get something on the screen and have it render a landscape. If that means rendering every landscape quad in a separate draw call then so be it.

Next, determine how slow it is exactly. Scale your landscape to the size you will most likely want in your game, for example 1000 x 1000 quads.

Now you can start looking for optimizations. Do you need to render the entire landscape or only the portion visible to the player? If not, try using frustum culling to only render the tiles that are actually visible.

If it's still too slow after frustum culling, then and only then can you start thinking about using a texture atlas. Determine the maximum texture size your target devices support, for example 4096 x 4096 pixels. You can use a tool like Texture Packer to create your texture atlas.

Group the terrain textures and try to make them fit in that space. Maybe the grass texture needs lots of detail, while the snow texture doesn't need much at all. In that case, you could make the grass texture 1024 x 1024 and the snow texture 128 x 128.

Play with different sizes until you have a good trade-off between the size of the atlas and the rendering speed.

\$\endgroup\$
  • \$\begingroup\$ I already done with just get something on the screen, the problem is that, if i switch to separate draw calls, i have pretty much bad performance when i draw even 1 plane with, lats say 5000 quads. And i would probably have more then this one plain, and "texturing" will be done throw the tiny helper application, so i can't really now what combination i can have and so on. And i already done some simple culling, the question is not really about that, but thank you VERY MUCH anyway. I will try somehow your solution about balancing sizes to get good trade-off. \$\endgroup\$ – user22320 Jul 4 '13 at 14:34
  • \$\begingroup\$ Actually, even if your answer is not direct answer to my question i will accept it since i just thought that i don't know something and going to the wrong direction. Now i think that i know pretty mutch all i need and just need to think about whole problem again write lot of tests to achieve acceptable performance. \$\endgroup\$ – user22320 Jul 4 '13 at 14:46
  • \$\begingroup\$ You can pack textures at runtime. You just have to load the files into CPU buffers, run a box packing algorithm, then upload the result as a single texture to the GPU. Doing it offline is better usually, but if you can't for whatever reason, do it at runtime. \$\endgroup\$ – Sean Middleditch Jul 4 '13 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy