Card Path Tracer

Published by

on

Some time ago I came across an excellent analysis of Andrew Kensler’s minimal ray tracer (a.k.a the business card ray tracer) whose entire source code could fit on the backside of a business card. The output is shown below:

minray
Taken from here.

Being stuck at home, sick with a debilitating cold, I thought I’d have a go at building my own business card ray tracer. From the onset, I opted for a path tracer rather than the Cook-style distributed ray tracing approach seen in Kensler’s renderer. Starting from scratch and developing everything from first principles, it took 5 to 6 hours of coding to get to the image below. Admittedly, in my version there is none of the clever stuff that made the original so damn good.

kbII
Business Card Path Tracer output at 256 samples per pixel

The program is almost twice the size of Kensler’s ray tracer … so probably, unless your business cards are the size of an iPad, you won’t have much luck fitting the path tracer on their back.

code

There’s still some cruft to be removed from the source code – towards the end, I seemed to be caring less about making the program as compact as possible and more about getting it over with. I can certainly shave off a good deal of space by simplifying the scene to just the ground and lettering. I will have to revisit it eventually. Soon. Hopefully. The source code is available on GitLab and Pastebin.

The slideshow below shows some variations in the lettering I experimented with during the development of the BCPT.

This slideshow requires JavaScript.

 

EDIT: I hadn’t thought about it at the time, but one could easily encode the source into a QR code and put that at the back of the business card:

Leave a Reply

Previous Post
Next Post

Discover more from Probably Works

Subscribe now to keep reading and get access to the full archive.

Continue reading