
Since its been a couple of weeks and I'm still not sure when I'll be done with this next update I thought I should give a progress update. As forewarning, this one will be more technical than most in effort to explain why its taking so long.
I wanted to go back to a performance feature I mentioned a while back around occlusion culling, and since there are more animals now it felt like a good time to try it one more time. I've made enough progress now that I'm feeling more hopeful I can deliver on it and if all goes well, it should see about a 25% decrease in overall rendering times.
What I'm working on is sort of like this:
https://tomcc.github.io/2014/08/31/visibility-1.html
How graphics cards work is that they are Much more effecient processing big chunks of data instead of lots of little bits, so to lean into this strength Aiyana utilises something sort of like static batching, which is where once chunks load they look around their neighbours and start combining their meshes into larger versions. So instead of rendering 4 small chunk meshes, they are combined and 1 is rendered instead.
This is already in and works really well, the problem is that when I first attempted to implement occlusion culling, like in that link above, that it means disabling the static batching and the results where almost identical for perfomance. So it felt a bit pointless to trade an already working system for a different system that gives similar results.
So what I'm doing now is mixing the two systems, which is complex to say the least. I'm using my custom static batching for the meshes above ground which will receive almost no benefit from culling anyway. Then for meshes below ground, occlusion culling kicks in and the smaller meshes are disabled depending on what you can see.
It looks like I have a foundation working ok but I still have the time consuming edge cases to work out. What has made me stop and write this post is that the algorithms I use for caves are problematic for the culling algorithm. Too many of them are connected together by tiny tunnels so when I'm trying to detect what should render, too much is passing the checks to say "chunk X can travel and reach chunk Y".
As a result, I'm reworking the caves to find a better balance of nice visuals whilst also not being a drain on performance. Current caves are a bit narrow too often so my aim is to have more open caverns that are easier to explore/fight in.