As mentioned in this previous post – in-between bouts of preparation for AU2013 and my other work responsibilities – I’ve been spending time following an edX class on computer graphics. It’s been really beneficial: I’ve shored up some of the basics I’d missed out on studying formally at university and it was a great continuation of many of the concepts gleaned from the linear algebra class on Coursera.
The final assignment in the class has been a challenge: I’ve had to write a ray-racer from the ground up. It’s been really interesting, though: there are various steps to go through, such as loading a scene from a (text) file, implementing a camera model, the ability to test for intersections between rays and the elements of your scene and then lighting and shadow calculations. I knew that ray-tracers cast per-pixel rays to determine colouring – and followed reflections in the model to determine the effect of light bouncing off other objects in the scene – but I didn’t realise they also cast rays towards light sources to determine whether the pixel was in shade (with respect to that particular light). In many ways obvious, but going through the whole process has been very instructive.
And I'm really happy I had this opportunity to dust off my C++ skills: I’d actually forgotten how much I enjoy the language, despite hassles such as class declarations and multiple inclusion of header files.
For fun I decided to save out the results I received from my evolving application and create an animated GIF showing some of the progress. Lots of the early issues – such as the black and white images – ended up relating to the image output code, but I eventually progressed to being able to deal with geometry, transformations and – towards the end – shading and lighting effects. I’m still not quite done but I won’t post any further images – at least not of the scenes provided in the course – as these images are actually used to submit the homework and the deadline isn’t for another couple of weeks.