kybernetikos edited this page Dec 7, 2017 · 25 revisions

ScalaTrace is a simple raytracer written as a way for me to learn Scala. I used the book Programming in Scala and the many helpful resources in the documentation section of the Scala Page. I wrote it for fun over two days and in order to explore some of the features of Scala (hence the extensive use of operator overloading, the low level of test coverage and the not excessive concern with code quality :-). Since I'm still just learning scala, it's quite possible I've not made the best use of various features, or didn't know about a feature that would have made my life easier. Feel free to educate me if you know a better way of doing something.

Rendered Image

Checking out

If you have eclipse with scala-ide and eGit installed (this is a helpful guide to getting eGit working with github), you should be able to check the project out by doing import 'Projects from Git', click Clone... and filling in the url git:// Use the 'New projects' wizard, and import as a Scala project.


You can run the raytracer by running RayTracer.scala as a scala application. It will pop up a window showing the final image, and also write the image to a file: image.png. The data for drawing the scene is read from a text file Scene.txt.

The format generally consists of the object name (e.g. raytracer.light.PositionalLight or raytracer.shapes.Sphere) and then a comma separated list of data points needed to create the object. These are usually vectors, points or colours and so often occur in groups of threes. If you want to be sure what they all mean, you'll need to look in the fromElements method in the object.


There's lots that could be done from adding more shapes and kinds of lighting to adding rays with jitter, and more advanced materials (maybe a proper BRDF). I don't expect to do any more work on this project now since it's given me a good way of getting to grips with Scala, but who knows...


You can contact me at my email address or by sending me a message on github or on my blog.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.