Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving the denoiser for RTGI (case 1346383) #5078

Merged
merged 9 commits into from Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Expand Up @@ -415,6 +415,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Improved a bit the area cookie behavior for higher smoothness values to reduce artifacts.
- Improved volumetric clouds (added new noise for erosion, reduced ghosting while flying through, altitude distortion, ghosting when changing from local to distant clouds, fix issue in wind distortion along the Z axis).
- Fixed upscaling issue that is exagerated by DLSS (case 1347250).
- Improvements to the RTGI denoising.

## [11.0.0] - 2020-10-21

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -60,7 +60,6 @@ HDRP uses the [Volume](Volumes.md) framework to calculate SSGI, so to enable and
| **Max Ray Length** | Controls the maximal length of rays. The higher this value is, the more resource-intensive ray traced global illumination is. |
| **Clamp Value** | 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. |
| **Full Resolution** | Enable this feature to increase the ray budget to one ray per pixel, per frame. Disable this feature to decrease the ray budget to one ray per four pixels, per frame.<br/>This property only appears if you set **Mode** to **Performance**. |
| **Upscale Radius** | Controls the radius of the up-scaler that HDRP uses to build the GI. The larger the radius, the more neighbors HDRP uses to build the GI, the better the quality.<br/>This property only appears if you set **Mode** to **Performance**. |
| **Sample Count** | Controls the number of rays per pixel per frame. Increasing this value increases execution time linearly.<br/>This property only appears if you set **Mode** to **Quality**. |
| **Bounce Count** | Controls the number of bounces that global illumination rays can do. Increasing this value increases execution time exponentially.<br/>This property only appears if you set **Mode** to **Quality**. |
| **Max Mixed Ray Steps** | Sets the maximum number of iterations that the algorithm can execute before it stops trying to find an intersection with a Mesh. For example, if you set the number of iterations to 1000 and the algorithm only needs 10 to find an intersection, the algorithm terminates after 10 iterations. If you set this value too low, the algorithm may terminate too early and abruptly stop global illumination. This property only appears if you set **Tracing** to **Mixed**. |
Expand Down
Expand Up @@ -94,7 +94,6 @@ public class Styles
public static readonly GUIContent RTGIRayLength = EditorGUIUtility.TrTextContent("Max Ray Length");
public static readonly GUIContent RTGIClampValue = EditorGUIUtility.TrTextContent("Clamp Value");
public static readonly GUIContent RTGIFullResolution = EditorGUIUtility.TrTextContent("Full Resolution");
public static readonly GUIContent RTGIUpScaleRadius = EditorGUIUtility.TrTextContent("Upscale Radius");
public static readonly GUIContent RTGIRaySteps = EditorGUIUtility.TrTextContent("Ray Steps");
public static readonly GUIContent RTGIDenoise = EditorGUIUtility.TrTextContent("Denoise");
public static readonly GUIContent RTGIHalfResDenoise = EditorGUIUtility.TrTextContent("Half Resolution Denoiser");
Expand Down
Expand Up @@ -789,7 +789,6 @@ static void DrawRTGIQualitySetting(SerializedHDRenderPipelineAsset serialized, i
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTGIRayLength.GetArrayElementAtIndex(tier), Styles.RTGIRayLength);
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTGIClampValue.GetArrayElementAtIndex(tier), Styles.RTGIClampValue);
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTGIFullResolution.GetArrayElementAtIndex(tier), Styles.RTGIFullResolution);
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTGIUpScaleRadius.GetArrayElementAtIndex(tier), Styles.RTGIUpScaleRadius);
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTGIRaySteps.GetArrayElementAtIndex(tier), Styles.RTGIRaySteps);
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTGIDenoise.GetArrayElementAtIndex(tier), Styles.RTGIDenoise);
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightingQualitySettings.RTGIHalfResDenoise.GetArrayElementAtIndex(tier), Styles.RTGIHalfResDenoise);
Expand Down
Expand Up @@ -31,7 +31,6 @@ class GlobalIlluminatorEditor : VolumeComponentWithQualityEditor

// Performance
SerializedDataParameter m_FullResolution;
SerializedDataParameter m_UpscaleRadius;

// Quality
SerializedDataParameter m_SampleCount;
Expand Down Expand Up @@ -76,7 +75,6 @@ public override void OnEnable()

// Performance
m_FullResolution = Unpack(o.Find(x => x.fullResolution));
m_UpscaleRadius = Unpack(o.Find(x => x.upscaleRadius));

