Business Card Raytracer in Python

There has been some "hype" around the business card raytracer recently. At least I've seen the link to it/discussions about it popup a lot recently.

I've always been interested in raytracing and 3D rendering but I never really got the grasp of it. Probably because it hasn't ivo3d.pngbeen part of my work or education, just personal interest and fascination.

So I decided to have a look at this minimal raytracer. If it's so few lines of code, how complex can it be? Well, it turns out the dense way in which it has been formatted/coded makes it actually harder to understand than longer code, which was to be expected. Fortunately, Fabien Sanglard has done a terrific job reverse engineering/documenting the code.

Based on this code I managed to create a python version of the raytracer, which can then be used to do further experiments and analysis.

I've created three different versions:

This version aims to be as small/compact as pisslble (smaller than the C version). It won't fit on a business card though. Please don't judge me by this code and don't take this coding style seriously :)

This version aims to be as close to the original C version without Python "compacting", in line with Fabien Sanglard's reverse engineered code/annotations

This version aims to make the code more pythonic, friendly and understandable.

If you run any of these versions, please use pypy or it will take ages (well, hours)


Last updated Sept. 25, 2013, 4:14 p.m. | filed under python | C python raytracing pypy
comments powered by Disqus