3
\$\begingroup\$

I'm looking for a fast way to draw simple 3D geometries - that will consist of up to 10 vertices. Each of them will have a texture (though varying between geometries). I also want to store the fragment depth for depth testing.

There will be no lighting and only very simple transformations (this actually is for isometric game).

So far what I did was trying to achieve top performance using OpenGL for drawing simple quads (what the problem actually boils down to). For my machine (from around 2008), I had the following results:

  • Using immediate mode 4800 quads took 120ms
  • Using vertex arrays and VBOs this took around 40 ms

What I see as a problem is the bottleneck of glDraw* calls. I want to somehow get below 4-5 ms , as there will be really a lot of objects on the screen. Any ideas about how could (or perhaps couldn't) achieve that?

\$\endgroup\$
4
  • 1
    \$\begingroup\$ group them into a single VBO and draw once \$\endgroup\$ Dec 14, 2015 at 11:22
  • \$\begingroup\$ @ratchet freak These are dynamic objects, so that's probably not possible. \$\endgroup\$
    – luke1985
    Dec 14, 2015 at 11:25
  • \$\begingroup\$ sure it is. you just need a decent allocator strategy and glMultiDraw* \$\endgroup\$ Dec 14, 2015 at 11:28
  • \$\begingroup\$ @ratchetfreak But then how would I pass my uniforms to shader per single object? \$\endgroup\$
    – luke1985
    Dec 14, 2015 at 11:41

1 Answer 1

3
\$\begingroup\$

I suggest you create a huge array in cpu side that will be linked with a vertex buffer in the gpu side.

At each frame you fill that array with the vertices coming from all your meshes. So you'll be able to batch a certain amount of draw calls.

The trick is to sort your objects, first by shader, then by z it by texture, depending if you have transparent objects.

In order to change your textures at the right moment, you'll have to use a stack of objects containing the number of vertices to draw and the common material parameters for these vertices.

Even best if you can interleave vertices position with uvs in the huge array.

Hope this helps.

\$\endgroup\$

You must log in to answer this question.

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