OpenGL dynamic Vertex color attributes and Texture Coords.

Okey guys… I really have a problem…
Consider a blocky world. That world is 2D, and there is lighting.

That lighting is applied as vertex-color attributes. That way I archieve nice-looking interpolated lighting.
The problem with this is following:

I use Immediate mode.
Problem with other modes are:

  • VBO: I don’t want to create a new Mesh for every 40963232*2 block…
  • One VBO: Impossible… I need to have 16*4 different Texture coords…
  • 16 VBO’s: Impossible too, I need to have dynamic lighting… that means, I need to have non-predictable, 10.000+ different light values for each corner of the sprite/quad.
  • VAO: Slower… maybe due to very much dynamic traffic with the FloatBuffer?

Have you got any ideas?

Currently:

  • the vertices are dynamic for every block, to avoid matrix calculations.
  • the texture coords are dynamic, due to Packed “Sprite batches”.
  • the colors are dynamic, due to lighting…

That means, currently EVERYTHING is dynamic.

I think point 1 (vertices) and 2 (texture coords) can be avoided, enabling Matrix transformations, and creating 16 different VBO’s/whatever for every sprite in the sprite-sheet/batch.

But colors are tricky… can you help me? have you got any Ideas???

Use simple vertex arrays (like LibGDX’s SpriteBatch). My sprite batch looks like this (its very messy at the moment but it will give you an idea).
http://www.java-gaming.org/?action=pastebin&id=93

For better performance you could look into mapped VBOs. And if it’s supported in the driver you should look into instancing (unfortunately not supported on my system…).