Subscribe to WolfCoder's Kawaii Column        RSS Feed

Software Rasterizing Triangles (Realtime Graphics)

Icon 2 Comments
I was writing a software fallback GPU for some engine I was working on for fun and the results are pretty standard of what you'd get. The basic idea is you want to map textures onto polygons and use a scanline algorithm to do so.

Posted Image

This is a pretty good diagram of what you do (that I found online because I am lazy). You start at the highest vertex of the triangle and work your way down, minding the side vertex. That pesky side vertex makes the entire algorithm a bit tricky.

The job is to convert the triangle into many horizontal 1-pixel bars (scanlines) and interpolate the texture coordinates on the left side as you go to the right side.

I took this as the texture to use:
Posted Image

And I decided to test it on my own scanline algorithm. I actually benchmarked the algorithm by first drawing 128 frames with 4 rotating images and then adding one rotating image for every frame after that:

Posted Image

I recorded my results in a millisecond histogram (FPS is not a proper way to benchmark graphics):

Posted Image

The top of the graph is 128ms a frame or about 8 FPS. At about 44 images, I hit the top of the graph >.< so I have a little bit of optimizing to do. I'm not too worried, this is only the GPU system my engine will use when there is no good video acceleration available. Video games become somewhat unplayable under 16 FPS which is halfway up my histogram.

This was still a fun little thing to do and I recommend anyone to write their own software rasterizer if they want to learn more about realtime graphics.

2 Comments On This Entry

Page 1 of 1

Amrykid Icon

12 October 2011 - 02:32 PM
Interesting. Will you be posting more updates about this?

WolfCoder Icon

22 October 2011 - 10:04 PM
I might. If you're interested in rasterizing your own graphics I might even write the basic intro. It involves tons of Linear Algebra though.
Page 1 of 1

Recent Entries

October 2016