scene graph render order

Started by
5 comments, last by Wh0p 9 years, 3 months ago

Hi, like the topic states I am currently tweaking the rendering order of my scene graph.

After VFC and occlusion culling happened i'd sorted the rendering lists by the objects state changes like

1. Pipeline state (enabling/disabling depth test, blending etc)

2. gl program

3. VBO

4. Material

I've never done a huge scene with lots and lots of different objects and I'm just wondering, if the priorities are set correctly. In this case similar materials might be sorted into seperate batches because their gl programs differ... however I thought the register cache will be flushed anyway when the gl program binding changes, won't it? I am kind of walking alone in the dark regarding what properties to cache first when rendering the objects.

Looking forward to your responses!

Advertisement
Hi.
It might be that you're confusing 2 things:
- scene graph: hierarchical view of the scene, for correctly updating parent/ child transforms and their relationships
- renderqueue: ordering stuff around to render it all with minimal state, shader etc. changing

On the 2nd topic you might consider creating a bitkey for each "renderable", so you can easily sort an index on top of it, and render everything you want in any needed order.

More on this here: http://www.gamedev.net/topic/659607-sorting-a-bucket/

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

As few state changes as possible is best regardless of the operation. Loading a shader is going to be the worst because it has to copy the shader executable to each processor and if that is 50 lines of code it will thrash back and forth loading shader programs, rather than other calls that just change pointers to memory locations.

The final sub sort to apply to each of those prior sorts, would be the objects position. Render closer objects first so that you don't draw the same pixel and then paint another pixel on top of the one you just drew (overdraw).

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

A scene graph has nothing to do with the orders in which objects are drawn.
Scene Graphs

See cozzie’s topic and/or search for “render queue” for information on sorting objects for best drawing order.

In regards to which states/properties to apply at a higher priority, typically as dpadam450 mentions shaders are the highest priority, followed by textures, vertex buffers, and index buffers.
But these priorities change depending on the hardware, especially so in OpenGL. You can’t make a single sort key that works best on all graphics cards/OpenGL driver versions, so your best bet is to simply benchmark each variation for yourself and just use your own results.


Also note that sorting is slower than not sorting if not done correctly. If you don’t use the correct sorting algorithm and also take advantage of temporal coherence you will not likely see any gains, and may possibly see slow-down.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Thanks! This is very appreciated.

I guess I expressed myself not quite accuratly by mentioning the term scene graph (I know what this is and only mentioned it because I'm calculating buckets for my objects while traversing and updating) I just wondered about the priorities...

@L. Spiro: Are there any further sources you can recommend on how to exploit the temporal coherence? That sounded very promising and interesting to try out.

The only detailed explanation of which I am aware is this.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Nice, that's sufficient for a start. I guess I can be creative on this one - like doing things in parallel.

This topic is closed to new replies.

Advertisement