Ray Tracing

In this project, you will work on a simple ray tracer.

 

  1. You are asked to implement all of the following features:

 

l  Add a (point or directional) light source and a diffuse component to the lighting model.

l  Add a new kind of object – your choice – to the scene

l  Add reflection

l  Cast shadow rays to make shadows

 

  1. If you implement one of the following additional features, you get extra credits.

l  Add refraction

l  Add texture mapping

l  Ray tracing acceleration techniques such as space subdivision

Starting off

Here are the files to make a primitive raytracer that are zipped together along with this file:

  • raytrace.h
  • lowlevel.h
  • raytrace.c
  • tracer.c
  • shader.c
  • lowlevel.c

When you compile it, you should get an executable that draws a picture of a dark red circle on a black background: a ray-traced picture of a red sphere in dim ambient light.

The simple ray tracer casts a ray through every pixel in the image plane. The image plane lies in the plane z=-1, and the viewpoint is at the origin. The sphere you see is centered at (0,0,-2) and has radius 1.

The raytracer uses OpenGL only to put up a window; it draws an array of pixels into the window, and YOU are responsible for coloring the pixels one by one to make the image. The function drawPixel writes single pixels to the array.

Latest Assignments