The diamond-square algorithm is a method for generating highly realistic heightmaps for computer graphics. It is a three-dimensional implementation of the midpoint displacement algorithm which produces two-dimensional landscapes. It is also known as the random midpoint displacement fractal, the cloud fractal or the plasma fractal, because of the plasma effect produced when applied. Algorithm * Assign a height value to each corner of the rectangle (image). * Divide the rectangle into 4 subrectangles, and let their height values be the mean values of the corners of the parent rectangle. For example, the upper left sub-rectangle in will have the height values Example on first iteration But when computing the middle height, one should add a small error, that depends on the size of the rectangle (the standard is to let the error be propotional to the size of the rectangle and some constant. The constant controls the "roughness" of the fractal; a bigger constant results in more valleys and mountains). * Iterate and subdivide each rectange into smaller ones. Eventually, they will be too small to produce a noticiable difference. When this occurs, stop the iteration, and render the pixel with the mean of the height values. Applications This algorithm can be used to generate realistic-looking landscapes, and different implementations are used in computer graphics software such as Bryce.
Links * Generating Random Fractal Terrain: The Diamond-Square Algorithm from GameProgrammer.com * Plasma Fractal from Justin Seyster's web page Retrieved from "http://en.wikipedia.org/" |
|