Home arrow Software Rendering
 
Software Rendering

At the end of May 2007 I began programming a software rasterizer which I ended up using in my GP2X demo that I entered in the GBAX 2007 Coding Competition. You can check out the finished demo at pouet.net . Check out the screenshot below:

My first implementation was based on Nicolas Capens article about advanced rasterization. In his article he describes a block based apporoach using edge equations to rasterize triangles.

I implemented this approach and used blocks of 8x8 pixels. I do the perspective correction at the corners of the blocks and within each block I use linear interpolation for the varying parameters. It works quite well and the block based appoach also allows a hirarchical depth test which could speed up scenes with a high depth complexity. The rasterizer is coded entirely with fixed point math (as the GP2X does not have floating point hardware) and can interpolate an arbitrary number of integer attributes across the triangle. I also programmed a vertex transformation and clipping pipeline. At the end I am now able to use vertex and pixel shaders coded in C++ with my rasterizer.

In my GP2X demo some scenes were quite slow. The block based approach seemd to have quite some performance problems especially with small triangles as at least a whole 8x8 block of pixels was scanned.

I reimplemented the triangle rasterizer to use a scanline based approach just the way Chris Hecker describes it in his articles on Perspective Texture Mapping. First I implemented a version which only did affine (perspective incorrect) interpolation and it turned out to be 50-100% faster than the block based approach. But this version also had a lot of rendering errors since the perspective correction was missing. I then implemented the subdividing affine method as described in Chris Heckes articles (so that I didn't need to do the perspective division for each pixel) which worked quite well and gave acceptable results. It naturally was slower than the affine version but still 30-60% faster than the block based approach.

Now in the final version the programmer can enable/disable perspective correction depending on what kind of geometry he wants to render (e.g. billboards don't need perspective correction as they face the camera). This gives the best performance.

Below you can find the source code. If you have a hard time finding out how to use it just drop me a line. It's released under the BSD license, so you are free to use this in a commercial product. In this case, although you are not required to, I would like you to give me a donation. 

Trenkis Software Renderer Resources: 

 Source code (Subdividing affine, scanline based)
 Source code of  older versions (block based etc.)
 F341 Demo (Precompiled for gp2x and win32; includes source code)

Usage example pack for the renderer


You might also want to check out my OpenGL ES-CL 1.0 implementation Fusion2X based on this software renderer.
 
< Prev   Next >

Paypal Donate




© 2014 Trenki's Programming Page
Joomla! is Free Software released under the GNU/GPL License.
Template Design by funky-visions.de