// Quality
m_SampleCount = Unpack(o.Find(x => x.sampleCount));
Expand Down Expand Up @@ -140,7 +138,6 @@ void RayTracingPerformanceModeGUI(bool mixed)
PropertyField(m_RayLength, k_RayLengthText);
PropertyField(m_ClampValue);
PropertyField(m_FullResolution);
PropertyField(m_UpscaleRadius);
if (mixed)
PropertyField(m_MaxMixedRaySteps, k_MaxMixedRaySteps);
DenoiserGUI();
Expand Down Expand Up @@ -253,7 +250,6 @@ public override QualitySettingsBlob SaveCustomQualitySettingsAsObject(QualitySet
settings.Save<float>(m_RayLength);
settings.Save<float>(m_ClampValue);
settings.Save<bool>(m_FullResolution);
settings.Save<int>(m_UpscaleRadius);
settings.Save<int>(m_MaxMixedRaySteps);
settings.Save<bool>(m_Denoise);
settings.Save<bool>(m_HalfResolutionDenoiser);
Expand All @@ -279,7 +275,6 @@ public override void LoadSettingsFromObject(QualitySettingsBlob settings)
settings.TryLoad<float>(ref m_RayLength);
settings.TryLoad<float>(ref m_ClampValue);
settings.TryLoad<bool>(ref m_FullResolution);
settings.TryLoad<int>(ref m_UpscaleRadius);
settings.TryLoad<int>(ref m_MaxMixedRaySteps);
settings.TryLoad<bool>(ref m_Denoise);
settings.TryLoad<bool>(ref m_HalfResolutionDenoiser);
Expand All @@ -306,7 +301,6 @@ public override void LoadSettingsFromQualityPreset(RenderPipelineSettings settin
CopySetting(ref m_RayLength, settings.lightingQualitySettings.RTGIRayLength[level]);
CopySetting(ref m_ClampValue, settings.lightingQualitySettings.RTGIClampValue[level]);
CopySetting(ref m_FullResolution, settings.lightingQualitySettings.RTGIFullResolution[level]);
CopySetting(ref m_UpscaleRadius, settings.lightingQualitySettings.RTGIUpScaleRadius[level]);
CopySetting(ref m_MaxMixedRaySteps, settings.lightingQualitySettings.RTGIRaySteps[level]);
CopySetting(ref m_Denoise, settings.lightingQualitySettings.RTGIDenoise[level]);
CopySetting(ref m_HalfResolutionDenoiser, settings.lightingQualitySettings.RTGIHalfResDenoise[level]);
Expand Down
Expand Up @@ -41,7 +41,6 @@ class SerializedLightingQualitySettings
public SerializedProperty RTGIRayLength;
public SerializedProperty RTGIFullResolution;
public SerializedProperty RTGIClampValue;
public SerializedProperty RTGIUpScaleRadius;
public SerializedProperty RTGIRaySteps;
public SerializedProperty RTGIDenoise;
public SerializedProperty RTGIHalfResDenoise;
Expand Down Expand Up @@ -97,7 +96,6 @@ public SerializedLightingQualitySettings(SerializedProperty root)
RTGIRayLength = root.Find((GlobalLightingQualitySettings s) => s.RTGIRayLength);
RTGIFullResolution = root.Find((GlobalLightingQualitySettings s) => s.RTGIFullResolution);
RTGIClampValue = root.Find((GlobalLightingQualitySettings s) => s.RTGIClampValue);
RTGIUpScaleRadius = root.Find((GlobalLightingQualitySettings s) => s.RTGIUpScaleRadius);
RTGIRaySteps = root.Find((GlobalLightingQualitySettings s) => s.RTGIRaySteps);
RTGIDenoise = root.Find((GlobalLightingQualitySettings s) => s.RTGIDenoise);
RTGIHalfResDenoise = root.Find((GlobalLightingQualitySettings s) => s.RTGIHalfResDenoise);
Expand Down
Expand Up @@ -211,24 +211,6 @@ public bool fullResolution
[Tooltip("Full Resolution")]
private BoolParameter m_FullResolution = new BoolParameter(false);

/// <summary>
/// Defines what radius value should be used to pre-filter the signal.
/// </summary>
public int upscaleRadius
{
get
{
if (!UsesQualitySettings())
return m_UpscaleRadius.value;
else
return GetLightingQualitySettings().RTGIUpScaleRadius[(int)quality.value];
}
set { m_UpscaleRadius.value = value; }
}
[SerializeField, FormerlySerializedAs("upscaleRadius")]
[Tooltip("Upscale Radius")]
private ClampedIntParameter m_UpscaleRadius = new ClampedIntParameter(2, 2, 4);

// Quality
/// <summary>
/// Number of samples for evaluating the effect.
Expand Down
Expand Up @@ -12,6 +12,19 @@ static const int2 IndexToLocalOffsetCoords[9] = {int2(-1, -1), int2(0, -1), int
, int2(-1, 0), int2(0, 0), int2(1, 0)
, int2(-1, 1) , int2(0, 1), int2(1, 1)};

// The bilateral upscale function (2x2 neighborhood, color3 version), uniform weight version
float3 BilUpColor3_Uniform(float HiDepth, float4 LowDepths, float3 lowValue0, float3 lowValue1, float3 lowValue2, float3 lowValue3)
{
float4 weights = float4(3, 3, 3, 3) / (abs(HiDepth - LowDepths) + _UpsampleTolerance);
float TotalWeight = dot(weights, 1) + _NoiseFilterStrength;
float3 WeightedSum = lowValue0 * weights.x
+ lowValue1 * weights.y
+ lowValue2 * weights.z
+ lowValue3 * weights.w
+ _NoiseFilterStrength;
return WeightedSum / TotalWeight;
}

// THe bilateral upscale function (2x2 neighborhood, color3 version)
float3 BilUpColor3(float HiDepth, float4 LowDepths, float3 lowValue0, float3 lowValue1, float3 lowValue2, float3 lowValue3)
{
Expand Down Expand Up @@ -47,6 +60,15 @@ float BilUpSingle(float HiDepth, float4 LowDepths, float4 lowValue)
return WeightedSum / TotalWeight;
}

// The bilateral upscale function (2x2 neighborhood) (single channel version), uniform version
float BilUpSingle_Uniform(float HiDepth, float4 LowDepths, float4 lowValue)
{
float4 weights = float4(3, 3, 3, 3) / (abs(HiDepth - LowDepths) + _UpsampleTolerance);
float TotalWeight = dot(weights, 1) + _NoiseFilterStrength;
float WeightedSum = dot(lowValue, weights) + _NoiseFilterStrength;
return WeightedSum / TotalWeight;
}

// Due to compiler issues, it is not possible to use arrays to store the neighborhood values, we then store
// them in this structure
struct NeighborhoodUpsampleData3x3
Expand Down