About optimizations, octrees, etc...

I’m implementing an octree based engine and the lastest days I code a q3bsp loader, but I copy the level geometrý into my own level data format (Not using the bsp structure). Without using the octree, simply rendering all the data using glDrawElements I take about 35fps on TNT2 Duron1000. But when I make the octree the framerate down to 20~fps :(. Basically I store in the octree leafs the geometry that are in each cube. Then, when I have make all the octree, I create an DisplayList for each leaf node. (Into the display list I call glDrawElements also). So when I render the octree I make glCallList() of the visibles nodes. I think that this slow framerate is due to that at first time I have only a few number of meshes and I make less texture changes to render its, but then, using the octree, I have more objects (DisplayLists) and as I don’t sort by texture, I make more texture changed.
Any idea if I’m in correct?
Another idea that I have about rendering octree is to have a list of faces array for each texture for example: KFace *FacesByMaterial[MAX_MATERIALS] and KVertex *ListOfVertex;
Then when I finish to create my octree, I don’t make the display lists for each node. I only wait that call RenderOctree() and I find the visibles nodes and copy their geometry to this faceList, so at the end of the search we have FaceByMaterial fill with the face ID that are currently viewed. And we only must to do:
For NumMaterials
UseMaterial(i)
glDrawElements(FaceByMaterials(i))
but I don’t know y make this one in each frame is too expensive. I tried the both method but I don’t note to much perfomance difference :
(

And finally I want to ask you another thing, If I have an scene with 5 movable objets that have the same material. Firstly you can do:
for (NumObjects)
UpdateMatrix(i)
glDrawElement(Object(i))
to make the transformation T&L. But how much perfomance increased if you make the transformations by software (Using 3DNow aceleration for example) and then copy all the transformed vertices to a commom buffer to all the same textured objtecs and then make:
for (NumMaterials)
UpdateMaterial(i);
glDrawElements(ObjetsbyMaterial[i]);

Thanks to all

I don’t know if this makes sense with your structure, but how about this - go through the octree once for each material and put an if statement before drawing each polygon checking if it’s the current material:

for(num_materials)
{
traverse octree
{
if(current material == material of current polygon)
draw polygon
}
}

This way you don’t have to store an array of faces which have each material (which doesn’t seem like it’s any faster anyway). However, I wonder if the texture switching is really causing such a great speed hit? It doesn’t seem like it should. But don’t ask me.

-Keenan Crane

Hi, the way I structured my octree was to store just the indices of of my geometry in each leaf. That way I can render a leaf with a call to glDrawElements().

Old GLman