Hi everyone!
I'm currently reworking my culling strategy and I came to a point where I just don't really know of what to do from here.
My current project is to improve the renderer of an older game (Open-World RPG) and it's working very nice so far, just not as fast as it could.
(Using D3D11, C++, if that matters)
This game basically has a static world-mesh and objects stored in a BSP-Tree, so I already have that. The BSP-Tree itself is created around the world-mesh and breaks the world down into little about 5 meter-AABBs of ingame space, which then contain a list of the objects resisting in that leaf.
Also bigger objects may are registered in multiple leafs as all of them are roughly the same size.
That leads me to following approach:
- Walk the BSP-Tree and check visibility to cut of branches
- If gotten to a leaf, iterate over the objects in all lists (Outdoor, Indoor, Small, etc)
- Check a flag if an object has been drawn before (Big-Object issue) and register it in the renderer
- After that, copy all instance-IDs to the GPU, where I remap that ID to a static World-Matrix-List in a structured buffer.
If I initialize everything only once, putting every object into the renderlist, then I can draw my whole world at about 200fps, which is nice. If I enable the culling I am down to ~100fps while not even drawing 1/4 of them.
Using profiling, I have found out that most of the time is spent in the function that iterates through the objectlists of a BSP-Leaf.
It basically only does this, like 5 times for the different lists:
if(nodeDistance < vobOutdoorDist)
{
for(auto it = node->Vobs.begin(); it != node->Vobs.end(); it++)
{
GVobObject* vob = (*it);
if(!vob->IsAlreadyCollectedFromTree())
{
// Just draw
vob->DrawVob();
vob->SetCollectedFromTreeSearch();
BspDrawnVobs.push_back(vob);
}
}
}
Internally the "DrawVob"-Method only pushes an indexvalue to an std::vector after the first time it has been called. It is still slow when I remove the code inside it completely.
It would be great if someone could tell me how this kind of scene is usually handled efficiently. By the way, it is still slower, even if I completely remove every code in the "DrawVob"-Method, so it's nothing in there causing the slowdown.