So as a side project, I've decided to give a stab at writing my own raytracer in Python. It's obviously not for any production use, but more of a learning tool and proof of concept. I've found some decent resources online, but I'm curious if anyone out there has done this and has any decent pointers to pass on? I'm planning on implementing diffuse and reflection for now. I'm going to give myself a month to do this and will update my progress as I go. When I finish, I'll post my code and my final image.
Step1 - Complete.
It took me a night and a better part of a day to create and implement. Being familiar with raytracing / rendering theory, it wasn't that hard to implement (with flat shaded spheres that is). Figuring out the math for ray intersections was the most difficult part of the process. I also found a faster way to cut objects in my Voronoi Cutting script while working on this. I love it when a plan comes together.
I'm using the PIL library to create the image. I'd like to learn how to write floating point data to a 32 bit tiff file, but one step at a time. From what I've seen, OpenEXR has an enitre C++ library with most of the math classes ready for you. With that and the ability to write to EXR files, this is where I'll probably start when I switch to C++ for the real thing. Oh yeah, did I mention that I wanted to port this over to C++ when I finish?
After looking around on the web, my geometric way of solving ray collisions with a sphere apparently isn't the fastest out there. Honestly, my code was about 10 lines longer until I realized I was doing the same thing that other renderers do. I was able to find more streamlined code on a website. I'm really not looking for speed at this point, however I can see this render time quickly getting out of hand once I start calculating light, shadow and reflection rays.
I want to implement cube intersections and probably point lights. Getting the shading models together will probably take the better part of a day, so I don't plan on having that up right away.