Procedural terrain generation with OpenGL

Enjoying a virtual sunset over a procedurally generated terrain

I completed this project with two colleagues, Julien Harbulot and Isaac Leimgruber, for the “Introduction to computer graphics” course.  The course focused on rendering techniques and their theoretical basis while leaving to the students the task of learning how to actually implement those techniques in OpenGL. The initial goal was to generate a landscape using procedural techniques and add some basic lighting effects to it.

We implemented several features in addition to the basic requirements:

  • Infinite terrain generation
  • Dynamic shadows
  • Adaptive level of details through the use of tessellation
  • Instantiated patches of grass
  • 3D model loading
  • Dynamic sky which mimics the natural colour changes throughout the day

Source code

See the screenshots of the completed project below:

Grass patches appear when appropriate terrain conditions are met.
Reflections on the water surface vary over time depending on the waves and ripples.
The terrain regenerates indefinitely when the user traverse the landscape. Mountains far away are faded to hide the regeneration process while at the same time giving the illusion of distance.

Tessellation allows adjusting the level of detail of the terrain based on the distance to the observer and the importance of a given zone. Note how little geometry is used for the underwater part.