Assigned: September 28, 2007
Due: October 12, 2007 11:59 PM
Lab overview: Write a basic ray tracer that can render spheres from an Open Inventor input file with simple illumination.
Objective: Upon finishing this lab, you will learn how to set up a camera and construct render rays from the given viewing parameters; to organize a basic ray tracer that computes a color for every pixel in the image plane; to implement basic ray-object intersection with simple illumination calculation; to create C++ classes that will be used and extended for the remainder of this quarter; to output the ray tracing result to a file that can be viewed later.
Tasks:
1. Modify the Makefile from the sample_read_iv code so that the name of your output will be “rt” (stands for ray tracer)
2. The program usage should be:
rt <input.iv> <output.ppm> <xres> <yres>
where <input.iv> is an Open Inventor file that contains only spheres; <ouput.ppm> is an image file in ppm format; <xres> is the width and <yres> is the height (in pixels) of your output image.
3. Write a ray tracer that uses the scene objects (spheres only) and camera information to generate images
3.1 Ignore any objects that are not spheres in the scene file
3.2 Use the camera defined in the Open Inventor scene file.
If camera is not defined, use the following default:
camera position = (0,0,1)
camera view up vector = (0,1,0)
camera looks at (0,0,0)
camera aspect ratio = 1.0
camera field of view angle = 45 degree
Information about how to retrieve the above information from an Open Inventor file and how to construct your eye coordinate system and rays can be found in the class lecture notes and the lab help page on our class web site.
3.3 objects need to be transformed to the correct positions based on the transformation stored in the Open Inventor scene file. Information about how to do this can be found in the lab help page
3.4 Object colors are defined as the material properties of the Open Inventor scene file. Use diffuse color only. To give a better sense of depth for the rendered objects, use the following simple illumination model:
a. calculate the normal (nx,ny,nz) at the ray intersection point
b. normalize the normal, i.e., (nx,ny,nz) / |(nx,ny,nz)|
c. dot product the normalized normal with a vector (0,0,1)
d. If the value is less than zero, set it to zero
e. scale the object color by this illumination value
3.5 Each component of the object color after illumination calculation should be clamped to [0,1]. Output the image to a ppm file. The ppm file format and how to create the file can be found in the lab help page.
Lab submission
Submit your source code (.C and .h) and Makefile. Do not submit any executable files. Our grader will use the sample .iv files in the Data director of the sample_read_iv folder to test your program. If you have some nicer scene files that you want the grader to use, you can submit them too.
Submit a readme file specifying what are being submitted and how to compile and link your program.
Use the following command on stdsun to submit your lab1
> submit cse681aa lab1 <names of all your files>
Notes about the submit program
The 'submit' program submits all of the files at once, not one at a time, previous submissions for a given lab are completely removed. Or put another way; each time the submit command is issued for a given lab, ALL of the previously submitted files are clobbered.
That means that
> submit c681aa lab1 lab1.c
> submit c681aa lab1 readme
will result in ONLY 'readme' remaining in the lab1 submission
You should do the following:
> submit c681aa lab1 lab1.c lab1.h .... readme
or
> submit c681aa lab1 lab1_dir
Where 'lab1_dir' is a directory containing all of the lab1 files to be submitted, or best of all (for both student and grader) is:
> cd lab1_dir
> submit c561aa lab1 .
Submit will immediately print submission information to the submitter. Use 'man submit' if you have any other questions.
Late Penalty
You should submit your lab on time. We are on a quarter schedule, which is pretty tight. Being late for one lab could affect the time left for you to complete subsequent labs. All labs are due at 11:59pm of the specified due data, and there is a 10% penalty each day for up to 50%. After that, you get zero.
Grading Criteria
Grading of the labs will be based on the following:
• 90%: Correctness and adherence to assignment specification.
• 10%: Readability, structure of code, use of comments, adherence to lab procedures (submitting, naming conventions, etc.)
The grader will grade the labs. If you have problems with the grade you received on your lab, see the grader first. If you can't resolve the dispute with the grader, then see me. However, in order to maintain consistent grading for everyone in the class, I am not very inclined to alter grades that are assigned by the grader.
Don't copy labs. Discussion of lab assignments is allowed and encouraged. However, you need to complete the lab all by yourself. Labs which are too similar will be handed over to the Committee on Academic Misconduct and handled by them.
Last updated: 9/27/2007 4 PM Han-Wei Shen