/3D_Terrain_Generation

Three-dimensional terrain generation using the diamond-square algorithm and OpenGL

Primary LanguageC++

3D_Terrain_Generation

Three-dimensional terrain generation using the diamond-square algorithm for heightmap generation and OpenGL with GLEW for rendering.
Created in June of 2016.

The initial purpose of this project was to create a set of classes for generating heightmaps. The Map class provides the ability to generate terrain using an iterative implementation of the diamond-square algorithm.

The functions that handle the actual generation allow you to define the terrain's roughness/courseness and its level of detail (or polygon count). Besides the basic functions that handle things such as capping the heightmap and cleaning it up, I've included a function for smoothing the terrain using a mean/box filter.

Initially I had the heightmaps rendering in 2D where the height values mapped to color values in an image, but later I decided to make the Mesh class for rendering the heightmap in 3D. I've implemented basic lighting and shaders, along with the ability to rotate and translate the terrain. I've also decided to create my own math classes for dealing with matrixes and vectors.

Below are some screen shots obtained by tweaking the values in main.cpp, and using the uncommented lines in the shader files.

Default values as seen in main: alt tag alt tag

Increasing passes of smooth filter and its size: alt tag alt tag alt tag

Changing the roughness: alt tag

Changing the level of detail (mapsize value in main): alt tag alt tag

Messing around with commented lines in the fragshader: alt tag alt tag alt tag alt tag alt tag alt tag

The imgur album can be viewed here: http://imgur.com/a/VaVkM