Log In  
Follow
mahkoe
[ :: Read More :: ]

Cart #mahkoe_sbuf-4 | 2022-01-06 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
13

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:

  • You can get 30 FPS with about 75 visible polygons
  • The fox model (downloaded here: https://opengameart.org/content/5-low-poly-animals) only hits 15 FPS. In general there are about 100 visible polygons at any given time
  • All polygons must be convex and planar, but the s-buffer technique completely deals with hidden surface determination (i.e. your models don't have to be convex, and you can have multiple objects in the scene)
  • There are still a few visual glitches for corner case polys that are a single line

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/

P#104285 2022-01-04 20:00 ( Edited 2022-01-06 02:36)

Follow Lexaloffle:          
Generated 2024-03-29 05:40:37 | 0.076s | Q:10