hello dear shader gods,
i’m fighting with hlsl for some time now, so - perhaps anyone can put me in the right direction.
what i want to achieve is a pixelshader that does dithering.
while there are many different dithering algorithms, a nice one is the so called floyd-steinberg algorithm but there is also this simpler ordered dithering algorithm.
so far, i thought i can base on the halftone-shader, but no success so far.
there’s this pseudocode that only has to be converted to hlsl:
for each y from top to bottom
for each x from left to right
oldpixel := pixel[x](x)[y](y)
newpixel := find_closest_palette_color(oldpixel)
pixel[x](x)[y](y) := newpixel
quant_error := oldpixel - newpixel
pixel[x+1](x+1)[y](y) := pixel[x+1](x+1)[y](y) + 7/16 * quant_error
pixel[x-1](x-1)[y+1](y+1) := pixel[x-1](x-1)[y+1](y+1) + 3/16 * quant_error
pixel[x](x)[y+1](y+1) := pixel[x](x)[y+1](y+1) + 5/16 * quant_error
pixel[x+1](x+1)[y+1](y+1) := pixel[x+1](x+1)[y+1](y+1) + 1/16 * quant_error
so, i would be very thankfull for any advise, thanks
sebl