r/tinycode • u/Yeknom • Jan 09 '13
Ray tracer in 140 SLOC of python with picture
I have be playing with raytracing for a while now and wanted to write something that was simple to understand but produced a cool effect. There is defiantly many more features that could be added, like reflections and multiple light sources, but I wanted to stay as minimalistic possible.
Source: http://pastebin.com/F8f5GHJZ
Image: http://imgur.com/prPGk
70
Upvotes
3
u/theinternetftw Jan 10 '13 edited Jan 10 '13
Surprisingly, not using a class for vectors improves runtime by 2x.
(which is why I used those more cumbersome functions in my raytracing code, but I'd forgotten just how dramatic the speedup was)