2 using UnityEngine
.Assertions
;
4 namespace UnityEngine
.Rendering
.PostProcessing
6 #if UNITY_2017_1_OR_NEWER
7 [UnityEngine
.Scripting
.Preserve
]
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
;
24 if (++m_NoiseTextureIndex
>= blueNoise
.Length
)
25 m_NoiseTextureIndex
= 0;
27 float rndOffsetX
= Random
.value;
28 float rndOffsetY
= Random
.value;
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
,