As I’ve been working lately, I’ve been very aware that seemingly simple things I wanted to have in a new game have huge implications on the difficulty of making a game and engine.
The first thing I wanted to change from the previous game was the ability for the camera to look up toward the horizon. In Banished the camera always looked down, and the higher the camera got, the more the ability to look up was limited.
This was great for performance – it limited the number of objects drawn, and no graphics models needed simpler level of detail (LOD) versions. The terrain was simple. I didn’t have to have a fancy sky drawn, nothing had to be drawn past the mountains at the edge of the map. The drawback was that you couldn’t ever see the whole settlement once it got large. You also couldn’t move around very quickly.
Now with that simple change – looking up, and zooming farther out there’s more work to do. All models need some of LOD to keep the triangle count down and keep highly detailed objects from aliasing in the distance. The terrain now has LOD as well. Having LOD on the terrain makes texturing it and having decals on it harder. And brings in other problems like objects disappearing or floating because the terrain is less detailed in the distance. I also have to draw to the horizon, ocean or mountains, the sky, the sun.
Drawing shadows also takes more time. Instead of a single shadow map based on what’s visible, to draw to the horizon takes multiple shadow maps, various tricks for distant shadows, and more complex pixel shaders. This also increases CPU load as 4 shadow maps are drawn instead of 1.
The renderer also has to change to handle this. While it works just fine, it’s slow. Instead of dealing with say 4000 visible objects in view, my current test scenes are dealing with 40000. So the renderer has to be changed to handle culling away and drawing 10 times the number of objects in the same amount of time as before. Granted GPUs are a bit faster than before, but CPU time hasn’t increased the same way.
After the camera change, the next change I thought wouldn’t be so bad is arbitrary layout of buildings. No grids. Grids were great in Banished because it made lots of things simple. Pathfinding was on a grid, placement of objects was on the grid, everything used the grid.
But I want to see organic layouts. I’d like farmed land to follow terrain and butt up against a river. I’d like buildings and roads to placed in whatever natural way they end up being.
But with the grid gone, lots of things are more complicated. Placing objects now requires checking an arbitrary shape against everything else already placed. This requires a spacial subdivision structure to be fast. It’s also harder to visually convey the overlap and how far you might have to move something to get it to fit.
It also adds a little friction to placing buildings. With a grid, you might place 2 buildings and leave space inbetween for something else – because you know its size. With arbitrary sizes, rotations, and shapes this can get harder, and potentially frustrating. When you do want to line up objects, its not as easy either.
Because things are arbitrary, I’m no longer limited to square regions – players can create any shape for an area – which is great, but makes the user interface more complicated. At the same time it can add friction to the experience because you have to spend time layout out areas if you don’t want the results of a quick click-and-drag.
I’ve been working on making placing arbitrary objects and regions as painless as possible, but it’s challenging.
As I wrote about last month, pathfinding has also gotten more complicated. However with the complexity comes flexibility. I have pathing setup such that characters can always walk between buildings, reducing the chance of getting stuck, and decreasing search time while running the A-Star algorithm. Search time is also decreased due to much more open area.
Thankfully, graphics doesn’t get anymore complicated, it was written to handle things in any orientation from the start.
These two seemingly simple changes have caused my game engine to get slightly more complicated. What is hardest is that there’s even more tiny details than I’ve written about that I keep running up against that were unknowable until I ran into them. I’ve spent more time making the features work than expected.
In the end, these changes are good – even I went back to building a grid based game with limited camera. It’s just surprising to see how far reaching a simple design decision can be.