Terrain is the shape of the ground in a game world.
How terrain is made
Terrain can be generated by hand, generated using algorithms, copied from existing real terrain, or made using a combination of these methods.
Hand-crafted worlds are the most creative. It takes a lot of work to hand-craft terrain, making large-scale hand-crafted worlds impossible. Most recent game worlds are hand-crafted, which is why their worlds are relatively small. Most game engines include terrain-crafting tools.
Algorithmic creation, better known as "procedural generation", uses software to generate random landscapes based on a set of rules. Procedurally-generated worlds can be vast, but it's hard to make them realistic, and new places tend to be predictable.
Finally, a world can be generated by mimicking an existing world. NASA's Shuttle Radar Topography Mission
(SRTM) project provides
90-meter elevation resolution of most of Earth's surface, and the USGS provides the National Elevation Dataset
(NED) for the US with 10-meter resolution. The data available includes elevation, ground cover, forest height, imagery, and more. There are similar (but less detailed) data sources for the moon and some other planets.
The technical side of terrain
Terrain is usually treated differently from other shapes and objects in the game. For speed optimization, it's unique and limited, because it's technically challenging to display enough terrain distance to reach a realistic horizon. Games commonly hide that limitation using these methods:
- Atmospheric "fog" that gets thicker in the distance, limiting the view distance.
- A "cutoff" where the terrain simply stops displaying, resulting in visually incomplete shapes.
- Terrain that encloses the player in a valley, with rising sides surrounding them, limiting view distance.
- Level of Detail (LOD) that turns distant terrain into a 2D "billboard" that's much faster to display to the player, and similar techniques.
In the real world, distance to the horizon depends on a viewer's elevation and atmospheric effects. At higher elevations, one can potentially see farther. Wikipedia calculates
that the distance to the horizon varies from 5 km (3.1 mi) at standing height, to 111km (69 mi) at 800 meters (2600 feet). Another article
estimates that in ideal conditions one could see 750 km (466 mi). More reasonable typical distances seem to be 15-100 km (10-60 miles).
Most games support a much shorter view distance for performance reasons. First Earth will use Unity3D's
default terrain system, in combination with atmospheric effects, to achieve a realistic-feeling view distance, though it may not reach the realistic hundreds of kilometers on most computers.
Another common limitation of game engines is terrains that are based on height maps. Heightmaps are an efficient way of handling terrain; a heightmap is a simple grid (array) of numbers describing the height of the terrain at each point. If the terrain is 1-meter resolution, the heightmap would have one number for each meter length. A 5x5 heightmap of a hill would look sort of like this:
4 5 6 6 5
4 4 5 4 4
3 4 5 4 4
3 3 4 3 2
2 3 3 2 2
Heightmaps' limitation is that they can't represent overlapping terrain, such as overhangs, sheer cliffs, or in particular, caves.
First Earth's terrain
Actual earth terrain data is being imported into First Earth's engine as the setting for the game. The starting place will have an area of more than 10,000 square kilometers, to be expanded to fill a continent as the game budget grows. The real-world location of the starting place remains a mystery for explorers to solve.
The data is imported from actual earth terrain data by an Erlang script that parses raw binary terrain data into 1000x1000 meter squares of 33KB each, then inserts each data point into a MongoDB
MongoDB was selected very carefully because of its suitability for this purpose, over any other storage option. (The second-best choice would have been Riak
, which is also an amazing piece of technology.) In MongoDB, the terrain data is distributed evenly across a cluster of MongoDB servers, so that the database can scale linearly with load. Because MongoDB is a document database, there is extra storage overhead. On top of that, everything must be indexed for fast access. In the end, each 10,000 square km (100 kilometers square) of terrain requires 16GB of storage space.
When Proxima (the game server) receives a successful player login from the game client, Proxima queries MongoDB for several terrain chunks (1000 meter, 33KB) surrounding the player. It receives that instantly, then streams it in binary to the Unity3D client, which parses it, loads blank terrains into the game, then applies the height data to the terrains. The player is now surrounded by terrain!
Minecraft, Dungeon Siege, and voxelsMinecraft
is a super-innovative game, and one aspect of that is its voxel-based world, where the whole world consists of large blocks that can be arranged in any shape. There are a number of famous games that use voxels
, like Delta Force. Voxels are the next step in innovative game world terrains.
Here's a wonderful article about Dungeon Siege's continuous world