OK, so I am currently creating OpenGL renderer for my own engine. I asked a while ago about render queues, where I go some really good information.
I went away and wrote a system that sorts the draw calls into "Render Buckets" and goes as follows:
Clear the Render Buckets
Loop through the entities, check if they are visible within the frustum.
- If its visible, check if a bucket exists with the same shaderID and render flags (alpha blended etc..). If it exists add the renderable to that bucket. If not, create the bucket and add the renderable.
- If its not visible, cull it (dont add it to the list)
When it comes to rendering, I loop over the buckets; get the shader and draw the renderables that are in that bucket (using that shader and the flags that are set for the bucket e.g. alpha blending).
This system works well, however I am now trying to add lighting and I am finding it difficult to architect it in a way that fits in with this bucketed render system.
I am trying to implement a Forward rendering path, which either needs to loop over the lights and draw the bucket for each light, or have a single shader that accepts a list of light (however I have been told this will make it more difficult to implement shadows later on).
(I am going to implement deferred later on after getting forward working)
How should I go about this?
Thanks
(Currently using C++ & OpenGL 3.3)