Submission deadline: 1/11/17.
In this homework we will implement a simple raytracer using open source libraries. In particular you will implement
You have to implement the functions provided in the
raytrace.cpp file. As a suggestion, we left the signature of the functions used to generate the solution available. You can change the code structure if you prefer though. To build the application we will use the Yocto/GL library, and in particular the following files:
The code can be compiled with cmake which, for OsX, is shown in the scripts
xcode.sh. CMake will generate project files for different build systems including Makefiles, Xcode and Visual Studio.
This repository contains also various tests that are executed from the command line as in
run.sh. The images generated are written to the
out/ directory. Your results should match the images in the
You have to complete the following tasks:
make_bvh(), add shapes with
add_XXX_shape()and instances with
add_instance(), and finally build the accelerator with
samplestimes for anti-aliasing. Write a camera ray generation function.
ksfor specular and
auto ns = (mat->rs) ? 2 / (mat->rs * mat->rs) - 2 : 1e6f;for the specular exponent.
ke > 0and are made of points.
ks_txtusing bilinear interpolation. Multiply the values of
ksby the texture lookups if present.
mat->opacityand, if the object is not opaque, recursively call the shading method for a ray that starts at
posand continues along the camera ray, to pick up the color of the background. Scale the value of this last ray by
As extra credit, you can implement the following functions.
kdto get a better effect. Submit a new image for this.
To submit the homework, you will use a form indicated on the Google Group where we report first and last name, email, student id (numero di matricola) and you will upload a ZIP file containing the results. In the ZIP file you are to include only your code in and the images generated by your code. This means that your ZIP file will only include the
out/ directories. You have to name your file
<numero_di_matricola>.zip and exlude all other directories.