Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

1 Introduction

Computer games, depending on their genre, can include numerous terrains with different properties and details. Some areas are represented schematically, while others are created with great level of detail, showing even the smallest elements.

Terrain designed for usage in computer games must posses series of different properties as well as allow easy introduction of various changes. Those concern not only terrain shape but also other game elements connected to them such as: story, quests, placement of objects, enemies and other constituents. Because of those requirements most of maps are modelled by hand, usually requiring considerable amount of time to create. Procedural content generation in it most common form is rarely used in those applications, because of low level of control over created content, as well as many difficulties with further edition of obtained objects. However it may provide interesting results.

While considering different terrains and arrangement of occurring elements, it is possible to notice that most of them can be divided by similar features and inclusive properties. Parts that contain distinctive similarities (considering that they are smaller and content inside them is mostly uniform) are much easier to generate and combine. It is also easier to decide precise set of constraints for single tile. That leads to the idea of generating 3D terrain using image processing approach based on simplified 2D maps.

While this concept is not new, existing methods still have a few drawbacks. They allow for creation of suitable and complex terrains, but their final product lacks the capability for further terrain adjustments. Usually procedure allows introducing modifications either by editing input maps (which greatly decreases level of control over final shape of generated object) or requires conversion of generated terrain to 3D modelling environment (where results of such actions are not always satisfactory and often hard to predict). Another issue is complexity of obtained terrain, which not always meets computer games requirements.

In our approach we propose a method for creating 3D terrains by processing set of simplified maps. This allows for fast and precise generation, easy adjustment and regeneration of both entire terrain and its individual parts. As a test platform for our algorithm we chose Blender 2.73a application (for Blender documentation see [19]).

The rest of the paper is organized as follows. In Sect. 2 we review other works related to our area of research. Section 3 describes initial assumptions for our method. Section 4 contains procedure overview. Section 5 outlines some areas of future work. Finally we conclude our work in Sect. 6.

2 Related Work

Procedural generation for computer games is not a new topic similarly to generating terrain by processing 2D maps or other simplified input. Among existing algorithms some focus only on generating 2D maps from their more basic versions [6], while other generate complex terrains, containing various data and details [17, 18]

One of many problems described in some of the existing works is building entire worlds in real time (which is not an easy case, considering amount of data that needs to be processed) [2]. Other interesting area of research is creating objects from input given by the users in form of pre-processed objects [5]. Some works focus on increasing level of control over generated output by defining terrain with various constraints and parameters such as set of actions that will be performed at generated map [4] or by restricting some of its properties to better fit desired results [13].

Simple and complex algorithms proposed for creation of various virtual worlds, range from basic methods [7] to entire frameworks and methodologies [11, 16]. Among the interesting issues is representation of real world data through sets of height maps [10].

When it comes to generation itself, there are many different ways to realize it. Some solutions use sets of height maps to create complex objects [12], others introduce genetic algorithms, evolving terrain according to user preferences [8], or focus on efficient introduction of various changes to created map(i.e. adding roads) [9].

There are many methods for generation of objects and terrains. For detailed study of procedural content generation algorithms see [1, 3, 14, 15].

3 Initial Assumptions

In this section we present assumptions that led to design of our algorithm in its current form.

While planning our procedure, we assumed that generated terrain must meet certain constraints and have a few significant properties, if it is to be used in computer games.

Most important features concern terrain itself. We assumed that any area must allow for introducing various changes, both during algorithm operations and after it terminates its work. At the same time, any created object should be as close to desired output as possible, providing high level of control over terrain properties.

Another crucial issue is generation process. Designing and modelling of complex 3D objects takes considerable amount of time. We decided to use image processing and base our procedure on 2D maps to simplify the process. In our approach each pixel represents different region inside generated object. Since terrain tiles contain different data, that would be difficult to represent on single image, also increasing its complexity. We decided to use set of maps, where each file contains different information. Currently we consider three type of maps: height map (containing information about basic terrain level, represented in greyscale colour value), dispersion map (describing dispersion range for height value in single region, stored in text file) and terrain map (showing different terrains distribution through the scene, represented as RGB colour value). Each map is independent from others therefore performing changes to one of them does not require updating others (for example, if we want to slightly adjust dispersion range, we don’t need to change terrain level or type).

While creating 2D images is easier than modelling 3D environment, very complex maps can still take a lot of time to finish, especially if we consider large maps with great level of detail. Since each terrain can be divided into patches containing elements of the same type (like mountains, plains, forests etc.) we decided to simplify that input as much as possible. Such patches are represented by pixels in our maps and are further processed adding details during algorithm operations and merging terrains according to user-defined properties.

After generation is complete, each of the regions processed from pixels in input maps is represented as different object. Although its internal properties are to some point determined by adjacent regions, it can be further adjusted or regenerated independently, therefore allowing for easier management of terrain data. At the same time, one faulty region doesn’t disqualify entire terrain - it can simply be regenerated (or manually adjusted), without influencing other, correct regions.

4 Algorithm Overview

In this section we describe procedure we use for generating 3D maps by processing set of 2D images and using chosen properties of emerging terrain. As a test platform for our algorithm we use newest Blender application (version 2.73a). We chose this 3D modelling environment because it contains complete python interpreter and also allows for easy access to program functionality.

Terrain generation algorithm consists of two main steps: processing terrain maps and building terrain according to input data and predefined properties.

4.1 Processing Terrain Maps

Storing different terrain data in separate files requires precise defining what type of information is taken from which map. In our method we currently consider three types of data, defining our output object.

