Just a tip: In this specific scenario, I don't know why, but you don't need the ps_main_pm or premultiplied version.
To fix the white dithering on premultiplied you just need to multiply rgb by alpha at the end on ps_main, it will work for both
That's very handy, thanks!
It turns out that in DX11, dithering can be simplified a lot, since there isn't the limit on constants. Instead of using four separate 4x4 matrices, you can just use a single array[64].
Oh, and I figured out how to make it a constant, defined outside of the main function, which ought to be marginally more performant than redefining it for every pixel.
static const int ptn[64] = {
0, 32, 8, 40, 2, 34, 10, 42,
48, 16, 56, 24, 50, 18, 58, 26,
12, 44, 4, 36, 14, 46, 6, 38,
60, 28, 52, 20, 62, 30, 54, 22,
3, 35, 11, 43, 1, 33, 9, 41,
51, 19, 59, 27, 49, 17, 57, 25,
15, 47, 7, 39, 13, 45, 5, 37,
63, 31, 55, 23, 61, 29, 53, 21
};
// Get pattern index
int ptnPixel = yIn * 8 + xIn;
// Determine if the pixel should be 100% transparent or 100% opaque
palPixel.a = ptn[ptnPixel] < alpha ? 1 : 0;
I've updated the file here: Please login to see this link.
Obviously you're welcome to add or remove whatever features you like, but I think my work here is done! Thanks again for your help