Anton's Research Ramblings

Software Rasterisation Resources

I talked about building a software 3D rasteriser in some of my recent live streams, and people asked if I could share my resources. If you start with a program that can write out an image then you can progressively add features one by one, which is quite fun. If you find a triangle fill algorithm to rasterise one triangle (colour the correct pixels between 3 corner points) then you're on the right path. It's easier, and arguably more fun, to write a simple software rasteriser than get a modern 3D API started, which is kind of silly. Yes, it is a good way to learn 3D graphics concepts, much like writing a software ray tracer. Here is some of my demo code.

A rasterised shape with a flat colour
Upgrading from one filled triangle to a shape made of triangles.
Barcyentric interpolation
Barycentric coordinates used for interpolating vertex colours.
A depth map
A depth buffer for depth testing.
A 3D model loaded from a mesh file.
Displaying a 3D model loaded from a mesh file.

In my graphics experiments repository you'll also find code for animating graphics in an X11 window, and a starter for rasterising a cube in an X11 window. I have a similar demo somewhere that rasterises a 3D spinning cube into a 2D canvas element on a webpage.

I may have some lecture slides from last year about this process that could be helpful - I'll have to dig further to find them...