| |
|
|
||||
![]() |
||||||
| |
|
|||||
|
Generating Random Terrain We have already discussed the Macro-Infinite Resolution, and how it is limited by the size of random number sequence that can be generated. However, at the other end of the spectrum is Micro-Infinite Resolution; in effect, zooming in to the detail of a given game element. In practice, this is limitless, so long as a given point that we wish to examine can be uniquely identified within the limitations of the system. This means that so long as we can identify a given game element uniquely based on its position in the game universe, we can define the characteristics of that point algorithmically. The reason that it needs to be identified is so that we can seed the random number generator using the identifier, and guarantee that the sequence of numbers generated which are used to determine the characteristics are the same for two instances of the game universe. One example of how this is useful is in the generation of terrain maps. It means that not only can we generate the entire map, but that we can also zoom in to ever increasing detail on a given point, so long as we can identify it uniquely. For example, we can show the map, and then zoom in to a coastline. As we zoom, the coastline will become ever more detailed as the resolution increases. The reason that this is possible is that we can break down each feature into a series of grids, and then each of those grid squares into grids to get more detail, and so on. Each of the grid squares can be given certain characteristics based on its position in the game Universe.
The simplest type of terrain that can be generated is completely chaotic. That is, for each point on the arbitrary grid, a value can be assigned at random which indicates the height of the terrain. The image in Figure 3 is the result of such a random terrain generator Of course, it does not look like traditional terrain, because there are no patterns to the arrangement of height values. In order to create a pattern, a technique can be used known as Quadrant Average Analysis. The essence of this technique is to break down the terrain into a series of grids. For each grid, the sum of the height values in the squares is calculated, and then the average computed, which is then the value given to the entire grid. This can then be performed again for successively larger grids until the required resolution is achieved (Figure 4 shows this technique in action).
Note that in defining the landscape in this fashion, if we decide to "zoom in" to the map, we can recalculate each land feature by it’s placement on the planet, based on the neighboring features. Be warned, however, that the greater the size of the quadrants used to create each feature, the more computationally expensive it will be, since more squares need to be taken into account. More realism can be achieved if we use a mixture of storage and calculation. One of the best techniques for creating realistic landforms is based on observing the natural formation of land in the real world. The key to the creation of the majority of natural landforms is the existence of fault lines on a planets surface. These fault lines result in either ridges or troughs, which give mountains or valleys. The fault lines intersect at certain points.
There is more to the science of geophysics than that, but this will be more than enough for our next example. As before, we use a grid. This time, instead of populating it with random squares, we draw lines running from top to bottom and left to right, as shown in Figure 5. The start and end points of the lines are chosen using the pseudorandom number generator seeded on a value that is a combination of their sequence number and the planets position within the Universe. Next, the same algorithm is applied as before, to smooth out the spaces between the lines. The effect of this can be seen in Figure 6. To add even more spice to the landforms, we can vary the "height" of each point of the lines with an algorithm. We might choose, for example, to apply a sine function of a pseudorandom amplitude and frequency. When we combine these, and "average out" the resulting pattern, the result is very convincing.
However, it is much too computationally expensive to actually recalculate all this just to zoom into one square, so this initial height map must be stored for future reference. We can, on the other hand, assign other features such as rivers, trees, or grass in an algorithmic fashion based on the stored value of a particular square along with it’s position, in real time without any real penalties.
|
|
|