Since its been a couple of weeks I thought I would drop what is becoming my usual dry/technical updates. The next area of focus for me hitting that draw distance is animals. I had mentioned fish in my last update and I'm still working towards them but the fish use the same animation systems as the animals. That system is one I bought online that allows you to animate purely on the GPU (your graphics card). As a foundation, that tool was great but it does have its drawbacks by trying to be generic. Namely, it spends a lot of rendering time preparing skinning data.
This picture is something called RenderDoc which lets you measure how long it takes to render something. In this case its an older render and it took 28ms, which is too much. The aim is to be under 16ms for 60fps. The highlighted section here is time spent by the GPU doing what you can think of as general calculations, in this case its that tool preparing all the data it needs to animate fish and animals. To be fair to the tool, what it is doing here is incredibly efficient, but bottom line is its too much time. In this case it was 5ms or 30% of the rendering budget for 60fps.
So I'm making my own animation tools that will prepare the skinning data on the CPU. For anyone that has tried this before, I realise this is utterly mad and a Ton of data to process! Normally, attempting this is pretty foolish because of the sheer amount of data to send to the GPU since skinning on the CPU means you need to send data per vertice, per animal, instead of per bone and per animal (which for the less technical this is roughly 1000x more data as a minimum. Sometimes its 10,000x more data depending on how complex your models are). However. In my last update I discovered new-ish techniques for writing to GPU memory directly. So coupling this with the Burst compiler, I'm seeing some promising results that let me completely remove that time spent on the GPU. The tool itself is mostly done and the results are great. However, getting it to work with existing animal logic was going to be extremely messy since Animal AI relies on lots of checks that can only happen on the main thread for things like drawing particles (magical effects) or things like lens flares.
So I've decided that whilst everything is already really broken, now is probably a good time to rewrite animals AI so that it can run properly in a multi threaded way and utilise Burst as well. This is going to take a bit of time but in the long run it means they will take a ton less CPU time (which is now important since skinning will need it) whilst also letting me rewrite some sections to make multiplayer work easier in the future and syncing with the new animation systems is clean/easy since I'm doing everything at the same time. Finally, by reworking animals in this way it should be much more efficient to have more of them in the world at once. My hope is that once this is all done I can spawn more animals and rebalance their drops so its easier to find the things you need from them such as the leather strips.