Skip to content

Commit aeb0eaf

Browse files
sebastienlagardeEvergreen
authored andcommitted
[HDRP] Fix issues with RTGI and RTR discrepency when using high contrasted IBL
This PR is fixing discrepency observe when using an IBL with strong local lighting and using SSGI/SSR versus RTGI/RTR in quality, performance and mixed mode (see the JIRA for more details). The PR is removing the clamped value for the "clamp" parameter of RTR and RTGI allowing to put any value and is changing the default from 1.0 to 100.0. Users observing noise with raytracing will be require to adjust those value to improve the quality, pottentially causing a decrease in intensity, but at least by default users will not complain that the lighting is dull and not understanding why. The PR also update the fallback of the RTGI and SSGI effect to fallback on ambient probe rather than Sky cubemap texture for less noisy result.
1 parent adc22f6 commit aeb0eaf

File tree

21 files changed

+121
-67
lines changed

21 files changed

+121
-67
lines changed

Packages/com.unity.render-pipelines.high-definition/Documentation~/reference-screen-space-global-illumination.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@
102102
<td></td>
103103
<td>Defines the layers that HDRP processes this ray-traced effect for.</td>
104104
</tr>
105+
<tr>
106+
<td><strong>Clamp Value</strong></td>
107+
<td></td>
108+
<td>Set a value to control the threshold that HDRP uses to clamp the pre-exposed value. This reduces the range of values and makes the global illumination more stable to denoise, but reduces quality.</td>
109+
</tr>
105110
<tr>
106111
<td><strong>Mode</strong></td>
107112
<td></td>
@@ -117,11 +122,6 @@
117122
<td></td>
118123
<td>Controls the maximal length of rays. The higher this value is, the more resource-intensive ray traced global illumination is.</td>
119124
</tr>
120-
<tr>
121-
<td><strong>Clamp Value</strong></td>
122-
<td></td>
123-
<td>Set a value to control the threshold that HDRP uses to clamp the pre-exposed value. This reduces the range of values and makes the global illumination more stable to denoise, but reduces quality.</td>
124-
</tr>
125125
<tr>
126126
<td><strong>Full Resolution</strong></td>
127127
<td></td>

Packages/com.unity.render-pipelines.high-definition/Documentation~/reference-screen-space-reflection.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
<td></td>
5858
<td>Defines the layers that HDRP processes this ray-traced effect for.</td>
5959
</tr>
60+
<tr>
61+
<td><strong>Clamp Value</strong></td>
62+
<td></td>
63+
<td>Controls the threshold that HDRP uses to clamp the pre-exposed value. This reduces the range of values and makes the reflections more stable to denoise, but reduces quality.</td>
64+
</tr>
6065
<tr>
6166
<td><strong>Mode</strong></td>
6267
<td></td>
@@ -82,11 +87,6 @@
8287
<td></td>
8388
<td>Controls the maximum length of reflection rays. The higher this value is, the more resource-intensive ray-traced reflection is if a ray doesn't find an intersection.</td>
8489
</tr>
85-
<tr>
86-
<td><strong>Clamp Value</strong></td>
87-
<td></td>
88-
<td>Controls the threshold that HDRP uses to clamp the pre-exposed value. This reduces the range of values and makes the reflections more stable to denoise, but reduces quality.</td>
89-
</tr>
9090
<tr>
9191
<td><strong>Full Resolution</strong></td>
9292
<td></td>

Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ void RayTracingQualityModeGUI()
149149
PropertyField(m_SmoothnessFadeStart, k_SmoothnessFadeStartText);
150150
m_SmoothnessFadeStart.value.floatValue = Mathf.Max(m_MinSmoothness.value.floatValue, m_SmoothnessFadeStart.value.floatValue);
151151
PropertyField(m_RayLength, k_RayLengthText);
152-
PropertyField(m_ClampValue, k_ClampValueText);
153152
PropertyField(m_SampleCount, k_SampleCountText);
154153
PropertyField(m_BounceCount, k_BounceCountText);
155154
PropertyField(m_Denoise, k_DenoiseText);
@@ -172,7 +171,6 @@ void RayTracingPerformanceModeGUI(bool mixed)
172171
PropertyField(m_SmoothnessFadeStart, k_SmoothnessFadeStartText);
173172
m_SmoothnessFadeStart.value.floatValue = Mathf.Max(m_MinSmoothness.value.floatValue, m_SmoothnessFadeStart.value.floatValue);
174173
PropertyField(m_RayLength, k_RayLengthText);
175-
PropertyField(m_ClampValue, k_ClampValueText);
176174
PropertyField(m_FullResolution, k_FullResolutionText);
177175
if (mixed)
178176
PropertyField(m_RayMaxIterationsRT, k_MaxMixedRaySteps);
@@ -206,6 +204,8 @@ void RayTracedReflectionGUI(RayCastingMode tracingMode)
206204
PropertyField(m_LayerMask, k_LayerMaskText);
207205
PropertyField(m_TextureLodBias, k_TextureLodBiasText);
208206

