-1

I just got stuck with texturing my cubes - i searched web and realized that the only way to give my cube 6 different textures (With glDrawElements) is to create about a 24 indices. It is still faster than just glDrawArrays, but it seems quite illogically and horribly slow. I understand that the purpose of glDrawElements is to deal with complex models where very few indices share different texture coords. But, i am still pretty confused, because glDrawElements gave me perfomance boost (Without any effects, just shader coloring) from about 50-67ms with 10,000 cubes (glDrawArrays), to 25-33ms with 100,000 cubes.

My question is: i just have to accept it, or there is still some way to come over this?

genpfault
  • 51,148
  • 11
  • 85
  • 139
DaSH
  • 75
  • 1
  • 8
  • instead of texturing surface by surface you can try to texture with Cubemap texture something like [that](https://www.evl.uic.edu/aej/525/pics/cubemap-diagram.jpg). – Berke Cagkan Toptas Apr 22 '15 at 17:49
  • Why do you expect `glDrawElements` to be slower? It almost never is, not even when no vertices are shared at all. – derhass Apr 22 '15 at 19:18

1 Answers1

0

I do not know what you want to archieve but you can try to reduce the number ob vertices in the scene. This will make is much more faster. I think if your Cube needs more than one texture, you can store them in a texture atlas ans assign each vertex of the cube the corresponding texture coordinate for the image in the texture atlas. This will reduce the number of texture calls, as there is only one texutre. IN addition you will only need to render the vertices/Triangles which are visible by the user, so you do not need to texture the back of the cube.

I've found a good site which explains a lot of speeding up rendering thousands of cubes. They try to generate one big object on the CPU by culling a lot of vertices before loading them to the GPU, but I think for your problem, you can only try to use as less textures as possible (TextureAtlas), this will increase the performance, but for a whole cube you need the 8 Vertices with each a specific TextureCoordinate.

glethien
  • 2,440
  • 2
  • 26
  • 36