This Raytracer project shows 3 spheres. The green sphere is partly inside the blue sphere! ** Use Turbo Mode (<Shift> key + Green Flag) Press <1> to see the picture in finer resolution Press <5> to see the picture again in lower resolution A "Ray Tracer" traces rays from the viewer through each pixel on the screen and calculates which object it hits first in 3D space (ie. which object is closest). The pixel is coloured with the colour of that object. More advanced Ray Tracers add different types of lighting, shadows and reflections of other objects. They also include not just spheres (which have easier math) but other 3D objects. The lighting is made up of 3 components: - Ambient Light - general background reflected light that even gets into dark places such as under a bed - Diffuse Light - sphere lighting that is stronger if the light shines more "straight on" towards the sphere. (Diffuse Light Intensity does not depend where the viewer is) - Specular Reflected Light - the highlight produced when light is reflected off a sphere almost directly towards the viewer. I worked out the following math with pen and paper: - where a ray from the viewer intersected each sphere (I used a parallel projection to keep the math simpler) - the angle between any 2 normalized rays/vectors (I drew a picture and used trigonometry rather than just using the dot product) - the angle of a light ray reflected off the sphere (I drew a picture and used trigonometry) Writing the project would have been quicker if I had used existing formulae rather than "doing the math".