0xSim,
@0xSim@hachyderm.io avatar
0xSim,
@0xSim@hachyderm.io avatar

Simple 4x4 Bayer dithering in #PICO8

https://gist.github.com/scambier/9c6fe468b6414b291e6a84d113917b5d

Contrary to TIC-80, PICO-8 has a built-in fillp() ("fill pattern") function that accepts a 4x4 pattern, and can be used with e.g. rect() or line(). So a pre-computed table of all Bayer values is more useful than the matrix itself.

Animated dithering: a square gradually looping colors, and a vertical strip showing the whole dithering range, going from one color on the top to the other at the bottom.

bails80,
@bails80@mastodon.gamedev.place avatar

@0xSim I've been using a little function to give me a halftone dithered gradient between two palette colours:

function cd(d,ps,pe)
d=1-d
local mv=#ht*(pe-ps+1)
local i=mv*d
if(i<#ht)return false
local c1=mid(ps,pe,ps+(i#ht))
local c2=mid(ps,pe,c1-1)
color((c1<<4)+c2)
fillp(ht[ceil(i%#ht)])
return c1
end

ht={0,0x8000,0x8020,0xa020,0xa0a0,0xa8a0,0xa8a2,0xaaa2,0xaaaa,0xeaaa,0xeaba,0xfaba,0xfafa,0xfefa,0xfefb,0xfffb,0xffff}

call cd(0..1, palette start #, palette end #)

0xSim,
@0xSim@hachyderm.io avatar

Lol thank you mastodon for hiding the best part in the top left corner 😅

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • mdbf
  • ethstaker
  • magazineikmin
  • GTA5RPClips
  • rosin
  • thenastyranch
  • Youngstown
  • osvaldo12
  • slotface
  • khanakhh
  • kavyap
  • InstantRegret
  • Durango
  • megavids
  • everett
  • tester
  • cisconetworking
  • Leos
  • cubers
  • modclub
  • ngwrru68w68
  • tacticalgear
  • anitta
  • provamag3
  • normalnudes
  • JUstTest
  • lostlight
  • All magazines