gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > span buffer

#610 - PeterP - Wed Jan 08, 2003 11:50 pm

A piece of advice:

It's the number of rendered pixels on the screen that determines the speed, so make sure that you keep overdraw to minimum.

I use a span buffer to get zero overdraw. Much faster than z-buffering and more exact than just sorting.

Basically:

void RenderFrame()
{
Sort triangles front-to-back.
Clear span buffer.

for each triangle:
{
scan convert the edges.
compare each horizontal line of the triangle (the span) against the currently entered spans.
If no overlap => render the span and add it to the span buffer.
If complete overlap => don't render the span
Else clip the span, render it and add to the span buffer.
}

}


/pete

#611 - PeterP - Wed Jan 08, 2003 11:51 pm

That message was meant to be a reply in the topic "3d engine"...

sorry

#612 - Burre - Wed Jan 08, 2003 11:52 pm

I see, I was starting to wonder. :)
_________________
"The best optimizer is between your ears..."

#616 - Touchstone - Thu Jan 09, 2003 12:31 am

For some reason I got this irresistable urge to write a software renderer of some sort when you mentioned this span-thingie. That's pretty much where I ended my ventures in software rendering on the PC about five years ago. It really tickles my imagination thinking of all kinds of optimizations and trying to figure out ways to utilize the gba hardware. Oh, I think I had a bit of a nostalgia-trip there, sorry about that.
_________________
You can't beat our meat

#629 - jaymzjulian - Thu Jan 09, 2003 5:27 am

PeterP wrote:
A piece of advice:
I use a span buffer to get zero overdraw. Much faster than z-buffering and more exact than just sorting.
/pete


Span buffers are great if you're just drawing polys, however, when I was using a span buffer, because I'm trying to render sprites as well, I started having all sorts of Z axis fun :(.

Overdraw is a real bitch, tho

- jj

#647 - coelurus - Thu Jan 09, 2003 11:56 am

The kind of fine occlusion algorithm to use depends heavily on what kind of 3D world you want. For example, S-buffers are only useful where there will be many triangles and a lot of overdraw. In case of possibly little overdraw, the overhead of using span-search and the complex insertion routine will just slow things down.
There are also other algos around (Quake used AELs). Check out:
http://www.flipcode.com/harmless/issue01.htm