6.837 Intro to Computer Graphics
Assignment 3: OpenGL & Phong Shading

In this assignment, you will add an interactive preview of the scene, and implement Phong Shading in your ray tracer. For interactive display, you will use the OpenGL API that uses graphics hardware for fast rendering of 3D polygons. Note: with some configurations, software emulation might be used, resulting in slower rendering. You will be able to interactively pre-visualize your scene and change the viewpoint, then use your ray-tracer for higher-quality rendering. Most of the infrastructure is provided to you, and you will just need to add functions that send the appropriate triangle-rendering commands to the API to render or paint each kind of Object3D primitive. In OpenGL, you display primitives by sending commands to the API. The API takes care of the perspective projection and the various other transformations, and also rasterizes polygons, i.e., it draws the appropriate pixels for each polygon. (In lecture, we will talk about how this is done using the rendering pipeline). In addition, the infrastructure we provide takes care of the user interface and how the mouse controls the camera.

To use OpenGL on Athena, you will first need to obtain access to the OpenGL libraries and header files. To do this, from an Athena prompt, type:

   add mesa_v501

All files implementing OpenGL code should include the OpenGL header files:

   // Included files for OpenGL Rendering
   #include <GL/gl.h>
   #include <GL/glu.h>
   #include <GL/glut.h>
We provide an updated Makefile to link with the OpenGL libraries on Athena Linux. If you are using Windows, then you may need to download the OpenGL libraries yourself from http://www.opengl.org.

Tasks

Hints

Ideas for Extra Credit

Updated Files:

      If you're interested, here's the scene description file grammar used in this assignment.

      If you're interested, here's a list of command line arguments used in this assignment.

Input Files

Sample Results

raytracer -input scene3_01_cube_orthographic.txt -size 200 200 -output output3_01.tga -gui

raytracer -input scene3_02_cube_perspective.txt -size 200 200 -output output3_02.tga -gui

raytracer -input scene3_03_bunny_mesh_200.txt -size 200 200 -output output3_03.tga -gui

raytracer -input scene3_04_bunny_mesh_1k.txt -size 200 200 -output output3_04.tga -gui

raytracer -input scene3_05_axes_cube.txt -size 200 200 -output output3_05.tga -gui

raytracer -input scene3_06_crazy_transforms.txt -size 200 200 -output output3_06.tga -gui

raytracer -input scene3_07_plane.txt -size 200 200 -output output3_07.tga -gui -tessellation 10 5

raytracer -input scene3_08_sphere.txt -size 200 200 -output output3_08.tga -gui -tessellation 10 5
raytracer -input scene3_08_sphere.txt -size 200 200 -output output3_08.tga -gui -tessellation 20 10
raytracer -input scene3_08_sphere.txt -size 200 200 -output output3_08.tga -gui -tessellation 10 5 -gouraud
raytracer -input scene3_08_sphere.txt -size 200 200 -output output3_08.tga -gui -tessellation 20 10 -gouraud

raytracer -input scene3_09_exponent_variations.txt -size 300 300 -output output3_09.tga -gui -tessellation 100 50 -gouraud

and with the OPTIONAL specular fix:

raytracer -input scene3_10_exponent_variations_back.txt -size 300 300 -output output3_10.tga -gui -tessellation 100 50 -gouraud 

and with the OPTIONAL specular fix:

raytracer -input scene3_11_weird_lighting_diffuse.txt -size 200 200 -output output3_11.tga -gui -tessellation 100 50 -gouraud

raytracer -input scene3_12_weird_lighting_specular.txt -size 200 200 -output output3_12.tga -gui -tessellation 100 50 -gouraud

and with the OPTIONAL specular fix:

See the main Assignments Page for submission information.