Dithering
- Ashwani Shahrawat
- Jun 5, 2024
- 1 min read
Updated: Jun 20, 2024
Simply put, "Dithering is Morse Code of rendering techniques." Just like Dots and Dashes of Morse Code, you only have two possible outputs, but by arranging them in different sequence, you can express a lot more than two things.
In this blog, I will express how i look at dithering, and
Let's reinvent dithering, to build a good understating of how it works.
//////// Dithering ////////
inline float isDithered(float2 pos, float alpha)
{
float DITHER_THRESHOLDS[16] =
{
1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0,
13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0,
4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0,
16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0
};
int index = (int(pos.x) % 4) * 4 + int(pos.y) % 4;
return alpha - DITHER_THRESHOLDS[index];
}
inline void ditherClip(float2 pos, float alpha)
{
clip(isDithered(pos, alpha));
}



Comments