Computer Graphics Lab 2


Ray casting: You are given a functioning ray casting program which only computes the ambient light of the visible object at each pixel. You are task is to add the missing code to add the diffuse and specular component of the direct illumination.

These two images show the before (ambient) and the after (ambient, diffuse and specular):



or like this if you are running it on a SUN (or other machine with only 8-bit graphics)

The code can be here are a ZIP file of the code. Under Linux, please copy all the .h/cpp  files to your home directory, as well as simplescene.dat and the makefile. Under Windows, just load the question.sln into MS Visual Studio. Compile the code, and then run it by executing it with question.exe < simplescene.dat . Note that under Windows, it is important to have the scene file and the executable in the same directory.

The part of the code you must edit is in litscenecene.cpp, in the method calculateColour ("Your code here!"). You should experiment with changing the scene structure. Note that the sphere on the left has *only* specular colour. You should think about why it thus looks odd!

 


Finally

The software described here and in the associated directories are for your personal use only, and in conjuction with the coursework for this course.

On no account may they be shown or in any way given to any person not on this course without permission from Anthony Steed.

They may be copied to your personal machine for use at home, without requiring permission.

On no account may any aspect of the software be used or modified for use for any commercial reason whatsoever.