I'm working on a game in a 3D world with 2D sprites only (like Don't Starve game). (OpenGL ES2 with C++)
Currently, I'm ordering elements back to front before drawing them without batch (so 1 element = 1 drawcall). I would like to implement batching in my framework to decrease draw calls.
Here is what I've got for the moment:
- Order all elements of my scene back to front.
- Send order list of elements to the Renderer.
Renderer look in his batch manager if a batch exist for the given element with his Material.
- Batch didn't exist: create a new one.
- Batch exist for element with this Material: Add sprite to the batch.
Compute big mesh with all sprite for each batch (1 material type = 1 batch).
When all batches are ok, the batch manager compute draw commands for the renderer.
Renderer process draw commands (bind shader, bind textures, bind buffers, draw element)
Image with my problem here:
But I've got some problems because objects can be behind another objects inside another batch.
How can I do something like that?