CECS Home | ANU Home | Search ANU
The Australian National University
ANU College of Engineering and Computer Science
School of Computer Science
Printer Friendly Version of this Document

UniSAFE

Computer Graphics

Ray Tracer

In this lab you will extend a simple ray tracing program. This should help you understand what is involved in ray tracing. Also this lab aim to re-enforce your understanding of illumination models.

The program you are given really only does ray casting onto spheres, and it is really a very simple and short program. A lot of the code is dedicated to setting up the juggler and animating it. If you are very keen you are welcome to write your own ray tracer from scratch(something every programmer should do sometime in their life!). You may also change the scene as you see fit.

Step 1 (4 marks)

Obtain a copy of the code. Make a new directory and copy the code into is directory. Compile and run it(java *.java; java RayTracer). The frames are ray caste into a sequence of images, once this is done the sequence is animated.

Read over all the code and attempt to understand what each line does(don't worry too much about 'ballpos' or 'makeScene' in 'RayTracer.java'). You may be asked questions about this when your lab is marked.

Modify the 'raytrace' method in 'Scene.java' such that it's illumination model includes both diffuse and specular reflection. This may be from a single light source. You should adjust lighting parameters such that both the diffuse and specular effects are viewable. Make a note of the formula you used for your illumination model.

Note, you do not need to trace rays to the light sources in this part of the lab. Hence you should not see shadows.

Step 2 (1 mark)

Trace the rays to the light source, this should effect your illumination model and create shadows.

Add two large mirror spheres to the scene. Let these mirrors act as perfect reflectors. Enable rays to reflect off these mirrors a number of times.

Step 3 (1 mark)

Complete one aspect from the following:
  • add a checkerboard pattern floor and a blue sky. You should be able to see shadows on the floor. Also the blue of the sky should change as the angle from the horizon changes.
  • add anti-aliasing - make some comments about the difference this makes.
  • add some type of motion blurring to give the fast moving balls a more realistic look.