Best way to sort objects of a scene ?

Started by
1 comment, last by cozzie 9 years, 7 months ago

Hello,

I am creating an OpenGL Renderer class, and I am trying to figure a way to optimize things.

In my scene, there are objects sharing same mesh, objects sharing same shader, objects sharing both and objects sharing textures etc ...

For objects sharing mesh and shader I could use instanced rendering.

But what about the other objects, how do I sort them ? I sort them by buffer, by shader or by texture ?

thanks

Advertisement

Depends...

I am sorting my objects shader 1st then mesh then pipeline state changes (like enable depth/cull/blend and stuff).

In general the benefit from sorting is minimizing api overhead, since most of the objects share the same shader, I figured to sort the objects according to their shader first. geometry changes more often than the pipeline state and so on...

I do not have any proof that this is the best way to do it, but this is the way I am doing it and it works pretty nicley.

Here's something that can get you going on the implementation:
http://www.gamedev.net/topic/659927-sorting-out-the-bits/

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

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

This topic is closed to new replies.

Advertisement