experiments with fresnel and shadergraph
[WindSway-HDRP.git] / Library / PackageCache / com.unity.postprocessing@2.1.6 / PostProcessing / Runtime / Effects / Dithering.cs
blob9fcc15123aa2418d1d720deacb0fb52443874b71
1 using System;
2 using UnityEngine.Assertions;
4 namespace UnityEngine.Rendering.PostProcessing
6 #if UNITY_2017_1_OR_NEWER
7 [UnityEngine.Scripting.Preserve]
8 #endif
9 [Serializable]
10 internal sealed class Dithering
12 int m_NoiseTextureIndex = 0;
14 internal void Render(PostProcessRenderContext context)
16 var blueNoise = context.resources.blueNoise64;
17 Assert.IsTrue(blueNoise != null && blueNoise.Length > 0);
19 #if POSTFX_DEBUG_STATIC_DITHERING // Used by QA for automated testing
20 m_NoiseTextureIndex = 0;
21 float rndOffsetX = 0f;
22 float rndOffsetY = 0f;
23 #else
24 if (++m_NoiseTextureIndex >= blueNoise.Length)
25 m_NoiseTextureIndex = 0;
27 float rndOffsetX = Random.value;
28 float rndOffsetY = Random.value;
29 #endif
31 var noiseTex = blueNoise[m_NoiseTextureIndex];
32 var uberSheet = context.uberSheet;
34 uberSheet.properties.SetTexture(ShaderIDs.DitheringTex, noiseTex);
35 uberSheet.properties.SetVector(ShaderIDs.Dithering_Coords, new Vector4(
36 (float)context.screenWidth / (float)noiseTex.width,
37 (float)context.screenHeight / (float)noiseTex.height,
38 rndOffsetX,
39 rndOffsetY
40 ));