top of page

Dithering

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));
}


Recent Posts

See All
Height Map and Parallax Mapping

In this blog, I will explain Adjust UV using HeightMap RayTrace HeightMap to find Occlusions. o.Height = SAMPLE_TEXTURE2D(_PKDMAP,...

 
 
 

Comments


bottom of page