207+
PropertyField(m_ClampValue, k_ClampValueText);
208+
209209
if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Both)
210210
{
211211
if (tracingMode == RayCastingMode.RayTracing)
@@ -393,7 +393,6 @@ public override void LoadSettingsFromQualityPreset(RenderPipelineSettings settin
393393
CopySetting(ref m_MinSmoothness, settings.lightingQualitySettings.RTRMinSmoothness[level]);
394394
CopySetting(ref m_SmoothnessFadeStart, settings.lightingQualitySettings.RTRSmoothnessFadeStart[level]);
395395
CopySetting(ref m_RayLength, settings.lightingQualitySettings.RTRRayLength[level]);
396-
CopySetting(ref m_ClampValue, settings.lightingQualitySettings.RTRClampValue[level]);
397396
CopySetting(ref m_FullResolution, settings.lightingQualitySettings.RTRFullResolution[level]);
398397
CopySetting(ref m_RayMaxIterationsRT, settings.lightingQualitySettings.RTRRayMaxIterations[level]);
399398
CopySetting(ref m_Denoise, settings.lightingQualitySettings.RTRDenoise[level]);

Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ public class Styles
9090
public static readonly GUIContent RTRMinSmoothness = EditorGUIUtility.TrTextContent("Minimum Smoothness");
9191
public static readonly GUIContent RTRSmoothnessFadeStart = EditorGUIUtility.TrTextContent("Smoothness Fade Start");
9292
public static readonly GUIContent RTRRayLength = EditorGUIUtility.TrTextContent("Max Ray Length");
93-
public static readonly GUIContent RTRClampValue = EditorGUIUtility.TrTextContent("Clamp Value");
9493
public static readonly GUIContent RTRFullResolution = EditorGUIUtility.TrTextContent("Full Resolution");
9594
public static readonly GUIContent RTRRayMaxIterations = EditorGUIUtility.TrTextContent("Ray Max Iterations");
9695
public static readonly GUIContent RTRDenoise = EditorGUIUtility.TrTextContent("Denoise");
@@ -100,7 +99,6 @@ public class Styles
10099
// RTGI
101100
public static readonly GUIContent RTGISettingsSubTitle = EditorGUIUtility.TrTextContent("Ray Traced Global Illumination (Performance)");
102101
public static readonly GUIContent RTGIRayLength = EditorGUIUtility.TrTextContent("Max Ray Length");
103-
public static readonly GUIContent RTGIClampValue = EditorGUIUtility.TrTextContent("Clamp Value");
104102
public static readonly GUIContent RTGIFullResolution = EditorGUIUtility.TrTextContent("Full Resolution");
105103
public static readonly GUIContent RTGIRaySteps = EditorGUIUtility.TrTextContent("Ray Steps");
106104
public static readonly GUIContent RTGIDenoise = EditorGUIUtility.TrTextContent("Denoise");

Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,6 @@ static void DrawRTRQualitySetting(SerializedHDRenderPipelineAsset serialized, in
11561156
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTRMinSmoothness.GetArrayElementAtIndex(tier), Styles.RTRMinSmoothness);
11571157
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTRSmoothnessFadeStart.GetArrayElementAtIndex(tier), Styles.RTRSmoothnessFadeStart);
11581158
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTRRayLength.GetArrayElementAtIndex(tier), Styles.RTRRayLength);
1159-
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTRClampValue.GetArrayElementAtIndex(tier), Styles.RTRClampValue);
11601159
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTRFullResolution.GetArrayElementAtIndex(tier), Styles.RTRFullResolution);
11611160
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTRRayMaxIterations.GetArrayElementAtIndex(tier), Styles.RTRRayMaxIterations);
11621161
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTRDenoise.GetArrayElementAtIndex(tier), Styles.RTRDenoise);
@@ -1177,7 +1176,6 @@ static void DrawVolumetricFogQualitySetting(SerializedHDRenderPipelineAsset seri
11771176
static void DrawRTGIQualitySetting(SerializedHDRenderPipelineAsset serialized, int tier)
11781177
{
11791178
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTGIRayLength.GetArrayElementAtIndex(tier), Styles.RTGIRayLength);
1180-
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTGIClampValue.GetArrayElementAtIndex(tier), Styles.RTGIClampValue);
11811179
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTGIFullResolution.GetArrayElementAtIndex(tier), Styles.RTGIFullResolution);
11821180
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTGIRaySteps.GetArrayElementAtIndex(tier), Styles.RTGIRaySteps);
11831181
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTGIDenoise.GetArrayElementAtIndex(tier), Styles.RTGIDenoise);

Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ void RayTracingPerformanceModeGUI(bool mixed)
145145
using (new QualityScope(this))
146146
{
147147
PropertyField(m_RayLength, k_RayLengthText);
148-
PropertyField(m_ClampValue);
149148
PropertyField(m_FullResolution);
150149
if (mixed)
151150
PropertyField(m_MaxMixedRaySteps, k_MaxMixedRaySteps);
@@ -158,7 +157,6 @@ void RayTracingQualityModeGUI()
158157
using (new QualityScope(this))
159158
{
160159
PropertyField(m_RayLength, k_RayLengthText);
161-
PropertyField(m_ClampValue);
162160
PropertyField(m_SampleCount);
163161
PropertyField(m_BounceCount);
164162
DenoiserGUI();
@@ -212,6 +210,8 @@ public override void OnInspectorGUI()
212210
}
213211
}
214212

