Skip to content

C++/OpenGL terrain generator from a grayscale image.

Notifications You must be signed in to change notification settings

matorsoni/BitmapTerrain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BitmapTerrain

C++/OpenGL terrain generator from a grayscale image.

Samples

image_3

image_4

image_1

image_2

image_5

image_6

Setup

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.

Running the application

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>

Inputs

  • 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.

About

C++/OpenGL terrain generator from a grayscale image.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published