Jump to content
  • Advertisement
Sign in to follow this  
nickyc95

OpenGL Render Queue Question

This topic is 944 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)

 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!