times came when i had to implement some culling into my engine. I started by reading some stuff and so far so good. I managed to create an octree which can effectivly divide my geometry's vertices (per mesh) into an octree. But here i have some Questions:
Currently i am using immediate mode to test if the culling works. And it does work, i am recursivly traversing the tree's nodes and testing against the node's bounding box if the frustum intersects with it. Repeat untill leaf is found and render that leaf's geometry (with immediate mode for testing) But now i would like to use VBO/VAO's to render the geometry in the leaves and here i see two options: - 1.Each time the i traverse the tree push the leaves that intersect with the frustrum into a list then get the vertices out of them and construct a VBO and send it to be rendered. - 2.Pre build a VBO for each leaf then just rebind for each visible leaf and render.
Anyway, which is the better option rebuilding a new vbo each time the frustum changes, or just rebinding multiple vbos (which is also expensive). Also is this even the right approach , maybe i am missing something.
bool view_Culling(CFrustum& frusrum, COctree *node)
{
if (!node)
return false;
if (frusrum.CubeInFrustum(node->GetCenter().x, node->GetCenter().y, node- >GetCenter().z,(node->GetWidth()/2.0f)))
{
if (node->IsSubDivided())
{
view_Culling(frusrum, node->OctreeNodes()[TOP_LEFT_FRONT]);
view_Culling(frusrum, node->OctreeNodes()[TOP_LEFT_BACK]);
view_Culling(frusrum, node->OctreeNodes()[TOP_RIGHT_BACK]);
view_Culling(frusrum, node->OctreeNodes()[TOP_RIGHT_FRONT]);
view_Culling(frusrum, node->OctreeNodes()[BOTTOM_LEFT_FRONT]);
view_Culling(frusrum, node->OctreeNodes()[BOTTOM_LEFT_BACK]);
view_Culling(frusrum, node->OctreeNodes()[BOTTOM_RIGHT_BACK]);
view_Culling(frusrum, node->OctreeNodes()[BOTTOM_RIGHT_FRONT]);
}
else
{
//use prebuilded vbo here
//or push these vertices here in a list later build a dynamic vbo
//from them
node->DrawOctree(node);
return true;
}
}
return false;
}