Submission: Submit your assignment using Wolfware Classic. Remember that 10% of your assignment grade is for correctly submitting your work! For more information about how to correctly submit, see this post on the class website.
The submit locker is now available at: http://courses.ncsu.edu/csc561/ . Click on "Submit Assignments" next to "Grade Book".
Goal: In this assignment you will practice the ray casting methods that we are discussing.
BASIC GRADING:
- 10% Part 0: properly turned in assignment
- 40% Part 1: using ray casting, render the triangles in the obj file in white
- 50% Part 2: color the triangles with Blinn-Phong illumination
- Participation: You can receive participation credit (outside of this assignment) for posting images of your progress, good or bad, on the class forum!
General:
Obj is a 3D modeling format in widespread use, originally designed for the Alias modeling software, now Maya. You can find details on obj in our course wiki, including format, sites with free models, and parsing code that you should feel free to use. You will not need parse the complete obj format for this assignment: only those parts that describe triangles and the vertices they contain, as well as vertex locations, colors and normals. If you wish to build your own models, you can download Maya and Max for free through the university. Both can output directly to obj, and you can read and edit obj easily in any editor. Here is a simple example obj file describing a cube, here is its material.
All vertex locations should be described in world coordinates, meaning they do not require any transformation. Locate the eye at (0 0 -2), with a view up vector of [0 1 0] and a look at vector of [0 0 1]. Locate the front clipping plane a distance of 1 from the eye, and the back clipping plane a distance of 3. You may assume that the viewing window is a 2x2 square centered on the front clipping plane, and aligned with world the coordinate axes. With this scheme, you can ensure that everything in the world is in view if it is located in a 2x2x2 box centered at the origin. Use perspective projection. Put a white (1,1,1) light at location (0,5,0).
You may make your interface window only 256x256 in size. This will speed testing of your ray casting. We will test your program with the test cube, as well as several other obj files, some of which you can find here, others which you cannot.
We provide a small shell in which you can build your code, and an executable showing a good solution. The shell shows how to draw pixels without using WebGL or OpenGL. Note that your ray caster need match the solution closely, but not exactly.
Part 0: Properly turned in assignment
It is challenging to return grades promptly in a class of this size, particularly if files turned in are not well standardized. Our TA will define proper turnin very precisely; turn in as instructed or you will lose points.
Part 1: Using ray casting, render white triangles
Use ray casting to render filled white triangles. Feel free to use intersection code you find on the net (though you should cite it). You needn't do any depth testing however, since everything is still white.
Part 2: Using ray casting, render lit triangles
Now you will have to examine the depth of each intersection, and if it is the frontmost, perform a local lighting calculation. To perform that lighting calculation, you may either perform an edge based interpolation of the normals as we discussed in class, or use the barycentric weights you generated in the intersection test for that triangle. Don't forget to normalize the resulting vectors, and recalculate the local light vector! You should see an image showing triangles with the same outline and occlusion as the previous part, but with better looking colors.
EXTRA CREDIT GRADING:
- 2.5% arbitrarily sized images (and interface windows)
- 2.5% arbitrary viewing setups
- 5% multiple obj files and arbitrary modeling coordinates
- 5% off-axis and rectangular projections
- 5% multiple lights at arbitrary locations
- 10% shadows during ray casting
Extra credit: Arbitrarily sized images and interface windows
Read in an additional window.txt file that in one line, lists the width and height of the interface window. Size your interface window to match, and change your ray casting interpolation to match. This should effect every part of your assignment.
Extra credit: Multiple obj files and arbitrary modeling coordinates
Read in an additional world.txt file that on each line, references an obj file and its associated modeling transform. Read in, transform and display all the named obj files before rendering them. This should affect every part of your assignment.
Extra credit: Support arbitrary viewing setups
Read in an additional view.txt file that lists the eye's location, the view up, and the look at vectors, each on a different line. Reorient the window to be normal to the look at vector (in OpenGL this will happen automatically, but not in ray casting). Render the scene with these viewing parameters. Note that with bad viewing parameters, you will not see the model. This should affect every part of your assignment.
Extra credit: Support off-axis and rectangular projections
Read in an additional project.txt file that lists the viewing window's top, right, bottom and left Y, X, Y, and X coordinates (four numbers) on one line. Adjust your ray casting interpolation to these new coordinates. Render the scene with these new projection parameters. Note that if you also perform the arbitrary viewing extra credit, these coordinates may not be in world space! Also with bad projection parameters, you will not see the model. This should affect every part of your assignment.
Extra credit: Multiple and arbitrarily located lights
Read in an additional lights.txt file that on each line, describes the location and color of a light (use one triple for a light's color, with its ambient, diffuse and specular colors the same). Render the scene with these lights. In ray casting, you will have to sum the colors all the lights. This should affect the last two parts of your assignment.
Extra credit: Detect shadows during ray casting
When performing lighting during ray casting, shoot an additional ray toward the light to decide if only ambient light reaches the intersection. If you also support multiple lights, make sure to shoot a ray at each light! This should only affect the last part of your assignment.