gannonprudhomme / Terrain-Generation

3D Random terrain generator using OpenGL and Perlin Noise written in C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terrain-Generation

A terrain generator written in C++ that uses Perlin noise(libnoise) to output a height map, and OpenGL to render it. Other features include:

  • Self-contained heightmap generation
  • Specular lighting
  • Bump mapping

Requires

  • GLFW for window creation
  • GLEW for using OpenGL
  • GLM for math utilities
  • libnoise for Perlin noise / terrain generation
  • stb_image for loading image files into a texture

How it works

  1. Height map is created with libnoise and exported to an image file.
  2. Vertices are filled with simple x and z coordinates(no height). Generally around 12,000,000 vertices.
  3. OpenGL is set up, vertices are sent to vertex-shader through draw call.
  4. The vertex shader updates each vertex with the according height by reading it from the height map image file.
  5. It then calculates the normal values by looking up the heights for the surrounding vertices and creates a normal vector, which is sent to the fragment shader.
  6. Fragment shader calculates light value using normal map and light location, blends the resulting color with the terrain texture, then outputs the final color.

Controls

  • W-A-S-D for movement
  • Shift to increase movement speed
  • F to show wireframes
  • G to hide wireframes
  • Escape to close the program

Screen Shots

512x512 height map Imgur

4096x4096 height-map Imgur

Wireframe mode Imgur

About

3D Random terrain generator using OpenGL and Perlin Noise written in C++

License:GNU General Public License v3.0


Languages

Language:C 55.7%Language:C++ 43.1%Language:GLSL 1.1%