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:
Renderer look in his batch manager if a batch exist for the given element with his Material.
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 to show my problem here: Image
But I've got some problems because objects can be behind another objects inside another batch.
How can I do something like that?
It sounds like you're trying to optimize rendering for two mutually exclusive goals.
One of them has to take priority over the other. Since Z-ordering is critical for proper appearance of transparency you'll likely have to have that take precedence. Once you've done that you're still free to batch up items of the same material within the Z-ordering.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With