GameDev.netTerrain Generation Using Fluid Simulation

Terrain Generation Using Fluid Simulation
## IntroductionThere are many ways of generating terrain. Some use a simple randomise-and-smooth 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 CPU-intensive 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
## Generating a HeightmapTo actually generate the heightmap, the process is fairly simple. Roughly, the steps are: - 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].
- Multiply heightmap values by 255 and output as greyscale image.
Let us examine the stages in detail.
This is simply a case of trial and error. It is important that the fluid is very viscous for the method to work; values that I have found to produce satisfactory results are: *c =*100*d =*10*t =*0.033*μ =*100
This brings each value between 0 and 1.
Here are some examples of heightmaps generated using the algorithm. The parameters are those specified in the step-by-step description unless otherwise stated.
Notice how lowering If you wish to try the method out yourself, then take a look at the ## References[1] Lecky-Thompson, Guy W., "Real-Time Realistic Terrain Generation," Game Programming Gems, pp. 484-498
Francis "DeathWish" Woodhouse
© 1999-2011 Gamedev.net. All rights reserved. |