Hey everyone,
I've been studying OpenGL/Graphics for a short while now and I'm in the process of working on a simple rendering pipeline for my (basic) game engine. From what I understand (and please correct me if my understanding is not entirely accurate), the high level overview of a simple rendering pipeline might look like this:
- Add all non-transparent objects to a queue, and sort them front to back based on their distance from the camera (as fragments are discarded if they fail the depth test).
- Or instead do some sorting based on which shader and textures various objects use to minimize OpenGL state changes. (I'm not entirely sure which sorting method to use for the best performance but this isn't the main issue here).
- Add transparent objects to a 2nd queue, and sort them back to front based on their distance from the camera (so the proper effects show up on screen as a result of the transparency).
- Cull any objects (as they are added to the queues) that won't be seen anyway so there aren't any wasted draw calls. (As far as I know, primitives are discarded if they aren't within screen space anyways but at that point you've already spent some processing time calling draw and running the vertex shader so it ends up being worth it).
- Render all of the non-transparent objects in the queue, and then render all of the transparent objects in the other queue.
I understand there are some issues with drawing transparent objects, and that's what's led me to post this today. My question is as follows:
- How do you handle rendering multiple particle systems that are working with different textures? It seems like a clean (object oriented) solution to have one particle system responsible for a single type of particle, but then sorting the particles properly becomes a problem when you introduce multiple particle systems. If you had every single particle in one container, then it seems like you have even more problems because different particle systems may have different data requirements.
I'm sure there's a simple and elegant solution here that I can't see due to my lack of experience with graphics programming. Any ideas/suggestions?