This is ScalaRay, a ray tracer written in Scala 2.8. It is based on pbrt, the ray tracer described in the book Physically Based Rendering - From Theory to Implementation by Matt Pharr and Greg Humphreys, publisher: Morgan Kaufmann, ISBN: 0-12-553180-X; second edition ISBN: 978-0-12-375079-2
Note: The second edition of this book came out in July 2010. I initially based ScalaRay on the first edition, but I now also have the second edition and parts of ScalaRay are based on pbrt version 2.
I wrote ScalaRay because I wanted to learn the Scala programming language by doing a larger project. Note that ScalaRay is not intended to be production-quality software; it is an educational hobby project, it is not complete and not optimized for speed.
I've been interested in 3D computer graphics for a long time. I wrote my first ray tracing program in C on the Commodore Amiga, inspired by a German book (Amiga 3D-Grafik und Animation, by Axel Plenge, ISBN 3-89090-526-9). That was in 1988. I remember writing a ray tracer in Turbo Pascal a few years later on my first MS-DOS PC.
To compile and run ScalaRay, you need:
After installing the JDK and Maven and adding their
bin directories to your
PATH, you can compile it with:
If you have compiled ScalaRay successfully, run it with:
scala -cp target\classes org.jesperdj.scalaray.Main
ScalaRay is not as complete as the original pbrt. Here is a list of things that need to be fixed, enhanced or implemented, in no particular order.
- make it possible to sample area light sources with stratified sampling; not only with Latin hypercube sampling
- is it worth it to have a mutable variant of class Spectrum? (call it SpectrumBuffer, for example; add implicit conversion SpectrumBuffer -> Spectrum)
- implement accelerators (bounding volume hierarchy, kd-tree, grid)
- implement triangle mesh, loop subdivision surface, height field
- implement Sphere.sampleSurface
- implement reflection models, materials, texture (see book chapters 9, 10, 11)
- complete DirectLightingSurfaceIntegrator (reflection and refraction)
- implement other samplers (see book chapter 7)
- implement other light sources: texture projection light (13.2.2) goniometric diagram light (13.2.3), infinite area light (13.5)
- implement output to EXR format (high dynamic range)
- tone mapping (see book chapter 8, only in first edition)
- implement other surface integrators
- implement volume integrators
- implement other cameras (see book chapter 6)
- create unit tests (with ScalaTest)
- profile, optimize speed (at the moment I haven't found a profiler which works well with Scala)
- better concurrency
- DSL for scene definition (use Scala's parser stuff)
- add features that are not in pbrt (iso-surfaces ("blobs"), for example)
- pbrt has no shadow ray caching; investigate if this is worth implementing
- subsurface scattering