Slipped and fell down three steps flat on my face onto concrete at work yesterday. Have smashed up two knees, one ankle and one wrist. Falling over at the age of 40 is a lot less funny than it was at 20.
On a brighter note, I've implemented basic frustrum culling in my game, meaning larger levels are now possible while maintaining efficiency.
If you look at the depth map in the top left corner, you can see the culling going on. The culling for the depth pass is similar, I just ignore the top plane of the frusrum for now. Probably need to come up with a more sophisticated culling strategy for the depth pass at some point.
It was quite straightforward really. I stole some code from the Rastertek tutorials to extract the six planes from the view and projection matrix, then wrote a method to build a local AABB from any of my mesh objects.
I realised it was reasonably efficient to support OBBs instead of AABBs for the culling, so created a Hull class (basically a list of vertices) that can be constructed from an AABB. Each scene node now maintains such a hull, updating it whenever the transform of the node changes.
I can then trivially check to see if all the vertices are in the negative space of one of the frustrum planes and reject the node for rendering if so. I'm aware I could find a support vertex in the direction of the plane normal and just test that, but I'm not convinced that would be more efficient, since identifying this vertex would involve a dot product on each vertex, which is basically the same as testing which side of the plane it is on.
I copied and pasted my level in the editor and moved it over to double the size, realising as I did that the code to draw selections in the editor needs to be made a lot more efficient - barely usable when many object selections are being drawn but perfectly fast drawing the meshes themselves.
The game maintains a steady 60 fps on my mediocre hardware regardless of the view, so seems to be acceptable so far. Will have to see what happens as the levels get larger.
Thanks for stopping by.