From e51760ab5e6d698b26b60e1811e7afce62be55d0 Mon Sep 17 00:00:00 2001 From: yum Date: Mon, 7 Oct 2024 14:41:33 -0700 Subject: Fix center eye toggle in rim lighting Also add bayer dithering logic (not used yet). --- poi.cginc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'poi.cginc') diff --git a/poi.cginc b/poi.cginc index f5019d7..6a0d5f3 100644 --- a/poi.cginc +++ b/poi.cginc @@ -123,4 +123,27 @@ float3 getPoiLightingIndirect() { return BetterSH9(float4(0, 0, 0, 1)); } +inline half Dither8x8Bayer(int x, int y) +{ + // Premultiplied by 1/64 + const half dither[ 64 ] = { + 0.015625, 0.765625, 0.203125, 0.953125, 0.06250, 0.81250, 0.25000, 1.00000, + 0.515625, 0.265625, 0.703125, 0.453125, 0.56250, 0.31250, 0.75000, 0.50000, + 0.140625, 0.890625, 0.078125, 0.828125, 0.18750, 0.93750, 0.12500, 0.87500, + 0.640625, 0.390625, 0.578125, 0.328125, 0.68750, 0.43750, 0.62500, 0.37500, + 0.046875, 0.796875, 0.234375, 0.984375, 0.03125, 0.78125, 0.21875, 0.96875, + 0.546875, 0.296875, 0.734375, 0.484375, 0.53125, 0.28125, 0.71875, 0.46875, + 0.171875, 0.921875, 0.109375, 0.859375, 0.15625, 0.90625, 0.09375, 0.84375, + 0.671875, 0.421875, 0.609375, 0.359375, 0.65625, 0.40625, 0.59375, 0.34375 + }; + int r = y * 8 + x; + return dither[r]; +} + +half calcDither(half2 grabPos) +{ + return Dither8x8Bayer(glsl_mod(grabPos.x, 8), glsl_mod(grabPos.y, 8)); +} + + #endif // __POI_INC -- cgit v1.2.3