Squeezing PICO-8 CPU!
Disclaimer: updated version will all tracks is not yet published - should be published later in Jan.
The next step for Virtua Racing is to have other competitors to play against (or zoom past them as in the arcade).
Some performance boost is necessary (and beside Zedwolf showed me that 300+ tri/frame was possible on pico!)
TL;DR - 2019 vs. 2020 CPU:
gif are not aligned thanks to a slightly different screen center (63.5 vs. 64)
Most notable performance elements listed below (with estimate on total pico-8 cpu in brackets)
Full minute code diff (Github)
New Polygon Renderer [~2-8%]
Virtual Racing track and 3d models are mainly convex quads, well suited for an optimized edge renderer.
That shaved between 2-8% cpu per frame.
Side by side. trifill vs. edge renderer (max. cpu over 2s)
Note: right gif taken before full optimization pass
-64/-64 Everything [~1%]
camera(-64,-64) was used to remove centering from all vertex coords calculations. Pays at scale.
Code Cleanup [~5%]
Many "little" performance improvements are just "better" code, loops unrolling...
One aspect I took care of was to avoid closure access cost:
function make_track() local i=0 return function() local li=i for j=1,100 do -- i: closure variable, accessed by 'unboxing' the data if(i==j) print(i) -- li: "local"ized version, fast if(li==j) print(li) end end end
Background Pruning [7%]
Was not expecting this one, but a major gain was achieved by trimming down the number of tiles on the background map!
Full background image is now rendered with 2 rectfills on top of each other + map.
|Full map - slow||Sparse map + 2 rectfill 's= fast!|
Get Virtua Racing Demake
Leave a comment
Log in with itch.io to leave a comment.