Render Queue Question

Started by
2 comments, last by Ingenu 7 years, 11 months ago

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)

Advertisement

Go for deferred shading directly and add a light bucket, that will be much easier.

Otherwise go for the light list, if you plan to go deferred I don't really see the point in wasting my time on the forward proof of concept step, so it will be fine.

-* So many things to do, so little time to spend. *-

Go for deferred shading directly and add a light bucket, that will be much easier.

Otherwise go for the light list, if you plan to go deferred I don't really see the point in wasting my time on the forward proof of concept step, so it will be fine.

I would appreciate it if you could explain your concept, so that I know. I am wanting to support both forward and deferred in the engine.

Thanks

You could write the code in a flexible enough manner so that it would work, just have your light bucket, in the forward case send it to whatever needs to be rendered so it can pick the lights it needs, for the deferred case just render them and compute lighting.

In both cases you'll need to store light information in an array, and probably branch on light type (actually you'd rather have 3 loops for 3 different light types), if you have an array of lights (or 3 arrays, one for each type) you can as well have an array of textures (your shadow buffers, 3 arrays again)...

So I don't really see any difficulty here. Just try to cull as many lights as possible to generate the least amount of shadow buffers (you'll only have a maximum of n of them anyway), to save on processing.

That's pretty much how I made my engine work with any rendering technique I may want to try or fancy, having a plugin rendering process and a list of ordered Step/Groups that change depend on the rendering tech I chose. (Which would be similar to your buckets)

-* So many things to do, so little time to spend. *-

This topic is closed to new replies.

Advertisement