I am still very new to PICO-8 and saw a few games rendered with polygons.
This lead me to the Trifill Thunderdome benchmark by Musurca.
One thing this benchmark didn't show was the number of tokens for each method which is an important detail considering the limitations of the platform.
Also, I wrote two triangle rasterizers in 163 and 335 tokens respectively which perform pretty decently. They might be an acceptable alternative to ElectricGryphon's super fast triangle rasterizer if you need an extra 2-400 tokens. If you don't, by all mean use his. It is the fastest one I found, and by a good margin!
Update 20180706: Added the possibility to switch rasterizer and turn the test triangle with the arrow keys. This allows to compare rasterizers at a normal pace. Updated EG's rasterizer to the latest he posted in the previous thread and added the one from Gryphon 3D Engine Library v2 only modified to use normal color() and fillp().
Update 20180708: Added a fill pattern and a toggle for the results and control wireframe.
Hope this helps,


That would be the one by @creamdog. It uses memset(screenAddress, col * 17, scanlineWidth) which can only set an even number of pixels. Hence the half resolution horizontally and the artifacts.
The triangle you see spinning after the benchmark uses my 335 tokens rasterizer.


Nice work! I haven't looked at the code yet, but that's a mighty optimization effort right there. (Twice!)
edit: I added some code to switch between renderers on the result screen, there seems to be something not quite right with at least one of the algorithms. (Pretty sure I set things up right, maybe not?)
z changes the renderer, x pauses the rotation, up changes the colour.
You might want to extend this to modify the vertices as well if you're hunting for artefacts.


THANKS!
Excellent idea to try the different rasterizers after the benchmark.
I tried this last night and saw some have wild bugs. I updated EG's rasterizer to the last one he posted in the previous thread, and the one from the Gryphon 3D librarry v2 and now my "big" rasterizer comes ahead :U


Another nice addition would be an overlay of the demo triangle using plain lines (dunno, switch on/off using button).
Not all rasterizers are drawing the triangle at the same place!!
EDIT: just did the test, and @p01 are fast and accurate. Nice job!
... tests[method_index].fn(1) -- "native" pico triangle/lines if btn(4) then for i=0,2 do local p0,p1=2*i+1,(2*(i+1))%6+1 line(f[p0],f[p0+1],f[p1],f[p1+1],8) end end |


I created a trifill() for my project.
I'd like to share it because it has a different loop than the other code.
Thank you so much for posting this place!
308 token(top clipping & V-H processing branch)
176 token(Enable top clipping only)
129 token(minfy-code! Non top clipping) [UPDATE:20221118]

Previous Code
These cords have the disadvantage of missing the bottom edge.


Here's my 143 token take on a triangle fill.
-- @Domino_Marama function domino_tri(x0,y0,x1,y1,x2,y2,col) color(col) if(y1<y0)x0,x1,y0,y1=x1,x0,y1,y0 if(y2<y0)x0,x2,y0,y2=x2,x0,y2,y0 if(y2<y1)x1,x2,y1,y2=x2,x1,y2,y1 if(y0!=y1) x0,col=trapa(y0,y1,x0,x0,(x1-x0)/(y1-y0),(x2-x0)/(y2-y0)) if(y1!=y2) trapa(y1,y2,x1,x0,(x2-x1)/(y2-y1),col) end function trapa(y1,y2,lx,rx,dl,dr) for y=y1,min(y2,128) do rectfill(lx,y,rx,y) lx+=dl rx+=dr end return rx-dr,dr end |
[Please log in to post a comment]