In this MP you will make a copy of your Terrain MP that applies a rainbow of colors based on terrain altitude.

This MP is elective, with no core components. It assumes you have already completed the Terrain MP.

1 Overview

You will submit a webpage that has

  • Two number entry fields
  • One button
  • One canvas
  • A 3D view of dynamically-generated fractal terrain

Submit an HTML file and any number of js and glsl files. No image files, JSON files, or CSS files are permitted for this assignment.

You are welcome to use a JavaScript math library, such as the one used in in-class examples or others you might know.

2 Specification

All specs from the Terrain MP apply to this MP too except as noted below.

2.1 Rainbow height map

The color of each pixel should be based on the altitude of the terrain beneath it, plus lighting. The color should move smoothly through several different colors so as to make a rainbow effect.

The colors should change smoothly through multiple colors even if there is only one fracture. A good way to make the changes smooth is with a lerp, (1-t)x + (t)y such as we also used in the Bézier notes and for linearly interpolated textures.

2.2 No input-varying branches

As always, our WebGL2 dialect applies. You’ll probably find the warp parallelism part of the dialect a little frustrating as it means that your fragment shader cannot include an if with the height as part of the condition. You’ll need to use expression-based conditions instead.

3 Evaluating your results

On both your development machine and when submitted to the submission server and then viewed by clicking the HTML link, the resulting page should initially be blank. Once the button is pressed a terrain should appear with a rotating camera, shiny green where flat and duller red where steep. One example might be the following:

A video of an example result showing three different generated terrains.