Files
T
2026-08-14 13:27:17 +02:00

16 lines
491 B
HLSL

/* 4x4 Bayer ordered dithering in UV space */
void Dither_float(float In, float2 UV, out float Out)
{
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
};
uint index = (uint(UV.x) % 4) * 4 + uint(UV.y) % 4;
Out = In - DITHER_THRESHOLDS[index];
}