gimp
08-24-2002, 02:54 AM
I've searched the archives on the topic of redundant state changes and found a very cool thread on guarding against redundant state changes.
So, I'v started writing a state sorting system. I query my octree for all 'in view' leaves. Produce a render list and the idea was to sort the list, however I've found no information on what render states should be given priority in my sorter.
I have no idea as to how I might do this dynamically(but it does sound like a forward thinking idea, change state & time it?) so I guess I'll just hard code the order.
Does anyone have a guestimate preference for order of state changes? In include the active lights as states as well, if two entities use the same light it should in theory need no extra changes either.
So my list will start like this sorting states in this order:
1) Enabled lights
2) Texture binding
3) Material
4) Err... This is where I run out of idea's.
My engine is designed so the each 'RenderState' is represented by a small class, like 'Texture' that can be sent to the renderer to set the texture. Some o the classes will have multiple grouped properties, like sending a material change will do this:
glMaterialfv(g_Sides[a_Object.GetSides()], GL_EMISSION, a_Object.GetEmissive());
glMaterialfv(g_Sides[a_Object.GetSides()], GL_AMBIENT, a_Object.GetAmbient());
glMaterialfv(g_Sides[a_Object.GetSides()], GL_DIFFUSE, a_Object.GetDiffuse());
glMaterialfv(g_Sides[a_Object.GetSides()], GL_SPECULAR, a_Object.GetSpecular());
glMaterialf(g_Sides[a_Object.GetSides()], GL_SHININESS, a_Object.GetShininess());
Not sure about how evil that is. I guess I could seperate the states out in to individual classes.
What are your thoughts so far?
So, I'v started writing a state sorting system. I query my octree for all 'in view' leaves. Produce a render list and the idea was to sort the list, however I've found no information on what render states should be given priority in my sorter.
I have no idea as to how I might do this dynamically(but it does sound like a forward thinking idea, change state & time it?) so I guess I'll just hard code the order.
Does anyone have a guestimate preference for order of state changes? In include the active lights as states as well, if two entities use the same light it should in theory need no extra changes either.
So my list will start like this sorting states in this order:
1) Enabled lights
2) Texture binding
3) Material
4) Err... This is where I run out of idea's.
My engine is designed so the each 'RenderState' is represented by a small class, like 'Texture' that can be sent to the renderer to set the texture. Some o the classes will have multiple grouped properties, like sending a material change will do this:
glMaterialfv(g_Sides[a_Object.GetSides()], GL_EMISSION, a_Object.GetEmissive());
glMaterialfv(g_Sides[a_Object.GetSides()], GL_AMBIENT, a_Object.GetAmbient());
glMaterialfv(g_Sides[a_Object.GetSides()], GL_DIFFUSE, a_Object.GetDiffuse());
glMaterialfv(g_Sides[a_Object.GetSides()], GL_SPECULAR, a_Object.GetSpecular());
glMaterialf(g_Sides[a_Object.GetSides()], GL_SHININESS, a_Object.GetShininess());
Not sure about how evil that is. I guess I could seperate the states out in to individual classes.
What are your thoughts so far?