Fractal Terrain Generation

Anthony Annuzzi


Technologies Used and Steps Taken:

  • Diamond-Square Fractal Heightmap Generation
  • Heightmap to vertex coordiates
  • Index Buffer Object to connect proper vertices
  • Using the IBO, compute normals for lighting
  • Generate texture coordinates for terrain
  • Include ground water plane
  • Render terrain using Phong lighting and textures
  • Water rendered using texture and transparency

Diamond-Square Fractal Generation Method

In order to generate the heightmap for the terrain, I used the diamond-square method which is illustrated below. First, the corners are set, then the center point is randomly generated and added to the average of the corner values. Now, for step c, there is a diamond which has a randomly generated center point. The midpoint value is then calculated by averging the corner values and adding the random number that was generated. This will now create squares again so that the algorithm can be repeated. The image below illustrates how this algorithm works.


Generating Triangles

Using the heightmap generated using the diamond square method, the next step is to generate the vertices that will be used. These have a varying x,z position and get the y values from the heightmap. Once that is done, the vertices must be indexed so that OpenGL will know which vertices will be connected. This was done by using GL_TRIANGLE_STRIPS and connecting adjacent vertices. Once that step was completed, I then calculated normals for each of the triangles by getting the vertices of each triangle and taking the cross product. This was done so that Phong lighting could be applied.

Finished Product

Unfortunately due to time constraints, the project was not fully implemented as expected. The original goal was to create a realistic looking landscape. Although that goal was not accomplished, many of the elements were created as I had hoped. I was able to implement the heightmap generation and creation of the triangles. However, it did not look as realistic as I had hoped. Also, the texture mapping did not work as well as I had hoped. Below is an image of the finished product.