IntroductionThere are many ways of generating terrain. Some use a simple randomiseandsmooth technique [1], whereas others use more complex techniques that use fractal methods to achieve realistic terrain [2, 3, 4]. While each individual method has its own advantages, it can be hard to control just how "bumpy" the terrain is. In this article, I propose a new method of terrain heightmap generation that uses an iterative process, treating the heightmap as a highly viscous and rubbery fluid. The parameters to the fluid simulation equation enable the quality and quantity of features in the generated heightmap to be varied as desired. Fluid SimulationBefore I explain the process of generating a satisfactory heightmap, it will be helpful to the reader to know about methods of fluid simulation, as it is one of these methods that is behind the algorithm. Simulating fluids is a very CPUintensive operation. The more accurate and boundless you want the simulation to be, the more CPU power that is required. Some methods use a fast Fourier transform to achieve believable results [5], whereas others extend equations for tensioned strings into 3D [6, 7]. To keep the algorithm relatively simple and fast to compute, I have chosen to use the method described in [7]. After extending tensioned strings into 3D and computing partial derivatives, the method gives the following equation for the height of the point i, j, at frame k: _{} c is the speed at which waves travel across the surface, t is the constant timestep between each iteration, d is the distance between each node of the surface and μ is the viscosity of the fluid. Note that this method uses the previous two timesteps, not just one, to compute the next one, although only one point is sampled from the timestep k1. Generating a HeightmapTo actually generate the heightmap, the process is fairly simple. Roughly, the steps are:
Let us examine the stages in detail. Pick constants c, μ, d and t
Fill heightmap with random values between two boundaries
Iterate fluid simulation equation over the heightmap as many times as desired
Normalise heightmap values to bring them into the range [0…1]
_{} This brings each value between 0 and 1. Multiply heightmap values by 255 and output as greyscale image
Here are some examples of heightmaps generated using the algorithm. The parameters are those specified in the stepbystep description unless otherwise stated.
Notice how lowering μ produces a smoother terrain, and how lowering c produces a terrain much like those generated with c=100 but with the features less welldefined (compare c=50, 1000 passes with the standard parameters, 100 passes heightmap). If you wish to try the method out yourself, then take a look at the sample application (and source) included with this article. The application takes various parameters and outputs the heightmap to your specification as a simple raw image file. The supplied source file shows how to implement the algorithm. References[1] LeckyThompson, Guy W., "RealTime Realistic Terrain Generation," Game Programming Gems, pp. 484498

