

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CSC 461 Oct 2008 Assignment 2
A Rendering Comparison Due: end of Monday, November 17
Learning Objective: In this assignment you will learn to render a polygonal model using both OpenGL and ray casting, and compare the two.
Input: This assignment will accept as input three types of ASCII files.
The first file is called the view file. It describes the viewpoints of the images you must generate. It takes the following format:
Format: Example: eyeX eyeY eyeZ 0 0 - ctrX ctrY ctrZ 0 0 0 upX upY upZ 0 1 0 width 512
where (eyeX,eyeY,eyeZ) is the location of the eye, (ctrX,ctrY,ctrZ) is the point at which the eye is looking, (upX,upY,upZ) is a vector describing the direction that is “up” in the image, and width is horizontal extent of the display viewport in pixels. The viewing frustum should always be centered around the line from the eye toward the ctr point with field of view of 90 degrees and an aspect ratio of 1. Clipping planes should always be set to extend from the eye to “back” of the model (only clip what is “behind” the eye). The example above describes a viewpoint looking the positive Z direction toward the origin. This example should be the default view, should no view file be named on the command line.
The second file is called the world file. It lists the collection of models that make up your scee. We assume that you have already transformed all models in this file into world coordinates during precomputation. It has the following format:
Format: Example: filename1 cylinder.obj filename2 sphere.obj
Here, filename is the name of the object file (more on that soon) describing one of the objects to display. By default, you should use the world file provided by our TA, which names only a simple cube.obj file.
The third type of file is called an object file. This sort of file contains descriptions of a single object’s vertices, triangles and colors (you may assume that all polygons are triangles). We will use the obj format. See the class wiki for details on this format, and pointers to source code for reading it. We encourage you to use this source code.
Your program should assume the first two input files are called world.file and view.file. Object files are referred to only in the world file.
Output: Having loaded all these models into memory, you will use both OpenGL and ray casting to render them in perspective. Initially, show only the OpenGL rendering. Whenever the user presses the “r” key (for rendering), switch to the other rendering.
For the OpenGL rendering, simply render each triangle as you rendered triangles in the first assignment. However, make sure you use a perspective projection that reflects the input view. Your renderer should use Phong illumination and switch between flat (one color per polygon) and Gouraud (fragment colors BILERP’d from vertices) shading when the “l” key is pressed. Use Z buffering. You may ignore any vertex normals and texture, but use the colors define in the obj’s accompanying “mtl” file.
A ray caster is a ray tracer without any reflection, refraction or shadow rays. Intersect the ray from the eye through each pixel with each triangle to find the closest ray-triangle intersection point. We highly recommend that you use existing ray-triangle intersection code (e.g. graphicsgems.org or realtimerendering.com/intersections.html). Color each such point using Phong illumination and flat, Gouraud or per-pixel lighting (switch between these when the “l” key is pressed). For Gouraud shading, you will have to light the vertices, project the triangle into image space (you may use rays cast through the vertices if you like) and BILERP.
Mechanics: Our TA will eventually provide you with a few example input files, and resulting imagery.
Submission: Please submit the following files through WolfWare (Assmt2): All your source code. Executable of your code. Readme.txt (Including your name and your unity id, everything that I need to know about your program (how to run it, how to interact with it). Also, please write down what is working, and what is not working.) Your input files. (your view file, world file, obj files)