Assignment 4 - Intro. to GLSL and Texturing

Due Wednesday Nov. 6, 2019 at 3:00 PM

Overview

This assignment is a introduction to OpenGL shaders and texturing.

There are two parts to this assignment:

Before you begin, you may want to review the assignment material with these lecture notes. The GLSL shader demo for this assignment can be downloaded here. More in-depth details for the assignment will be given in the sections below. There is also an extra credit section at the bottom.

Your Assignment: Part 1 (50 pts)

Your task is to update your OpenGL renderer and update it to implement per-pixel Phong shading. The program should also have a mode argument, which can be either 0 or 1, and if it is 0, then the scene should be rendered with Gouraud shading; otherwise, the scene should be rendered with Phong shading.

The input of your program should be read from standard input as so:

./opengl_renderer [scene_description_file.txt] [xres] [yres] [mode]

Within the hw4 folder is an OpenGL shader demo program that is meant to serve as a reference for your own OpenGL program. We recommend making use of the demo’s source code and comments and its Makefile as references for when you are writing your own program.

Your Assignment: Part 2 (50 pts)

Your task is to write a program in C++ that takes an input color texture and normal map, and renders flat polygon shaded with the given textures. Lighting for the each pixel should be calculated with the color texture as the material color, and the R, G, and B components of the normal map as the xyz components of the normal vector. The program should also allow the user to intuitively rotate the scene with an Arcball mouse UI.

The input of your program should be read from standard input as so:

./opengl_renderer [color_texture.png] [normal_map.png]

For this program, it is acceptable to hardcode the vertexes, normals, tangent vectors, and texture coordinates of a square surface directly into the program.

pict
Texture mapped image

pict
Texture mapped image with normal mapped lighting

Extra Credit

Assignments 3 and 4 together cover our “introduction” to the Open Graphics Library API. However, there are many more features of OpenGL and GLSL shaders that we did not cover. This includes small features such as fog, text rendering, alpha channels, and multiple display windows. This also includes larger topics such as Modern OpenGL syntax, geometry shaders, other texture mapping techniques like height mapping and parallax mapping, data plotting methods in OpenGL for scientific visualizations, and many more. This link provides a lot of nice tutorials on the matter.

For extra credit, explore and implement some of these features of OpenGL and GLSL. Please consult with the TA’s ahead of time to make sure your extra credit topic is appropriate. Please also include details regarding your extra credit in the README. Extra credit points will be awarded based on the complexity of the work. Simple things like fog rendering – which is only a few lines of additional syntax – won’t be worth much, but larger attempts such as implementing height mapping will be worth more.

TA’s are not liable to help with extra credit.

What to Submit

Before submitting, please comment your code clearly and appropriately, making sure to give details regarding any non-trivial parts of your program.

Submit a .zip or .tar.gz file containing all the files that we would need to compile, run, and test your program. In addition, please submit in the .zip or .tar.gz a README with instructions on how to compile and execute your program as well as any comments and information that you would like us to know.

We ask that you name your .zip or .tar.gz file lastname_firstname_hw4.zip or lastname_firstname_hw4.tar.gz respectively, where you replace the “firstname” and “lastname” fields with your actual first and last name.

Please submit your zip or tar.gz to moodle in the area for Assignment 4.


Original assignment by Andrew Zhao (Class of 2016).
Links: Home Assignments Contacts Policies Resources