C++/OpenGL terrain generator from a grayscale image.
Clone repository along with submodules (-j4
flag is an optional speed up):
git clone --recurse-submodules -j4 https://github.com/matorsoni/BitmapTerrain.git
Build and run the project:
cd BitmapTerrain/
mkdir build
cd build
cmake ..
make -j4
./terrain
Note: GLFW may ask for additional dependencies that are not installed in your system. Installing them and rebuilding this project should work fine.
Execution modes:
(1) ./terrain
(2) ./terrain <path-to-grayscale-image.png>
(3) ./terrain <path-to-grayscale-image.png> <path-to-rgb-texture.jpeg>
Running (1) will create the default image terrain (BitmapTerrain/assets/bitmap.png
) renderer with the default texture (BitmapTerrain/assets/wood.jpeg
).
Running (2) will create a terrain based on input image, renderer with the default texture.
Running (3) will create a terrain based on input image, renderer with the input texture.
Note: While textures can be of any image type, terrain generation only works with true grayscale images. To convert any image to this format, I recommend running the following ImageMagick command:
convert <input_image> -set colorspace Gray -separate -average <output_image.png>
- Move camera with WASD + mouse movement.
- Mouse scroll to increase and decrease terrain height.
- Press F to render on wireframe mode (On/Off).
- Press T to apply texture (On/Off).
- ESC to close application.