CISC440 S2017 HW3
CISC 440/640 -- Computer Graphics
Due: Thursday, April 27
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. 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:
- Land elevation (brighter = taller)
- 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.
In the basic program above there is no lighting--the sphere's appearance is completely determined by the current texture map.
FYI, there seems to be a bug in common/texture.cpp in loadBMP_custom(). This fix worked for me: right after the line "delete  data;", comment out "fclose(file);" (the problem is that the file was already closed!).
Your job is to add code to the fragment shader 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 [5 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) [5 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) [5 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. You should only modify and submit your fragment shader -- make sure to put your name in it!
Using the elevation texture, implement bump mapping (toggle with the b key while in draw mode 8 from above). This section is worth [5 pts]
When in this mode, the entire surface of the earth should be specular -- not just the water.
You may use any method, but make sure to explain what you did in your README file.