ZSpace
Jan 2004 - Download Source
ZSpace was a software only rasteriser I was working on late 2003. It was progressing nicely, until I came up against one rather large problem... Using a MS DirectDraw surface to plot pixels on the screen is dang slow. I did a lot of optimisation of the inner loop but nothing got me much over 30fps, so this one went on the shelf.
Culling methods were not fast. Object locations were projected to screen space and culled if outside that, then every polygon that made up visible objects were back face culled then transformed then clipped to screen space. The only interesting optimization was to include a frame counter to faces. If a face was back face culled then we would exclude if from the renderer for x number of frames, depending on its angle to the viewer.
Texturing used linear interpolation; I think the results were quite good. Except in all the images you see here, the texturing has gotten all wacky. It seems we are reading outside the memory region of the textures. I'm not sure what happened between when it was working in 2004 and now.
I used scalable point sprites for the gunfire, debris, explosions, stars, and earth. I had quite an elaborate structure for all this; one notable feature was that it allowed stars to be infinite distance. Separate Alpha channel bitmaps were used to make the explosions look nicer.
In case your interested here is the inner loop. I'm sure many improvements could be made, but I'm well onto OpenGL now to worry about reworking any software-rendering engine.
Feel free to download the code and have a look. I used a 3ds loader, and a little image opening code that was not mine so it's not included, I don't think.
for(i = Xr; i>Xl-1;--i)
{
if((qqqc = tZ+ZBufferPage) > *pZBuffer)
{ *pZBuffer = qqqc; if(res==15) { res=0;
OneOverZ = 1 / tZ; } else res++;
x = tU * OneOverZ; y = tV * OneOverZ; dibits = &MyTextureP[(x*4) + (y*1024)]; video_buffer[0] = dibits[0]; video_buffer[1] = dibits[1]; video_buffer[2] = dibits[2]; } tZ+=StepZ; tU+=StepU; tV+=StepV; video_buffer+=4; pZBuffer++; }

permanent link to this page : http://mrdavec.com/graphics/zspace

