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 found here (also here are a ZIP file of the code and documentation). Copy all the .java files to your home directory. Also copy the simplescene.dat. Compile the java code, and then run by executing "java SimpleRay simplescene.dat".

The part of the code you must edit is in Scene.java, 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.