213+
PropertyField(m_ClampValue);
214+
215215
if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Both)
216216
{
217217
if (tracingMode == RayCastingMode.RayTracing)
@@ -328,7 +328,6 @@ public override void LoadSettingsFromQualityPreset(RenderPipelineSettings settin
328328
{
329329
// RTGI
330330
CopySetting(ref m_RayLength, settings.lightingQualitySettings.RTGIRayLength[level]);
331-
CopySetting(ref m_ClampValue, settings.lightingQualitySettings.RTGIClampValue[level]);
332331
CopySetting(ref m_FullResolution, settings.lightingQualitySettings.RTGIFullResolution[level]);
333332
CopySetting(ref m_MaxMixedRaySteps, settings.lightingQualitySettings.RTGIRaySteps[level]);
334333
CopySetting(ref m_Denoise, settings.lightingQualitySettings.RTGIDenoise[level]);

Packages/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedLightingQualitySettings.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class SerializedLightingQualitySettings
3030
public SerializedProperty RTRMinSmoothness;
3131
public SerializedProperty RTRSmoothnessFadeStart;
3232
public SerializedProperty RTRRayLength;
33-
public SerializedProperty RTRClampValue;
3433
public SerializedProperty RTRFullResolution;
3534
public SerializedProperty RTRRayMaxIterations;
3635
public SerializedProperty RTRDenoise;
@@ -40,7 +39,6 @@ class SerializedLightingQualitySettings
4039
// Ray Traced Global Illumination
4140
public SerializedProperty RTGIRayLength;
4241
public SerializedProperty RTGIFullResolution;
43-
public SerializedProperty RTGIClampValue;
4442
public SerializedProperty RTGIRaySteps;
4543
public SerializedProperty RTGIDenoise;
4644
public SerializedProperty RTGIHalfResDenoise;
@@ -85,7 +83,6 @@ public SerializedLightingQualitySettings(SerializedProperty root)
8583
RTRMinSmoothness = root.Find((GlobalLightingQualitySettings s) => s.RTRMinSmoothness);
8684
RTRSmoothnessFadeStart = root.Find((GlobalLightingQualitySettings s) => s.RTRSmoothnessFadeStart);
8785
RTRRayLength = root.Find((GlobalLightingQualitySettings s) => s.RTRRayLength);
88-
RTRClampValue = root.Find((GlobalLightingQualitySettings s) => s.RTRClampValue);
8986
RTRFullResolution = root.Find((GlobalLightingQualitySettings s) => s.RTRFullResolution);
9087
RTRRayMaxIterations = root.Find((GlobalLightingQualitySettings s) => s.RTRRayMaxIterations);
9188
RTRDenoise = root.Find((GlobalLightingQualitySettings s) => s.RTRDenoise);
@@ -95,7 +92,6 @@ public SerializedLightingQualitySettings(SerializedProperty root)
9592
// Ray Traced Global Illumination
9693
RTGIRayLength = root.Find((GlobalLightingQualitySettings s) => s.RTGIRayLength);
9794
RTGIFullResolution = root.Find((GlobalLightingQualitySettings s) => s.RTGIFullResolution);
98-
RTGIClampValue = root.Find((GlobalLightingQualitySettings s) => s.RTGIClampValue);
9995
RTGIRaySteps = root.Find((GlobalLightingQualitySettings s) => s.RTGIRaySteps);
10096
RTGIDenoise = root.Find((GlobalLightingQualitySettings s) => s.RTGIDenoise);
10197
RTGIHalfResDenoise = root.Find((GlobalLightingQualitySettings s) => s.RTGIHalfResDenoise);

Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/GlobalIllumination.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,13 @@ public float clampValue
198198
{
199199
get
200200
{
201-
if (!UsesQualitySettings() || UsesQualityMode())
202-
return m_ClampValue.value;
203-
else
204-
return GetLightingQualitySettings().RTGIClampValue[(int)quality.value];
201+
return m_ClampValue.value;
205202
}
206203
set { m_ClampValue.value = value; }
207204
}
208205
[SerializeField, FormerlySerializedAs("clampValue")]
209206
[Tooltip("Controls the clamp of intensity.")]
210-
private ClampedFloatParameter m_ClampValue = new ClampedFloatParameter(1.0f, 0.001f, 10.0f);
207+
private MinFloatParameter m_ClampValue = new MinFloatParameter(100.0f, 0.001f);
211208

212209
/// <summary>
213210
/// Controls which version of the effect should be used.

Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.compute

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ void REPROJECT_GLOBAL_ILLUMINATION(uint3 dispatchThreadId : SV_DispatchThreadID,
307307

308308
if((RAYMARCHINGFALLBACKHIERARCHY_SKY & _RayMarchingFallbackHierarchy) && weight < 1.0f)
309309
{
310-
color += SAMPLE_TEXTURECUBE_ARRAY_LOD(_SkyTexture, s_trilinear_clamp_sampler, sampleDir, 0.0, 0).xyz * (1.0 - weight);
310+
color += EvaluateAmbientProbe(normalData.normalWS) * (1.0 - weight);
311311
weight = 1.0;
312312
}
313313
}

Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflection.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,13 @@ public float clampValue
253253
{
254254
get
255255
{
256-
if (!UsesQualitySettings() || UsesRayTracingQualityMode())
257-
return m_ClampValue.value;
258-
else
259-
return GetLightingQualitySettings().RTRClampValue[(int)quality.value];
256+
return m_ClampValue.value;
260257
}
261258
set { m_ClampValue.value = value; }
262259
}
263260
[SerializeField, FormerlySerializedAs("clampValue")]
264261
[Tooltip("Clamps the exposed intensity, this only affects reflections on opaque objects.")]
265-
private ClampedFloatParameter m_ClampValue = new ClampedFloatParameter(1.0f, 0.001f, 10.0f);
262+
private MinFloatParameter m_ClampValue = new MinFloatParameter(100.0f, 0.001f);
266263

267264
/// <summary>
268265
/// Enable denoising on the ray traced reflections.

0 commit comments

Comments
 (0)