Background, Background

Let’s talk a bit about how the terrain system works.

We don’t render the whole world. Indeed, the island is so huge that it would be crushingly overwhelming to show it all. So we show only the area that’s visible on screen. If you’ve seen the streams recently, you’ve seen this view.

Lovely little diorama, ain’t it?

When a server starts up, it generates a map of the world. This map is represented as a grid of subterritories. A subterritory is a distinct area in the world. In terms of what that means to the game, it represents a set of art assets and lighting settings. We have about 35 subterritories so far in Steambirds, of which about 16 are on the main island. The whole thing ends up looking like a giant pancake. In this rendering, we only have truly distinct colors for the 7 major territory types; we have more subdivisions within these (hence the name subterritory) and those have subtler color differences.

Each of those little squares, when rendered, spans a reasonable chunk of the screen. We also rotate everything by 45 degrees relative to the world. This rotation makes things “look cooler”.

This is called a tile. Within each tile, we have four ground meshes, one scatter on top, and up to 16 walls.

The four ground meshes are a part of a tiling system for making seamless shapes. We’re using a particularly efficient system that requires only 4 assets minimum, as compared to the 16 that our old system required. It’s actually not that different – we cover the same 16 cases by programmatically flipping and rotating the assets 4 different ways. 4 * 4 = 16! So instead of having to make 16 assets and then take a long break, we can make 4 and then have extra time for variations on each.

The rounded edges get the artist interpretation, and become cliffs, canyons, and flat ground.

As you’re flying around, we have a little bit of code that pops these tiles into and out of existence based on the camera position. What the camera can see is a distorted rectangle, a shape called the “view frustum” (ha ha, probably the frustrate-um for the folks who have to debug it). We generate a bounding box for each potential tile near the camera, and for those that intersect the view frustum, we create them. So no matter where the camera is, or what size it is, this algorithm will show only the minimum set of tiles that could possibly be seen.

It knows which mesh assets to place where because the server tells it. In addition to laying out the subterritories, the server also assigns the assets to each square. As a player plane flies around the world, the server keeps track of its viewpoint position, and sends tiles in a circle around it, as needed. As soon as the game receives the tiles, it puts them into the minimap in the corner of the screen, so what started as a bandwidth optimization becomes a kind of fog of war.

We do all this layout with these nice meshes, and then we cover everything up with clouds and fog! We’ll have to share what we do for those at some other time…

We hope everyone has a wonderful holiday break!