Skip to content

Commit 5c302c1

Browse files
svc-reach-platform-supportEvergreen
authored andcommitted
[Port] [6000.5] Fix On Tile PostProcessing not rendering properly with Gamma Colorspace
1 parent d0d641e commit 5c302c1

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/OnTilePostProcessPass.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer
116116
SetupGrain(m_OnTileUberMaterial, cameraData, filmgrain, m_PostProcessData);
117117
SetupDithering(m_OnTileUberMaterial, cameraData, m_PostProcessData);
118118

119+
CoreUtils.SetKeyword(m_OnTileUberMaterial, ShaderKeywordStrings.LinearToSRGBConversion, cameraData.requireSrgbConversion);
120+
CoreUtils.SetKeyword(m_OnTileUberMaterial, ShaderKeywordStrings.UseFastSRGBLinearConversion, postProcessingData.useFastSRGBLinearConversion);
119121
CoreUtils.SetKeyword(m_OnTileUberMaterial, ShaderKeywordStrings._ENABLE_ALPHA_OUTPUT, cameraData.isAlphaOutputEnabled);
120122

121123
#if ENABLE_VR && ENABLE_XR_MODULE

Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/OnTileUberPost.shader

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)