when rendering voxels in octrees, the only information necessary is the current octree-level, -position and colour/texture. But one has to send eight vertices to the rendering pipeline in order to render a complete cube and still needs colour/texture.

Is there a better way?

Since geometry-shaders wont be wide-spread for quite some time the "emit_vertex"-method in the geometry-pass wont suffice (or am i wrong? i don't think mesa currently supports geometry-shaders). Also, afaik, backface-culling is done before the geometry-pass, so that would lead to additional overhead.

My current idea is to send 'dummy vertices' and have the actual drawing data in between but that really shouldn't be the solution.

kind regards

  • \$\begingroup\$ Geometry shader is the better way you're asking for, your best bet might be implementing both and switching at runtime. \$\endgroup\$
    – MickLH
    Commented Mar 25, 2014 at 19:28
  • \$\begingroup\$ "Since geometry-shaders wont be wide-spread for quite some time" - I'm not sure where you're getting that information from, but geometry shaders are widespread now and have been for many years. Unless you're also targetting really low-end Intel integrated stuff they're a viable choice. \$\endgroup\$ Commented Mar 26, 2014 at 8:10

1 Answer 1


Geometry instancing is a good way to solve this. Since all the models you're rendering are identical (cubes), you can provide an "inner" vertex buffer containing the 8 vertices for a single cube, plus an "outer" vertex buffer with just one vertex per cube, containing all the per-cube information. The two buffers will get "multiplied" together during rendering - that is, the vertex shader will run once for each vertex of each cube, and the per-cube information will be replicated to all 8 vertices in that cube.

A similar trick is often used for drawing particle quads, using instancing to provide the 4 vertices per particle, so that the "outer" vertex buffer can have just one vertex per particle.

You can google for more information on how to actually implement geometry instancing in OpenGL, but here is one tutorial.

  • \$\begingroup\$ thank you!after reading further i've settled with passing a triangle strip (14 vertices) in one buffer and the voxel-data in another using glVertexAttribDivisor. \$\endgroup\$
    – yogo1212
    Commented Mar 25, 2014 at 22:18

You must log in to answer this question.

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