I'd always thought that it would be rather hard to write a raytracer (thought process: images pretty => producing them must be hard. non sequitur ftw) Then I came across this
toy raytracer in python at only 300 lines of code, and I'm like o_O. So I attempted to take a stab at writing my own tracer. The results:
Simple diffuse surfaces:
With reflection:
Glass (ie refraction):
Raytracers basically shoot rays from the 'eye' (viewport) onto the scene, and solve for the points where the rays intersect objects. Mostly simple vector math. I thought it was quite cool to see algebraic equations transformed by this simple process into 'real', visible objects on screen.. sort of like having a peek into their Platonic world, lol.
I started off in Python, but eventually decided that the time spent waiting for the renders was outweighing the time saved in coding. I think the C++ version ended up more than 100x faster, though I didn't take any measurements. (Discovered
Shed Skin, a Python to C++ compiler, only after I had done the port..)
Unfortunately it seems to get harder from this point onwards. Voxels, Kd trees and all that stuff.. maybe I shall go work on something else and come back to this later. Or I could start on my college apps, ho hum.