Terrain Generation is an implementation of Realitime Procedural Terrain Generation for generating mountainous terrain as a C++ library using OpenCV. The program generates random height maps using a combination of midpoint displacement, Voronoi diagrams, simplex noise, thermal erosion, hydraulic erosion, and a custom erosion operation. With a little effort, the heightmap can be imported into Unity3D, Unreal Engine, Gazebo, or any other physics simulation environment to create 3D landscapes.
Jacob Olsen: Realtime Procedural Terrain Generation, University of Southern Denmark, 2004. PDF
Simplex Noise Implementation: https://github.com/SRombauts/SimplexNoise
- OpenCV
- C++11
Refer to the following sources for instructions on installing OpenCV: Windows and Ubuntu.
Note: Tested on Windows 10 and Ubuntu 16.04, but it should compile on any platform
mkdir build && cd build
cmake -DBUILD_TESTS=ON -DBUILD_UNITY=OFF -DBUILDOpenMP=ON ..
make -j8
test_diamond_square 9 0.5 # Diamond-square algorithm with side lengths s = 2^9 + 1 = 513 and persistence = 0.5
test_voronoi -1 1 20 # Voronoi diagram with c_1 =-1, c_2=1, and n_points=50
test_combine -1 1 20
test_perturb 0.1 # Run perturbation with magnitude of 0.1
test_thermal_erosion 50 # 50 Iterations of thermal erosion
test_hydraulic_erosion 50 0.1 0.1 0.5 0.1
test_fast_erosion 50