# Octree Frustrum Culling

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;
}

• Well the approach makes sense if you're looking for a scene-bound culling algo. All the nodes in the octree that lie inside the frustum can be rendered, i.e.you're using a dynamic potential visibility set (or dPVS). Potential problems can be incorrect shadows and other issues with behind-the-camera partial geometry, e.g. if the geometry is not split at the splitting planes of the octree. As for the VBO strategy and assuming you are rendering static scenes, rotating a set of VBO's using prebuild buffers seems the most feasible - or you can build the commandbuffer yourself. – StarShine Aug 27 '15 at 14:27
• What structure should i use to store the bounding boxes of the objects . I assume i can group the boxes in huge chunks and test against that and discard the entire chunk if not visible . But how would one build that structure ? – user2742982 Aug 28 '15 at 9:44
• Try to search for Loose Otrees by Tatcher Ulrich. It will give you some pointers to build octrees for culling purposes that are actually useful. In terms of pure rendering performance, you can find other algorithms, usually image-based, that spare you all the work of keeping that octree up to date. – StarShine Aug 28 '15 at 10:35
• Actually i have an octree class built already and it works pretty well , currently it takes a list of vertices for a given object and builds an octree based on that. Then i can perfrom culling. My idea is to use higher level test based not on chunks of vertices but rather chunks of entire objects. And what i cant understand is how would i fit the model's AABB into the tree. Should the nodes contain objects or only the leaves etc.. For example where will a terrain's AABB fit in the tree if there are much smaller objects than it ? – user2742982 Aug 28 '15 at 11:17