S-Buffer Demo

0
0
Published 2023-06-12


A long time ago I read a page that explained the "s-buffer" technique for hidden surface determination. I can't find it anymore, sadly.

The general idea is to keep an array of "segments" per each horizontal line in the display (making 128 arrays total). A segment is just a left x-coordinate, a right x-coordinate, left+right z-depths, and colour. Each array of segments is kept in order.

The polygon filling code is my own method, but it was largely adapted from the method outlined in the graphics programming black book: https://www.jagregory.com/abrash-black-book/#chapter-38-the-polygon-primeval

A few extra notes:

EDIT: Thanks to @freds72, I was able to track down the original S-buffer article:
https://www.gamedev.net/tutorials/programming/graphics/s-buffer-faq-r668/