Mandelbox! Ray-marching! OpenCL! Distributed rendering?
Posted by Tom on 2013-03-10 22:20
I don't know how I first stumbled across the Mandelbox, and I can't remember what I was working on before, but before I knew it I'd dropped everything and written a ray marcher.
This is actually the first time I'd written a ray marcher (or ray tracer), which is odd considering they're the 'hello world' of computer graphics programming. Almost everything I'd done up until this point has been real-time.
Just for shits and giggles I then ported it to my Raspberry Pi. Turns out they're not to great at pure number crunching. I don't really know what I was expecting there. But it also forced me to learn the basics of make, so it wasn't a complete waste of time.
Since that worked it was time to try and animate the thing, I guess.
I thoroughly recommend clicking through and watching it in glorious HD directly on Vimeo, because after spending an embarrassing amount of time lovingly encoding it in Avidemux and learning more about H264 that I ever, ever wanted to know, Vimeo re-encoded it to look like shit.
So now what? I've been looking for an excuse to use OpenCL for a while now, and this seemed like a pretty good fit. The problem is already embarrassingly parallel (I love how that is actually a thing).
There is a whole lot of yucky boilerplate to set up, but moving code over to an OpenCL kernel is crazy simple assuming it starts in C and doesn't share any memory, which mine doesn't. Score! That led to a 3-5 performance increase on the laptop (2.13GHz Core 2 Duo and a GeForce 9400M G) and a 6-10 boost on the desktop (2.4GHz Core 2 Quad and a GeForce 8800 GTX OC). That's for single frames. When animating I was running multiple threads to keep all of the cores busy, so it's more of a 2x speed-up on both. I know next to nothing about GPGPU programming, so it could probably be improved. The only other gotcha is Time Detection and Recovery, which will throw a wobbler in Windows 7 (and Vista?) if the GPU blocks for a specified length of time. I buggered about with the registry settings to turn that off, but the better solution would be running smaller batches. Maybe in a while.
But next in my nefarious scheme is to have the rendering code running in various machines around the house (the laptop, the desktop, the Linux box upstairs) and have a server (running on the Rasperry Pi), which passes out frame descriptions on requests for the various clients to render in their downtime. Essentially I'm creating a very small botnet in my own home, specifically for running 3D fractals. Still a little ridiculous, but it'll keep me amused.
For those not keeping track, over the course of this faintly daft project I've learned ray marching, distance estimators, make, video encoding, OpenCL and next I'll probably move on to some distributed processing. I love learning new stuff.