This project implements a heightfield renderer using OpenGL and GLSL shaders. A grayscale JPEG image is interpreted as terrain elevation data and rendered in various geometric modes, mainly points, wireframes, and solid triangles. The user can rotate, scale, and translate the terrain interactively, and toggle between rendering modes using keyboard input.
In addition to standard rendering, a custom vertex shader provides a smoothing mode that averages each vertex with its neighbors and applies a height-based exponentiation and rescaling. The user can control these smoothing parameters in real time with key bindings. Vertex positions and their neighbors are passed in as vertex attributes using separate VBOs.
To visualize heightmaps, I first parsed grayscale JPEGs into terrain meshes using varying primitive types. Each rendering mode—points, wireframes, triangles—was assigned to a keypress and implemented with distinct VAOs and VBOs to adhere to core profile restrictions. I created additional VBOs to pass in neighbor vertex positions as attributes for use in the smoothing shader mode.
The smoothing shader included uniforms for scale and exponent, which users could modify live. The scale parameter linearly scales the height of the terrain, while the exponent parameter determines the degree applied to the height value (which also affects the final color).