Tuesday, March 23, 2010

Obicham -- 3D Rasterizing Demo in a Console Window

Speaking of demos, here's one I recently did. It's a traditional 3D rasterizer ... in a DOS console! Heck yes. The process goes like this: A Rasterizer renders objects in a sort of OpenGL immediate mode fashion onto an Image, a two dimensional array of Colors, and then sends it to a Console which then takes that Image and converts the individual pixels into ascii-characters, and sends the result to the window. A SDL debug window rendered the same image in another window with true color to help debug how the Console was choosing its blend of 16-colors.

Screenshots:

Here's the first ever screenshot from Obicham. Its supposed to be a box. As you can see, it is not; it's more like a rhombus on a flat piece of paper that's being rotated. Turns out I was multiplying the matrices in the wrong order.


Here's the second ever screenshot from Obicham, this time, with the matrices multiplied in the right order. This is still supposed to be a box. As you can see, there's some serious WTFs/sec going on. To add insult to injry, the top vertices spun in the opposite direction of the bottom vertices.


Polygon filling and color blending. This took a few tries to get right, but there it is. On the left is the main window, the console window, and on the right, is another SDL window for debugging.


First rotating cube! Having some trouble with the polygon filling, the technique I was using didn't do any bounds-checking, so I aggressively clamped the transformed x and y coordinates of the vertices, which changed the geometry a bit. I also chose a different charset to use for the blending. Looks better, doesn't it?


Same rotating cube! This time, I redid the bounds-checking on the polygon filling, added some back-face culling.

Video:


Showing off the different modes the demo offers.

Download:
Obicham Demo 2.0 (few more demos, better colors)
Obicham Demo 1.0

No comments:

Post a Comment