Raytracer demo

Raytracer screenshot

Here you can find a small, simple ray tracer in Java for demonstration purposes. I created seven different versions, each with a new feature, to illustrate how these features can be successively integrated into the ray tracing code. These versions are:

  1. rendering a red sphere without any lighting
  2. additionally: rendering four walls, floor and ceiling
  3. additionally: Phong lighting
  4. additionally: sphere casts a shadow
  5. additionally: sphere has reflectivity
  6. additionally: floor and ceiling have textures
  7. additionally: multithreaded rendering
  8. additionally: marble-like procedural texture for the sphere (using Perlin noise, real performance killer, but looks nice)

Note that this raytracer was not created to be efficient - otherwise, I would not have written it in Java in the first place, since Java is a poor choice for a fast raytracer because many small objects have to be created, which is not something that Java handles well. This raytracer was created merely to illustrate the basic ideas behind raytracing and how to implement them.

Resources

Picture gallery of different versions
Interactive demo (Java applet)
Code and compiled class files (.tar.gz, 2.7 MB)
Executable JAR file (2.7 MB)