![]() |
![]() |
![]() |
![]() |
|
![]() |
![]() ![]() ![]() |
|||
![]() |
||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Terrain Generation Tutorial: Heightmaps
Let's begin by establishing some basics. The standard way of creating 3d terrains is through the use of heightmaps. A heightmap is simply a 2d array of values. Each value in the array represents the height of the terrain at that value's position. For example, if the cell at (2, 3) has a value of 5, then the terrain contains the point (2, 3, 5). To render a heightmap in three dimensions you create a mesh by iterating through the two indices of the array and set the height at each vertex to the value of the heightmap at that point. Typically, I use the X and Y axes for the two indices, and the Z axis for the height of the terrain, but any orientation will work.
Heightmaps as ImagesAnother way to picture a heightmap is to think of it as a grayscale image, where the brightness of each pixel corresponds to the height of the terrain at that point. In this manner, dark regions on the image represent valleys and lighter regions represent peaks. For example:
Procedurally Generated HeightmapsNow that we understand how to generate terrains from heightmaps, the next step is coming up with an algorithm to generate this heightmap. There are a bunch out there already, each with it's own appearance and characteristics. For some examples (including some similar to this one) check out this and this. The algorithm shown next is a little different. Click here to continue. Copyright © 1999-2002 Bob Nystrom. |