$30
CAP 4730 – Assignment 1
Start Early!
First-Hit Ray Tracer
In this assignment you will write a simple ray tracer to render a scene composed of two spheres. The
two spheres are of different radii and colors (e.g., blue and green). Pick the centers and the radii of
the spheres so that they do not intersect in the 3-D space.
For simplicity, you may assume a directional light and a parallel view for rendering purposes.
This means that a single LookAt vector can be used to generate all rays. For example, you may set
the LightDir = (0, 1, 0) and LookAt = (0, 0, −1).
• Download and setup the CImg library from http://cimg.eu/. Write a simple program to
display an RGB image. Fix the image resolution (e.g., 256 ×256) and verify the correctness of
your program by displaying a test image that you generate (e.g., color stripes). You will use
this program to display the results of the ray tracer you will be implementing next. 20pts
• Generate parallel rays and solve the ray-sphere intersection problem to determine the color
of each pixel. Verify the correctness of your ray tracer by rendering the scene from multiple
angles (e.g., change the LookAt vector). 30pts
• Add ambient, diffuse and specular shading to your ray tracer. Pick the ambient, diffuse and
specular constants and light intensities to reflect a realistic rendering of the scene. 30pts
• Bonus point: Add a tetrahedron to the scene rendered above and discuss (in the report) the
effect of the tetrahedron on the performance of the ray tracer. +20pts
Submission: Along with your source code and makefile, submit a report (a PDF document) that
describes and documents your experiments for each step of the assignment. 20pts
While the discussion of ideas with classmates (e.g., via Canvas Discussion Forum) is encouraged,
coding and writing the report for this assignment must be your individual work. In particular,
assistance of the form of copying code, reviewing code or design, joint development or debugging,
use of public resources (e.g., web) for assignment-specific code is not acceptable. Whenever such
resources are used (e.g., libraries for peripheral parts of the assignment, or people consulted), they
need to be clearly acknowledged. Submit to E-learning site a single file as a .zip, .tar or a .tgz
bundle that contains all the files to be submitted. Include your written programs in the submission
bundle and have a README file that has sufficient instructions on how to run your programs.
1