I have some basic, not yet finished triangle rasterization, using a sligh modification of Bresenham line algorithm, so that I can keep everything integer only. This is SDL for now:
What you see may remind you of any OpenGL 101 tutorial, because these colored triangles are the very basics of any realtime 3D engine. The colors gradually blending indicate one important concept: interpolation by Barycentric coordinates. In OpenGL (and Direct3D and eventually my library as well) you can assign any number of values to each vertex – these can be a color (as seen here) or a texture coordinate, or transparency, or anything – in the rendering pipeline these are then automatically smoothly interpolated for each pixel inside the triangle – hence the smooth transitions. Pretty elegant design.
Eventually this interpolation will have to also take into account the Z coordinate for the perspective correction. This final equation is quite complex and is what I fear for the performance, since it’s a per-pixel operation. Anyway, I simply have to try and see if it’s possible to run on some reasonable FPS. I believe there are optimizations hiding around somewhere – most likely a lot of stuff will be precomputable at the start of rendering of each triangle, to relieve the upcoming per-pixel operations.