tree sway and shadow improvements
[WindSway-HDRP.git] / Library / PackageCache / com.unity.postprocessing@2.1.2 / PostProcessing / Shaders / Builtins / Dithering.hlsl
blob5ed1d0a0e4c8cf37609ed7507c37a9eba7e9bf69
1 #ifndef UNITY_POSTFX_DITHERING
2 #define UNITY_POSTFX_DITHERING
4 TEXTURE2D_SAMPLER2D(_DitheringTex, sampler_DitheringTex);
5 float4 _Dithering_Coords;
7 float3 Dither(float3 color, float2 uv)
9     // Final pass dithering
10     // Symmetric triangular distribution on [-1,1] with maximal density at 0
11     float noise = SAMPLE_TEXTURE2D(_DitheringTex, sampler_DitheringTex, uv * _Dithering_Coords.xy + _Dithering_Coords.zw).a * 2.0 - 1.0;
12     noise = FastSign(noise) * (1.0 - sqrt(1.0 - abs(noise)));
14 #if UNITY_COLORSPACE_GAMMA
15     color += noise / 255.0;
16 #else
17     color = SRGBToLinear(LinearToSRGB(color) + noise / 255.0);
18 #endif
20     return color;
23 #endif // UNITY_POSTFX_DITHERING