CSCE 441: Computer Graphics |
Fall 2017 |
Assignment 4: Polygon Rasterization [150 points]Due 11/1/2017Purpose:This assignment is designed to help you understand the complete polygon rasterization process. In particular, you will implement simple projection into 2D screen space, lighting/shading calculations and hidden surface removal. Description: In this assignment you will write a program that reads in a common 3D model format and displays the surface on the screen using 3 different shading models. We will assume that you have a working 2D scan converter from Assignment 2. If not, you may use this simple scan converter I wrote. You will NOT be using OpenGL to perform polygon rasterization, lighting calculations, transformations or hidden surface removal. For the purposes of this assignment, you do not need to worry about any of the view transformations. That is, you can assume that no transformations are required, and you can perform your lighting calculations directly on the 3D positions. We will assume that the viewer is infinitely far away (orthographic projection) at [0, 0, -infinity]. Therefore, to project the polygons onto the screen, you simply need to remove the z-coordinate. You can assume that the projected x,y position of the vertices of the triangle will be in the bounding box [-1,-1] (lower left), [1,1] (upper right). You will need to transform these coordinates into window coordinates ([0,0], [w,h]). Furthermore, you do not need to worry about clipping or performing perspectively correct interpolation (viewer at infinity) either. Note that because we limit the primitives to triangles, your scan-conversion process can be simpler than a general polygon scan-conversion routine. The scene itself will be specified with an ambient light amount of [.5, .5, .5] and an infinitely far away light source, which is emanating light in the [-1, -1, 1] direction and has an intensity of [1, 1, 1]. Finally, the object should have an ambient reflection coefficient of [.1, 0, 0], a diffuse reflection coefficient of [.7, 0, 0], a specular reflection coefficient of [.5, .5, .5] and a specular exponent of 5. The surface will be specified using a simplified version of the OBJ file format. The file is a text-based, format where each line either starts with a
Here are some example surfaces for you to try out: cube, sphere, cow, cube2. Cube2 should show obvious differences between the 3 shading algorithms. Here is what they should look like with a few of the rendering methods: box flat, sphere flat, sphere Gouraud, cow flat, cow Gouraud, cube2 phong. You should write a program that:
[10] Correctly loading obj file [10] Correct calculation of normals [10] Projection of vertices and transformation into window coordinates [20] Correct lighting calculations [20] Flat shading [30] Gouraud shading [30] Phong Shading [20] Z-buffer for hidden surface removal |
|||