Lab 4b

Ray Tracing

Due: Sunday, Jan 20th 2018, 23:59


Individual Effort:

No team participation is really encouraged in the case of the homeworks or the labs. If you need to use code you found online, you need to (1) check with us whether this is ok, (2) clearly mark it and (3) mention it in the readme file of your submission. If you fail to do one of these, it will be treated as academic misconduct.

Late Submission:

Don't get behind in the lab assignments - always start early!
In this course you will have a total of 4 (four) grace days that you can distribute however you like. See here for more information on grace days.

Forum:

There is a forum at Moodle. (Note: Please make use of the forum. Help each other, but don't copy homework!)

Objectives:

  • To develop a ray tracer.
  • To understand ray tracing and implement a ray tracer!
  • To understand texture mapping
  • To create some nice color images and beautiful scenes

In this lab you are writing a ray-tracer. After some basic features you will extend it to include some interesting effects. You should not use any OpenGL/WebGL in this assignment. You can use any programming language you want, as long as your programm compiles and runs on the lab PCs (Ubuntu) without installing additional environments (This should work at least with Java and C++).

Hint: We all love JavaScript, but writing a ray tracer with it is not the best decision. Unless you have a lot of time...

Submission Guidelines

Your project must build and run on the Ubuntu environment on our lab PCs. You must not submit prebuilt binaries. Your project should compile and run on the lab PCs without errors and without requiring extra configuration. Make sure to submit all the required files and to test it in time! A program that fails to compile will receive 0 points. No exceptions.

We encourage you to use either make or CMake to build your application. Make sure to keep your build system simple! It should only be a simple >>make (or similar) for us to build the project. We are not going to set up complex and weird build systems and spend 30 minutes to build your project.

If you have very good reasons to not use either make or CMake, make sure to document how to build your project. But it still should not be more than 1 or 2 simple commands!

Be sure to submit any comments or remarks in a 'readme.txt' file.

Submit your files on Moodle.

A word of Warning:
We will NOT (under any circumstances) accept submissions that do not compile and run on the lab PCs. Please test your submission on one of the lab PCs before you submit it. Check also that you included everything to compile your project. There will be absolutly no exception.

Scene files
Your raytracer has to be able to read in every file in the format specified here. You can implement this by allowing your program to accept a file path as an input parameter or by implementing a file picker or by letting the user type in a file path during the runtime of your program, BUT having file paths hard coded in your program and letting the user choose one or more scenes within a predefined set of scene files is NOT an option!

Tasks:

(80%) Required Tasks

  • (10%) Parse and raycast triangles (meshes read from obj files).
  • (10%) Add Shadows (example3.xml)
  • (10%) Implement basic reflection (perfect specular - example4.xml, sphere in the back on the left)
  • (10%) Implement basic refraction (perfect specular - example4.xml, the other two spheres)
  • (20%) Add basic (color image) texture mapping for spheres and triangles. This requires the functionality to read .png files (example4.xml)
  • (20%) Add object transformations (translation, scaling, rotation) (example5.xml)

(20%) Effects
Pick up to 20% from the following effects:

  • (5%) Bump mapping. (Effect name: bump)
  • (10%) Environment mapping with image based lighting. (Effect name: env)
  • (5%) Anti-aliased textures. (Effect name: anti)
  • (10%) Motion blur (on the moving objects, not the whole image). (Effect name: blur)
  • (10%) Depth of field & real camera lense. (Effect name: dof)
  • (5%) Area lights & soft shadows. (Effect name: area)
  • (10%) Proper reflection/refraction (based on Fresnel's + Beer's law) (Effect name: fresnel)
  • (5%) Spot light sources. (Effect name: spot)
  • (10%) Implement the Cook-Torrance shading model. (Effect name: cook)
  • (10%) Create scripts to enable simple animations. (Effect name: anim)

(10%) Bonus
We will assign bonus marks up to 10% for either:

  • very creative scenes (with sophisticated geometry)
  • close to photo-realistic scenes (with great lighting effects)
  • implementing a kd-tree acceleration structure using using a sub-O(n^2) building algorithm.
  • ray-tracing Julia sets.
  • implementing path tracing.
  • implement antialiasing using supersampling

Hints and Tips:

You should feel free to design your program as you see fit, however, the following progression will make life easier for you:

  1. Create a valid image. You can use any format you want, as long as it could easily be displayed on the lab PCs. If your programming environment does not support writing formats like PNG or JPEG you can also use the PPM format.
  2. Create a default camera and rays.
    Encode the ray direction as RGB and write it to an image to help debug your ray generation. The following image is an example of what the image should look like (r=x, g=y, b=z).
    Encoded ray directions
  3. Create intersectable surfaces.
    The following images show a reasonable progression. In the first image, white is a positive sphere intersection test. In the second image, the sphere is shaded based on the normal at the intersection point:
    Sphere intersection test Sphere normals encoded as RGB colors
  4. Implement simple materials such as a perfect Lambertian (as used for the bunny).
  5. Implement the full Phong illumination and shading.
  6. Create a scene which contains multiple objects/lightsources.
    Sometime during this step a scene file parser should be created.
  7. Add shadows.
    A scene with two light sources casting shadows:
  8. Implement camera and object transformation.
    A camera transformation.
  9. Implement effects.
    In this specific case it is a simple reflection.

In general, some useful hints to observe:

  • Use visual debugging by encoding data to RGB and outputting to an image.
  • There are two tactics to perform transformations: Transform the rays or transform the objects. If you choose to transform the rays remember that you must use the inverse transformations!
  • To transform the normal correctly, the transpose of the inverse transformation matrix must be used.
  • Calculate the inverse transformation matrix as you receive the transformations.
  • Some useful sites to get you started:
    Constructing eye rays
    Intersection routines
  • While we are providing some very primitive shapes. I am encouraging you to create your own, more interesting shapes in a modeling program, such as the open source Blender.

Input Files:

Your raytracer should be able to read our xml based input file format:
Input file specification

The following input scenes will be used to grade your submission, so make sure that they are displayed correctly.

Download example scenes

Grading Criteria

Grading the labs will be based on the following:

  • 80%: Correctness and adherence to assignment specification.
  • 10%: Readability and structure of code, use of comments, indentation, etc.
  • 5%: Efficiency and speed (only an issue if its very inefficient)
  • 5%: Adherence to lab procedures (submitting, naming conventions, etc)

In order to get a full mark, you need to do all of the assigned tasks AND adhere to to lab procedures while creating readable and efficient code. I.e. if you accomplish only 70% of the tasks correctly, but you do not adhere to lab procedures, your final mark will be 70*(1-0.05) = 66.5%.


Last modified: September 29, 2018
Manfred Klaffenboeck / manfred DOT klaffenboeck AT univie DOT ac DOT at