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
- Height map is created with libnoise and exported to an image file.
- Vertices are filled with simple x and z coordinates(no height). Generally around 12,000,000 vertices.
- OpenGL is set up, vertices are sent to vertex-shader through draw call.
- The vertex shader updates each vertex with the according height by reading it from the height map image file.
- 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.
- 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