During 1996 I developed a ray tracing program in C for a first-year university subject in computer graphics. I have re-visited the code (wow I've come a long way since uni!) and am about half way through converting it to Java.
Java mightn't run as quickly as raw C, however the conversion of this program to Java provides an exercise in:
The version I wrote in 1996 supports:
There are many features planned in the Java version:
This image sequence tells the story of my original ray tracer's development. As they progress, bugs are removed and new features unravel. These are the images and captions I included in my report.
Many of the irregularities of the images derive from having to write my own image file generator (the Targa format, which is pretty straightforward). My relative lack of programming experience resulted in unnecessary dependencies between the file format, and internal image representation. In the Java version, things are much easier -- I build a raster, create an Image object, then write a file through one of the widely available encoders.
Some of the bugs seen in the C version were also seen in the Java version -- for example, shadow jitter.
First output image - not pretty
Attempting three colours
Moving the camera (actually happened in reverse direction - missed a negative sign)
Much better
Rolling the camera by modifying the up vector
Diffuse shading (whoops!)
Diffuse shading (whoops!!)
Diffuse shading (whoops!!!)
Diffuse shading (whoops!!!!)
Diffuse shading (yeah!!!!!)
Introducing shadow (from the white sphere)
Inverted specular reflections (negative sign) and shadowed jitter (tolerance limit required)
Specular is working, but jitter remains
All better
Different coloured spheres and introducing the plane
Moving the camera to see any reflections (plane goes to infinity)
Hoping to see reflection from the use of k-specular
Using a reflection variable in the texture structure - much better result
Investigating behind the scenes
Rolling the camera - no distortion