Program4 - CSci 5108: Programming Assignment #4 due: 9pm,...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSci 5108: Programming Assignment #4 due: 9pm, Tuesday, April 13 The purpose of this assignment is to introduce you to software that is used to write pixel shaders. In particular, you will learn how to program using the OpenGL Shading Language. To complete the assignment you will be given three working OpenGL programs, you will be asked questions about one of the programs, and you will be required to modify the other two programs. The modifications will only involve the OpenGL Shading Language, so it will not be necessary for you to know the OpenGL API itself in order to do this homework. You should begin by familiarizing yourself with the OpenGL Shading Language. Read chapters two and three in the book OpenGL Shading Language by Randi J. Rost that is on reserve in Walter Library. You will also find the following web sites helpful as a resource for learning about the OpenGL Shading Language: http://www.opengl.org/documentation/glsl/ http://www.opengl.org/sdk/libs/OpenSceneGraph/glsl_quickref.pdf Once you have introduced yourself to the OpenGL Shading Language you should find a Windows PC or a Linux workstation that has the necessary graphics card installed. You must use a graphics card that can do both vertex and fragment shading. To determine which PCs or Linux machines in the IT instructional lab have the necessary graphics hardware to do this homework, or to find out whether you can use your own PC graphics card, read the documentation that is available with the software provided for this assignment. When you are ready to start work on the programming portions of this assignment, download the software that is available by following the link next to the assignment on the course web page. Follow the instructions given to install the three provided programs on your PC or Linux workstation. Answer the following questions regarding each of these three programs. 1. Program 1 demonstrates the difference between Gouraud and Phong shading. Gouraud shading was implemented in this program using the standard OpenGL rendering pipeline, while the OpenGL Shading Language was employed to write the Phong shader. Follow the instructions that are given with the program to switch between the two shaders and to alternate between displayed objects. Answer the following questions: a. Describe the visual differences that exist between the pictures produced using Gouraud and Phong shading. Where are these differences most apparent? b. What causes the visual differences that you see between Gouraud and Phong shading? Why is one method superior to the other? c. Without changing the two shading algorithms, discuss how better modeling could be used to improve the appearance of the inferior shading technique. Elaborate on the performance trade-off that exists between using better shaders with poorer models or superior models with inferior shaders. 2. Program 2 shows how a shader can be used to implement procedural bump mapping. This example was programmed using the vertex shader and the fragment shader given in Listings 11.7 and 11.8 respectively of the book OpenGL Shading Languages. Modify this shader so that it uses a normal map to perturb the surface normal instead of generating the normal perturbations procedurally. A normal map is a texture that contains normals that are to be used for the purpose of bump mapping. Use central differences to create the normal map from an RGB texture and store the normal map in the same texture memory that was allocated for an RGB texture in Program 2. You are free to choose whatever RGB texture you would like in order to create your normal map. Along with the source and the executable, please submit a screen capture called bump_map.tif of Program 2. 3. Program 3 is similar to Program 1 in that it allows you to shade an object using the Phong reflection model. For this part of the assignment you are to replace the Phong reflection model in Program 3 with the Ward reflection model discussed in class. To help you do this, Program 3 contains several sliders that allow you to adjust the parameters of the Ward reflection model. Your implementation should connect the output of these sliders (which don't do anything now except change the value of a variable) to the shader so that the reflection properties can be adjusted in real time. Program 3 also contains a sphere and a disk that you can shade using the Ward reflection model. The brush directions (necessary for anisotropic reflection effects) are computed for the sphere. For the disk you must program the brush directions yourself. A link to the original Ward reflection model paper is given below: http://doi.acm.org/10.1145/133994.134078 Along with the source and the executable, please submit screen captures called sphere.tif and disk.tif taken while Program 3 is displaying the sphere and the disk respectively. Part one will be worth one fourth of the total points allocated to this assignment with the remainder of the points split equally between parts two and three. To turn in your assignment, touch the button marked Homework Submission Tool on the course web page and follow the directions. ...
View Full Document

This note was uploaded on 10/21/2011 for the course CSCI 5108 taught by Professor Interrante,v during the Spring '08 term at Minnesota.

Ask a homework question - tutors are online