The Assignment

rasterized teapotFor this assignment, you will be rendering rayshade .ray files to ppm using barycentric triangle rasterization and z-buffering. You should at least be able to render the teapot.ray file with Blinn-Phong shading and interpolated normals. You can use your own code or provided solution code from any prior assignment. You can use the glm library if you choose, but no other external libraries. Do your work in the raster directory that has been created for you in your git repository. You should take a single rayshade file as a command-line input, look for that file in the project data directory, and create the ppm result file in the project build directory.

Transformations

Points in the rayshade file are provided in world space. Construct a combined RasterFromWorld matrix to transform those points into raster space for rendering.

Leave the lights and normals in world space. To find the world-space surface position to compute the light and view vectors (as normalize(light-position) and normalize(eye-position)) you can either tranform the raster-space point through the inverse of the RasterFromWorld matrix, or do an interpolation of the world-space vertex positions using the barycentric coordinates computed for rasterization.

Triangles

The teapot.ray file uses the polygon and triangle keywords for primitives. The polygons in this file are all convex quads given by four vertex positions. You should split each of these into two triangles for rendering, using the polygon normal for lighting calculations. The triangles each have three vertices and three normals. Interpolate the per-vertex normals across the triangle using the same barycentric coordinates you compute for rasterization.

triangle surface v0x v0y v0z  n0x n0y n0z  v1x v1y v1z  n1x n1y n1z  v2x v2y v2z  n2x n2y n2z

Lighting

Use the same local Blinn-Phong with diffuse equations from assignment 2, but without the reflection term. Lighting computations should be done in world space and should use the interpolated normal and world-space positions of the pixel, lights, and eye.

634 only

rasterized treeTriangulate any sphere and cone primitives in the ray file, so you can render tree.ray. Provide appropriate per-vertex normals for smooth rendering. Cones are are given by two points on the cone axis along with the radii of the cone at those two points:

cone surface r0 x0 y0 z0  r1 x1 y1 z1

Note that base plane of sample tree image will only render correctly if you also do the clipping extra credit. If you are not doing this extra credit, you can either leave it with the incorrectly rendered green plane, or remove the polygon line from the tree.ray file.

Extra Credit

clipped teapot435 and 634: For up to 10 points of extra credit, implement near-plane clipping using the Sutherland-Hodgeman algorithm. Include a modified rayshade file with the view changed to demonstrate your successful clipping. You can add a near-plane distance command line parameter or line in the rayshade file to be able to move the clip plane away from the viewer to make it easier to see and debug. For example, this example image has a near plane distance of 8.

435 only: For 10 points of extra credit, also do the cones and spheres as described under "634 only".

What to turn in

Turn in this assignment electronically by pushing your source code to your class git repository by 11:59 PM on the day of the deadline and tagging the commit assn6. Do your development in the raster directory so we can find it.

Also include an assn6.txt file at the top level of your repository telling us about your assignment. Tell us what works, and what does not. Also tell us what (if any) help you received from books, web sites, or people other than the instructor and TA. Finally, if you did anything toward the extra credit, be sure to tell us about it in this file.

You must make multiple commits along the way with useful checkin messages. We will be looking at your development process, so a complete and perfectly working assignment submitted in a single checkin one minute before the deadline will NOT get full credit. Individual checkins of complete files one at a time will not count as incremental commits. Do be sure to check in all of your source code, but no build files, log files, generated images, zip files, libraries, or other non-code content.

If you create any additional rayshade files that you would like us to be able to render to demonstrate your work, be sure to commit them in the data directory