Floyd-Steinberg Dithering Algorithm
en.wikipedia.org
en.wikipedia.org
In pngquant I have adaptive diffusion that is enabled only in areas of the image that really need it, so you still get dithered gradients, but don't get as much noise added to the image overall, which makes it look cleaner and compress better.
I also use Sobel edge detection and suppress diffusion at the edges, which fixes a particular quirk of FS where error is accumulated throughout a flat area and gets countered only at the edge when color changes (e.g. if an area should be brighter than the brightest color you have in your palette, dithering is unable to fix it, but all the "needs to be brighter!!!" error will accumulate and blow on next pixel that was supposed to be dark).