Java logo

ray tracer

home | software | ray tracer

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.

[one of the first new images!]

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:

Images from 1996

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.

Pic 1 First output image - not pretty

Pic 2 Attempting three colours

Pic 3 Moving the camera (actually happened in reverse direction - missed a negative sign)

Pic 4 Much better

Pic 5 Rolling the camera by modifying the up vector

Pic 6 Diffuse shading (whoops!)

Pic 7 Diffuse shading (whoops!!)

Pic 8 Diffuse shading (whoops!!!)

Pic 9 Diffuse shading (whoops!!!!)

Pic 10 Diffuse shading (yeah!!!!!)

Pic 11 Introducing shadow (from the white sphere)

Pic 12 Inverted specular reflections (negative sign) and shadowed jitter (tolerance limit required)

Pic 13 Specular is working, but jitter remains

Pic 14 All better

Pic 15 Different coloured spheres and introducing the plane

Pic 16 Moving the camera to see any reflections (plane goes to infinity)

Pic 17 Hoping to see reflection from the use of k-specular

Pic 18 Using a reflection variable in the texture structure - much better result

Pic 19 Investigating behind the scenes

Pic 20 Rolling the camera - no distortion