» Software » Mediumpt - ray & path tracer 

Mediumpt - ray & path tracer

Image formation is a very interesting matter, when investigated to a certain extent: the understanding of how light rays bounce forth and back improves, as well as how material surfaces react to light. There exist dozens of rendering programs allowing to produce decent and realistic images, however, I have recently discovered a very interesting path (ray) tracer, which does not only provide extremely realistic images, but is also astonishingly lightweight (99 lines of C++ code!). This path tracer is  smallpt of Kevin Beason.

I have done some modifications to it, and have called it mediumpt:

  • written in C89 in place of C++;
  • compiles out-of-the-box under Windows with Visual Studio 2008 (VC9);
  • multithreading added explicitly;
  • periodic dumping of the rendered image in BMP/PNG/PAM format;
  • exposure control before clipping and sRGB encoding;
  • added plane, disc, cylinder, cone, triangle and quadrangle primitives;
  • added ambient occlusion with active lighting from cubemap;
  • added depth of field;
  • mixed materials (specular/diffuse) and custom refractive index;
  • procedural diffuse and specular surface colors;
  • tentatively added mesh rendering and reading from polygon files.

Below you find some images obtained after some hours of mediumpt rendering on an Intel Core i7-3630 QM 2.4 GHz CPU, exploiting 6 concurrent threads.

Original scene rendered at 2048 samples/pixelHemi light  
Some images rendered by the tracer. From left to right, top to bottom: original scene of smallpt at 2048 samples/pixel; new scene with an hemispheric light source and a magenta sponge ball; same new scene with a pink glass ball and a magenta marble; scene with all the geometric primitives implemented by now; basic volumes with Lambertian surface; mix of Lambertian and specular (sort of ceramics, isn't it?); depth of field and caustics; procedural diffusion and specular maps with u-v texturing on spheres (Earth, Moon, Mars, Mercury, Venus, and Saturn)

Download and installation instructions

The source code can be downloaded from here (choose the archive with the highest numbered version, currently v20)

Currently, the program can be compiled only using Microsoft Visual Studio: the solution and project provided in the compressed archive are for MS Visual Studio 2008 (VC9), but it can be imported also in later versions (e.g., 2013). The program uses some external libraries for image loading and saving, namely libpng, jpeglib, and zlib, which are already provided as static objects in the archive.

As you will notice, the documentation is extremely poor, but it should not be difficult to understand how the program works and how can it be modified to render your very own scene.

The program is licensed under the MIT license, which is open and compatible with the GPL.

Last update: 2016-05-28, 11:44:46