Thanks, movax. Yes, please do play with the code all you want!
I *really* like the idea of simply adding an additional photo-realistic rendering mode (analogous to P3D or OPENGL) that just renders whatever you've thrown onto the list with beginShape(). And it looks like Mark Chadwick has integrated the amazing Sunflow renderer with processing in a somewhat similar manner already:
http://hipstersinc.com/p5sunflow/
Sunflow Gallery: http://sunflow.sourceforge.net/index.php?pg=gall
You're right that my code is hard-wired for spheres and planes, and though raytracing arbitrary polygons isn't so bad (adding ray-triangle intersection may, in fact, be just 10 lines
), the dirty secret is that as you add more complex geometry with nooks and crannies, many more photons may be needed to get the lighting correct. The key to the speed here is simple shapes and few photons, so I'd have to play around and see how my code scales to more complex scenes.
Thanks for the feedback -- no immediate plans, but I'll let you know if I push in this direction. If someone else wants to give it a shot, I'd love to see it.