Final Project - CSE 167 - Student: Allen Ding
CSE167 Final Project - Procedural Terrain Generation
Download
Fall 2004
Project Aims
For my final project, I wanted to do something that to do with procedural graphics. I narrowed it down to wanting to create a procedurally generated terrain after looking/inspired in some books and on the web, although I was also very interested in doing some procedural plant modelling. I was hoping to create a project that would allow me to create some fancy and interesting if not realistic terrain.
Implementation
I read about many, many terrain generation algorithms. Since I did not have that much time to spare, I decided on a relatively simple method for generating fractals, the plasma/midpoint displacement algorithm (mine was based on the one I read in game programming gems I, there are dozens of tutorials on the web). I was hoping to use some other methods, like using particle deposition, lattice, noise functions, etc if I had time, but I ran out of time, so no such luck.
Basically the MPD algorithm creates a 2D array of height values. It involves 2 steps: the diamond step and square step.
- Start with a square map of some size desired, and unknown height values.
- Initialize 4 corners to some value.
- Determine the height of the point in the middle of square with the average of 4 corners.
- Now determine the height of the mid points of the lines that form the square, by using the average of the 4 adjacent points to it (l,r,u,d).
- Repeat the process on each square in the new height map.
- There are some border conditions (eg:point without neighbours, such as corners) to deal with, and many ways of dealing with them.
- Each repeat of process makes height map have more and more detail.
- Oh, and when determining the height value of a point a random value that is at most DHEIGHT is added to it (this is basically the key of this stuff working). On each iteration, DHEIGHT is reduced by some factor DRATIO. The DHEIGHT and DRATIO values affect the type of terrain generated (really flat, really spiky, realistic, etc).
My explanation of the algorithm isnt that clear and leaves a little to be desired, but you can find out on the web anywhere about it if you dont already know, or want to understand it better. A lot of this stuff is in 'Game Programming Gems', www.vterrain.org, gamasutra.com, and some research papers. Really cool & advanced stuff is in 'Texturing and Modelling: A Procedural Approach'.
In addition to the basic algorithm that I managed to implement, I also implemented a few other features in my project (w/ explanations):
- lighting to look nice - the normals were not straightforward to compute (at first)
- using display lists so that the program actually runs decently
- smoothing band filter that smooths out the terrain
- a 'jaggie' filter that makes the terrain more 'grainy'
- a very basic mesh level-of-detail generation and selection just to see if I could do it. I used sort of the same idea as mip-mapping. It works, but unfortunately does not look good. I wish I had more time for this.
- texture maps from 'GameSuccess', this was slightly involved to get it to look good, but I think the result is decent - yes,the textures are legal and royalty free
- transparent water plane - this was easy :)
- limitation: terrain maps HAVE to be dimensions of powers of 2. (i regret this now)
Stuff I wanted to do but did not have time to:
- Procedural clouds - this would have been very similar, and quite simple, but no time too bad
- different fractal algorithm
- user specifiable height map masks
- Trees!!!
- Better LOD
- Water reflections
- animals roaming w/ animations
- Spherical terrain (to make worlds)
- many other things
Success/Failure of Aims
I was quite pleased with the results that the MPD algorithm gave. Although the terrain isnt exactly mindblowingly lifelike (eg, hard to get stuff like coast and flat plains with a hill somewhere), the results were very interesting. With lighting, it can sometimes look really cool I think. I was surprised that the textures looked quite decent, because I wasnt sure that they would apply well to procedural terrain.
I was unhappy with my LOD scheme, and hope to change it to be better some time. At the moment, the terrain meshes are powers of 2, but I think if they were arbitrarily sized, I would be able to generate much better progressive meshes. I do wish I had more time to get more things implemented, like in the list above.
All in all, I am pretty happy, esp. now that the quarter is over :)
List of figures
- Brrrr

- Red

- Rockies

- Serene Green

- High White Mountains

- With Some Liveliness

- Rocky Island

- Cliffs at the sea
