CISC440 S2022 HW2

From class_wiki
Jump to: navigation, search

CISC 440/640 -- Computer Graphics
Homework #2
Due: Thursday, March 17

Description

In this assignment you will experiment with GLSL fragment shader code to obtain different lighting and texturing effects. Starter code for the portion of the assignment which must be completed by both undergraduates and graduate students is called multiearth (you will probably need to change the line #include <glfw3.h> to #include <GLFW/glfw3.h>). This program shows a rotatable, texture-mapped sphere representing the planet Earth as seen from space. By pressing keys 1-5, the user can switch between "draw modes" to show five different textures on the sphere:

  1. Land elevation (brighter = taller)
  2. Water
  3. Night
  4. Clouds
  5. Color (no clouds, water is one color)

Pressing key '0' will show the sphere as all red, with no texture. Pressing key '6' will demonstrate simple multi-texturing by combining the color and cloud textures. 'a'/'s'/'d'/'w' cause the sphere to rotate, and ESC ends the program.

In the basic program above there is no lighting--the sphere's appearance is completely determined by the current texture map.

Required elements

Your job is to add code to the fragment shader (and possibly main.cpp and the vertex shader if it helps) to implement the following features. Switch effects within your shader by choosing the "draw mode" keys indicated below.

  • Modulate the color texture with diffuse lighting from a single point source representing the sun. The sun should be appropriately positioned to best demonstrate the effect. You may use OpenGL to define the light position and color and the material properties of the sphere, or just set them directly in your shaders. See OpenGL tutorial #8 for how to do this. This effect should be draw mode 7 [4 pts]
  • Implement specular lighting with Phong shading (i.e., show per-pixel highlights due to the Sun) ONLY where there is water (draw mode 8) [4 pts]
  • Show the night texture on the dark side and the color texture on the lit side of the Earth relative to the light position. Instead of having the Earth rotate, animate the light going around the Earth. Try to have a smooth transition at the border between the dark and light regions. You do not have to do diffuse or specular lighting in this mode (draw mode 9) [4 pts]

Please make use of functions for modularity to keep your shader code readable.

Include a README to explain your approach to each of these draw modes, and any difficulties or observations you had.

Graduate requirements

Integrate an animated fragment shader of your choice from www.shadertoy.com (similar to but not the same as the one shown in class on 3/1) that works over the land surface only of the earth while in draw mode 8 (water is still specular). You may replace the earth color or combine the effect creatively with one or more of the existing textures. The effect should turn on or off by toggling the 'b' key. This section is worth [4 pts] and will be scored for creativity and complexity.

Make sure to explain details of what you did in your README file.