Saturday, May 21, 2011

Got my rasterizer working

Long time, no see huh :|

Anyways, the big news is that I have crossed my rite of passage. See, most people would write a simple ray tracer when they are fooling around with graphics. But I for some reason, felt that writing a rasterizer would be so much cooler. The thing is, this technique is so looked down upon that even the word rasterize not in default Firefox dictionary. Talk about being an outcast. :P

But, I managed to write it in the end. So here's the obligatory screenshot.

It has vertex shaders, pixel shaders, bilinear filtering of rectangular textures (but no mip mapping) and perspective correct interpolation. It still has a few rough edges and sharp corners though. The rasterization process is anything but robust and for some reason, I decided to defer implementing the z buffer itself. Yeah, I am going to hell for this...

There's a very illuminating story behind the history of z buffer itself. It was discovered by Edward Catmull, who among other things discovered texturing. In a review of 10 visible surface determination algorithms (PDF) by the legendary Ivan Sutherland, it was characterized as ridiculously expensive. And yet, here it is, having virtually displaced everything else.

Bottom line, amenability to hardware implementation and Moore's law put together can change the cost of an algorithm.