SSJX.CO.UK
Content

Porting the Business Card Sized Ray Tracer to the D Programming Language

Introduction

This page details my porting of the Business Card Sized Ray Tracer to the D Programming Language. This started as 1337 byte obfuscated C++ program by Andrew Kensler that Fabien Sanglard deciphered. For more information, see Fabien Sanglard's website here:

Porting to the D Programming Language

Most of the changes were similar to those done for the Path Tracer, click here to visit that page!

Final Result

I changed the text from the original and C++ version...


This took 22,062ms to render...
(512 x 512 with 64 rays per pixel)

Download

To keep the download size small, this is provided as a 7zip archive. Archive includes the compiled exe and source.

⚠️ If you get a message about missing msvcr120.dll or vcruntime140.dll (or similar), you need either the Visual C++ Runtime 2013 or Visual C++ Runtime 2015-2022 from Microsoft installed. You can get them from here. The programs on this page are all 32bit so you will need that runtime even if you are running 64bit.

Benchmarks

As with the Path Tracer, this program benefitted a lot from doing the pixel rendering in parallel. It was almost twice as quick suggesting that the load was evenly spread across my two cores:

Parallel Version : 22,062ms
Standard Version : 40,890ms

This version was compiled using the LDC D compiler as follows: ldc2 -O -i trace.d

Conclusions

A lot of the code for this was copied from the Path Tracer which saved a lot of time and again making use of the parallel foreach loop made a big difference to the speed of the program. The advantages of using D is that I have a program that is fast, memory safe and still easy to understand.

Created 16/02/24