First map contains data about basic altitude level of region represented by each pixel. Since we assume that RGB values in that map are equal we read only one colour value and represent terrain height with it (Fig. 1. left). This parameter defines basic terrain level, which is a foundation for any further calculations (like obtaining dispersion or performing terrain generation).

Fig. 1.
figure 1

Input Files: height map (left), and terrain map (right)

Second map, stored in text file, contains values of dispersion for each region. Total range of this parameter is described by two variables - one concerning dispersion value below terrain level, and one for terrain above it (depending on desired results, those values might differ rather significantly).

Final map stored in RGB image (Fig. 1. right), contains description of different terrains occurring in generated object. Each terrain type is assigned a colour, and is then recognized by simply comparing pixel RGB values to those stored in terrain dictionary (each item, apart from terrain ID also contains basic properties for 3D generation algorithms to work with).

4.2 3D Terrain Generation

After information contained in map files is processed and interpreted we obtain few sets of data that are used in next step, which is terrain generation. Our algorithm currently consist of three main parts: creating and placing basic regions, adding details to those regions and finally joining created terrain tiles and reducing visibility of borders between them, as presented in Algorithm 1.

figure a

In first step of our procedure we use values obtained by processing image containing height map to place basic grids across the scene, as shown at Fig. 2 (top). Each grid has predefined number of vertices. We also normalize height values for it to better fit terrain characteristic, using user-defined parameter (normalization parameter allows us to adjust height differences between regions, decreasing or increasing tiles dispersion along “z” axis).

Although in this step we do not perform any complex operations, obtained results give quite good impression about overall terrain shape. It also provides the possibility to fix any defects that generated terrain can have at this point (like to high dispersion between regions) before main generation process begins.

After we create basic version of our terrain, we then use information from remaining maps, to add details. First we check type of terrain for each existing region (Fig. 2. bottom), since that information decides what kind of algorithm will be used for generation, as well as some of its input parameters. After obtaining required data, we run proper algorithm with given parameters and obtained dispersion range. At this point we gain set of separate regions, where each of them contains part of output terrain, generated according to data from map files. Results of such generation are shown at Fig. 3 (top).

Fig. 2.
figure 2

Basic generation: placing regions (top), and assigning terrain type (bottom)

Final step of our procedure connects created regions and blurs border between them. This part of algorithm works on two neighbouring tiles. It first checks placement of border vertices (since grids are generated next to each other, global x and y coordinates for those vertices will be the same) and moves them to new location. Final placement of each vertex is calculated according to set of constraints specified by user (i.e. they can be placed in the middle, or closer to one region location, depending from influence that each terrain will have at calculations outcome). Results of joining tiles are shown at Fig. 3 (middle).

Although at this point created regions are connected, borders between tiles are clearly visible. We use simple procedure to blur those transitions, by defining percentage of terrain that will be aligned (it corresponds directly to number of vertices in each region that will be modified). Subsequently we level that terrain to its border (already connected with neighbouring region), gradually decreasing alignment influence. Final terrain is shown in Fig. 3 (bottom).

After this final step we obtain terrain made up from set of separate tiles, where each of elements can be processed and modified independently. Since computer games rarely store terrain as single object, and rather load small parts of it when they are needed (i.e. while player travels to another locations or approaches borders between them), such data representation helps to avoid unnecessary operations (like dividing terrain after it was created, to include it in computer game). At the same time we also allow possibility to connect regions into single object (in this operation we consider both joining all regions as well as restricting this action to chosen set of elements).

In its current form (see Fig. 4), our algorithm has both advantages and disadvantages. We still use rather simple procedures for generating terrain inside tiles and blurring borders between them, therefore the amount of available terrains as well as their variety is limited. At the same time terrains we can generate can be easily edited and adjusted because they are editable Bender objects. Unfortunately using Blender application as our test platform greatly limits our performance. Our algorithm can generate terrain (including complex maps, with many different terrain tiles), from relatively simple input, but without inserting any additional detail (like vegetation or buildings). One big advantage is that each step of our procedure can be verified, limiting number of errors occurring in final object. Also due to its modular structure, appending new functionality is an easy task.

Fig. 3.
figure 3

Terrain generation: generating terrain details in regions (top), joining regions (middle) and blurring borders between regions (bottom)

Fig. 4.
figure 4

Algorithm overview

5 Future Work

Our algorithm in its current form can create rather large set of different terrains and is only limited by generation procedure that we are using for different terrain types. Currently we use diamond-square algorithm for that purpose. In the future we would like to add different and more complex procedures for generating terrain.

Another issue is that our joining procedure does not provide satisfactory results, since from time to time, borders between regions are still visible. We would like to work on that problem and try some other solutions, like genetic algorithms, or more complex, mathematical functions than the one we are currently using.

Finally, we would like to add some procedures to further add details to created terrain (like vegetation, rocks, buildings and other).

6 Conclusions

In this work we presented procedure for creating 3D terrain by processing set of schematic maps, and user-defined properties. Terrains obtained during generation process could not only be easily adjusted at different parts of their creation, but also are suitable base for further modifications. At the same time any adjustments can be performed without further actions, either by editing maps, or modifying terrain itself, since our output areas are editable Blender objects.

Our algorithm is at early stage of development and still has some drawbacks, like to clear borders between terrain tiles, or insufficient base of generation algorithms. We plan to address those problems.

Even in this form our procedure creates interesting and playable terrains, that can also be easily used in computer games and further adjusted by designers, providing suitable base for future research.