For many real world terrains, there exist Digital Elevation Models (DEMs) that represent a terrain by a set of data points representing elevations. These data points are gathered by several techniques such as lidar (laser that is used to measure distance), stereo photogrammetry (measurements derived from aerial photographs taken), and dopler radar. For my project, I wanted to render the Morro Bay landscape.
Available online is a DEM for Port San Luis. The DEM was a file composed of height values for each 10 m x 10 m square within San Simeon Bay, Cambria, El Paso de Robles, Estero Bay, Morro Bay, Port San Luis and San Luis Obispo Bay, Pismo Beach, Grover Beach, the Guadalupe Dunes, and Vandenberg Airforce Base. To load the DEM file into openGl, the file was parsed and placed into an array. Morro Bay was isolated by manually finding the rows and columns associated with Morro Bay. More specifically, this was done by finding the exact geographic coordinates of the corners of the landscape I wanted to render and converting those values into the appropriate rows and columns within the DEM data. The ground is then rasterized using the vertices that are in the array.
The entire landscape is lit with a moveable lightsource. The image below shows the landscape with a "sunset" like lighting. Since the landscape is made up of many triangular faces, the a normal buffer was calculated for the triangular faces and passed into the vertex and fragment shader to enable the phong lighting calculations to happen. The specular component was approximated with the half vector.
The surfer was constructed and animated using hierarchical modeling using three different objects: the surfboard, the surfer, and the sphere (the selfie stick). The gopro angle toggled using key '3' was achieved by updating the eye and lookAt everytime the surfer objs were updated. The gopro angle is shown below.
The ability to render realistic landscape gives the graphics programmer a lot of power. Any sort of game with a very "real world" type of feel can be done by rendering landscapes using DEMs.
The download for the DEM is found at this site.