Hi everybody,
As im writing a Renderer in OpenGL i stumble across the follwoing problem.
According to the following Article below i would like to optimize my scene by Sate Sorting:
http://ati.amd.com/developer/gdc/PerformanceTuning.pdfExample:
Lets consider objects as pairs of (material, geometry) with a given position.
Then a list of these pairs.
So i first sort my objects in terms of material (that is shader, texture a.s.o) then i sort in terms of VBO-Data (Geometry). Afterwards i have a list like f.E.:
metal torso at position 1
metal torso at posiiton 2
metal arm at ...
flesh head at ...
flesh hand at ...
now i in the renderloop i could just render the scene.
but then, at every position where i want to render a metal torso pair in code it would look like (pseudocode):
glenable(metal)
render torso at pos 1
gldisable(metal)
glenable(metal)
render torso at pos 2
gldisable(metal)
but wouldnt it be better to have code look like:
glenable(metal)
render torso at pos1
render torso at pos2
gldisable(metal)
i hope you see what i mean.
do you think there is much performance-loss if i disable a gl-State and enable the same state one call later?
or do i have to split-up the rendering for my 3D Objects to get the code like in the second example.
I coded something that achieved a glcommandstream like in the second example, tha looks ugly.
Im trying to get all my things into a resonable object-oriented structure. So my 3D Objects (Material,Geometry - Pairs) are LeafNodes in a Transfroms-Scene-Graph. And those objects now have this split rendering.
For other leanodes like Lights f.E. this doesnt make sense.
Maybe you can tell how you achieve something like this. What kind of structure you use to get sorted data for maximum performance in your 3dapps.
Greetings
Mnemon