@@ -4,6 +4,8 @@ Shader "OnTileUberPost"
44 #pragma multi_compile_local_fragment _ _HDR_GRADING _TONEMAP_ACES _TONEMAP_NEUTRAL
55 #pragma multi_compile_local_fragment _ _FILM_GRAIN
66 #pragma multi_compile_local_fragment _ _DITHERING
7+ #pragma multi_compile_local_fragment _ _GAMMA_20 _LINEAR_TO_SRGB_CONVERSION
8+ #pragma multi_compile_local_fragment _ _USE_FAST_SRGB_LINEAR_CONVERSION
79 #pragma multi_compile_local_fragment _ _ENABLE_ALPHA_OUTPUT
810 #include _with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
911
@@ -79,6 +81,14 @@ Shader "OnTileUberPost"
7981 {
8082 half3 color = inputColor.rgb;
8183
84+ // Gamma space... Just do the rest of Uber in linear and convert back to sRGB at the end
85+ #if UNITY_COLORSPACE_GAMMA
86+ {
87+ color = GetSRGBToLinear (color);
88+ inputColor = GetSRGBToLinear (inputColor);
89+ }
90+ #endif
91+
8292 // Remapped UV for screen-space effects in Quad View
8393 float2 uvRemapped = uv;
8494#ifdef USING_STEREO_MATRICES
@@ -112,12 +122,26 @@ Shader "OnTileUberPost"
112122 }
113123 #endif
114124
125+ // When Unity is configured to use gamma color encoding, we ignore the request to convert to gamma 2.0 and instead fall back to sRGB encoding
126+ #if _GAMMA_20 && !UNITY_COLORSPACE_GAMMA
127+ {
128+ color = LinearToGamma20 (color);
129+ inputColor = LinearToGamma20 (inputColor);
130+ }
131+ // Back to sRGB
132+ #elif UNITY_COLORSPACE_GAMMA || _LINEAR_TO_SRGB_CONVERSION
133+ {
134+ color = GetLinearToSRGB (color);
135+ inputColor = LinearToSRGB (inputColor);
136+ }
137+ #endif
138+
115139 #if _DITHERING
116140 {
117141 color = ApplyDithering (color, uvRemapped, TEXTURE2D_ARGS (_BlueNoise_Texture, sampler_PointRepeat), DitheringScale, DitheringOffset, PaperWhite, OneOverPaperWhite);
118142 }
119143 #endif
120-
144+
121145#if _ENABLE_ALPHA_OUTPUT
122146 // Saturate is necessary to avoid issues when additive blending pushes the alpha over 1.
123147 return half4 (color, saturate (inputColor.a));
0 commit comments