mahkoe [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=61728 S-Buffer Demo <p> <table><tr><td> <a href="/bbs/?pid=104285#p"> <img src="/bbs/thumbs/pico8_mahkoe_sbuf-4.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=104285#p"> S-buffer Demo 1.4</a><br><br> by <a href="/bbs/?uid=61728"> mahkoe</a> <br><br><br> <a href="/bbs/?pid=104285#p"> [Click to Play]</a> </td></tr></table> </p> <p>A long time ago I read a page that explained the &quot;s-buffer&quot; technique for hidden surface determination. I can't find it anymore, sadly.</p> <p>The general idea is to keep an array of &quot;segments&quot; 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.</p> <p>The polygon filling code is my own method, but it was largely adapted from the method outlined in the graphics programming black book: <a href="https://www.jagregory.com/abrash-black-book/#chapter-38-the-polygon-primeval">https://www.jagregory.com/abrash-black-book/#chapter-38-the-polygon-primeval</a></p> <p>A few extra notes:</p> <ul> <li>You can get 30 FPS with about 75 visible polygons</li> <li>The fox model (downloaded here: <a href="https://opengameart.org/content/5-low-poly-animals">https://opengameart.org/content/5-low-poly-animals</a>) only hits 15 FPS. In general there are about 100 visible polygons at any given time</li> <li>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)</li> <li>There are still a few visual glitches for corner case polys that are a single line</li> </ul> <p>EDIT: Thanks to <a href="https://www.lexaloffle.com/bbs/?uid=25532"> @freds72</a>, I was able to track down the original S-buffer article:<br /> <a href="https://www.gamedev.net/tutorials/programming/graphics/s-buffer-faq-r668/">https://www.gamedev.net/tutorials/programming/graphics/s-buffer-faq-r668/</a></p> https://www.lexaloffle.com/bbs/?tid=45999 https://www.lexaloffle.com/bbs/?tid=45999 Tue, 04 Jan 2022 20:00:46 UTC