Thursday, September 1, 2011

Software Rasterization

The previous post awakened the part of me that is somewhat passionate about graphics programming. In the last three nights, I threw together a software rasterizer that is now capable of perspective-correct texture mapping in addition to point lights.

Here is a screenshot:

Rotating cube

And here is a video that VLC should have no trouble playing.

Some details:

The rasterization algorithm is very primitive. Triangle setup first ensures clockwise vertex ordering (cross product of the two edge vectors followed by a sign comparison) and culls backfaces. Next, a transformation to Barycentric coordinates is computed, and blocks of pixels in the render target are transformed and compared. If their Barycentric coordinates are found to lie within the triangle, they are used to interpolate vertex color and texture samples.

It is not yet GPU accelerated, though expect a CUDA implementation to follow.

No comments: