🏔 Procedural Terrain Generator

7-week team project completed as part of the EPFL course « Introduction to Computer Graphics »


This application written in C and C++, uses several procedural generation algorithms to create an infinite 3D world. Just like in a video game, you can explore the environment using different camera modes and put yourself in the shoes of a character.

To ensure 3D rendering on the GPU, the application uses OpenGL with vertex and fragment shaders written in GLSL (GL Shader Language).

The default parameters used in the generation algorithms have been carefully selected to reproduce the Swiss topography, with its snow-capped mountains, green meadows, and crystal-clear lakes. You have the ability to adjust these parameters to observe their effect on the generated landscapes in real time.

Learn more...

The topography is formed by a 3D mesh consisting of many small triangles connected to each other. This mesh structure determines the shape and surface of the 3D landscape. The way these triangles are arranged affects the overall appearance of the world, including textures, shadows, and visual effects. This representation in a 3D mesh allows the application to create diverse landscapes while ensuring smooth exploration of the generated world.

OpenGL, Vertex & Fragment Shaders

OpenGL runs on your computer's GPU. That's why we need to provide code that runs specifically on that GPU. This code comes in the form of pairs of functions called "vertex shaders" and "fragment shaders." These functions are written in a strictly typed language called GLSL (GL Shader Language), which is similar to C/C++. When these two functions are combined, they form a "program".

The role of the "vertex shader" is to calculate the positions of vertices. Based on the output positions, OpenGL can then rasterize different types of primitives, such as points, lines, or triangles. During the rasterization of these primitives, OpenGL calls a second function called the "fragment shader". Its job is to calculate a color for each pixel of the currently drawn primitive.

Procedural Generation

Here are the different elements of the 3D world that are procedurally generated:

  • Height map
  • Moving water
  • Landscape reflection in water
  • Fog
  • Sky, clouds and sun
  • Day and night cycle
  • Snow
  • Shadows of mountains based on the position of the sun in the sky

Techniques Used

Here are some of the computer graphics techniques used:

  • Noise algorithms to create the terrain elevation map
  • Transformations and projections to create different camera modes
    • FPS mode
    • Free space navigation
    • Camera following a Bézier curve

  • Texture mapping

    A technique used to represent 2D textures or images in a 3D scene.

  • Tessellation

    This is the process of dividing a complex surface into smaller, simpler triangles, used to improve display quality by creating more detailed and smoother shapes, as well as to optimize performance.

  • SkyBox

    It's a way to create the illusion of an infinite, open, and borderless 3D environment without having to model and render the entire world. It's a cube that encloses the virtual world, with images of the sky and clouds placed on the inside of the cube. The player's view is limited to the inside of the cube, but the images on the faces give the illusion of a much larger and more complex environment.

  • Lighting & Shading

    Lighting and shading techniques are used to add depth, volume, and texture to a procedurally generated object. Shading algorithms are used to mimic the behavior of light in the real world, creating shadows and reflections that add realism to the scene.

Professor: Mark Pauly

Discover the application


Smooth camera path using Bézier curves

Day cycles

FPS Camera mode

Free camera mode + Winter landscape