Lab08: Fractal Landscape

draft-draft-draft-draft-draft-draft-draft-draft-draft-draft-draft-draft

This part of the assignment will take some work so please get started early!

On our fileshare, in Lab08-FractalLandscape, are two files FractalLandHeights.cpp and FractalLandHeights.h, which will generate a height map, i.e., a 2-dimensional grid of values that represent heights (the y-value) on a square grid (x and z). Read the comments at the top of FractalLandHeights.cpp to see what it does and how the heights are stored.

You need to create a new class e.g., called FractalLandShape (along the lines of the Cube or Disk) which takes the heights and generates a list of triangles (vertices) and normals. Think about how to calculate the normals efficiently. Note, the normal at a vertex needs to be the average of the normals of the surrounding triangles. Work it out first with pencil and paper.

The colors can either be implemented in your FractalLandShape class as a colors array or you can choose to implement the color as a color map in the shader (your choice). Either way, you will need to write a color map function which takes a y-value and returns a color. GLSL has some nice smoothing functions which you can use if you do it in the shader (preferably fragment over vertex, for the same reason Phong Lighting is better done in the fragment shader).

In main.cpp, create a new FractalLandShape object and render it. Include a light source which you can move around (along x, y, z). Include a cube that sits at the light location. Moving the light will help you test whether your normals and light location are set properly.

No later noon on Thursday Week 9 demonstrate your program in lab and submit this code via our Fileshare.