Skip to content

Commit

Permalink
Fix Quality Settings Behavior for Raytraced Modes (RTR, RTGI) (#2791)
Browse files Browse the repository at this point in the history
* Revert the original PR

* Apply fix for SSGI

* Apply fix for RTR quality component settings not saving

* Switching SSGI/SSR modes with indicate custom quality if changes were made to quality settings

* Update changelog

* Formatting

Co-authored-by: Sebastien Lagarde <sebastien@unity3d.com>
  • Loading branch information
johnpars and sebastienlagarde committed Nov 30, 2020
1 parent 91422f8 commit d29c35a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 10 deletions.
3 changes: 3 additions & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed
- Fixed probe volumes debug views.
- Fixed lookdev movement.
- Fixed volume component tooltips using the same parameter name.
- Fixed issue with saving some quality settings in volume overrides (case 1293747)

### Changed
- Removed the material pass probe volumes evaluation mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,11 @@ public override void OnEnable()

void RayTracingQualityModeGUI()
{
base.OnInspectorGUI();
using (new HDEditorUtils.IndentScope())
using (new QualityScope(this))
{
PropertyField(m_MinSmoothness, k_MinimumSmoothnessText);
PropertyField(m_SmoothnessFadeStart, k_SmoothnessFadeStartText);
m_SmoothnessFadeStart.value.floatValue = Mathf.Max(m_MinSmoothness.value.floatValue, m_SmoothnessFadeStart.value.floatValue);
m_SmoothnessFadeStart.value.floatValue = Mathf.Max(m_MinSmoothness.value.floatValue, m_SmoothnessFadeStart.value.floatValue);
PropertyField(m_RayLength, k_RayLengthText);
PropertyField(m_ClampValue, k_ClampValueText);
PropertyField(m_SampleCount, k_SampleCountText);
Expand Down Expand Up @@ -291,5 +289,22 @@ public override void LoadSettingsFromQualityPreset(RenderPipelineSettings settin
else
CopySetting(ref m_RayMaxIterations, settings.lightingQualitySettings.SSRMaxRaySteps[level]);
}

public override bool QualityEnabled()
{
// Quality always used for SSR
if (!HDRenderPipeline.rayTracingSupportedBySystem || !m_RayTracing.value.boolValue)
return true;

// Handle the quality usage for RTGI
HDRenderPipelineAsset currentAsset = HDRenderPipeline.currentAsset;

var bothSupportedAndPerformanceMode = currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Both
&& m_Mode.value.GetEnumValue<RayTracingMode>() == RayTracingMode.Performance;

var performanceSupported = currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Performance;

return bothSupportedAndPerformanceMode || performanceSupported;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ public override void OnInspectorGUI()
break;
case RayTracingMode.Quality:
{
base.OnInspectorGUI(); // Quality Setting

using (new HDEditorUtils.IndentScope())
using (new QualityScope(this))
{
PropertyField(m_RayLength, k_RayLengthText);
Expand All @@ -164,8 +161,6 @@ public override void OnInspectorGUI()
else if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode ==
RenderPipelineSettings.SupportedRayTracingMode.Quality)
{
base.OnInspectorGUI(); // Quality Setting
EditorGUI.indentLevel++;
using (new QualityScope(this))
{
PropertyField(m_RayLength, k_RayLengthText);
Expand Down Expand Up @@ -269,5 +264,23 @@ public override void LoadSettingsFromQualityPreset(RenderPipelineSettings settin
CopySetting(ref m_RaySteps, settings.lightingQualitySettings.SSGIRaySteps[level]);
CopySetting(ref m_FilterRadius, settings.lightingQualitySettings.SSGIFilterRadius[level]);
}

public override bool QualityEnabled()
{
// Quality always used for SSGI
if (!HDRenderPipeline.rayTracingSupportedBySystem || !m_RayTracing.value.boolValue)
return true;

// Handle the quality usage for RTGI
var currentAsset = HDRenderPipeline.currentAsset;

var bothSupportedAndPerformanceMode = (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode ==
RenderPipelineSettings.SupportedRayTracingMode.Both) && (m_Mode.value.GetEnumValue<RayTracingMode>() == RayTracingMode.Performance);

var performanceMode = currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode ==
RenderPipelineSettings.SupportedRayTracingMode.Performance;

return bothSupportedAndPerformanceMode || performanceMode;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public override void OnEnable()
{
serializedObject.Update();

if (m_QualitySetting.value.intValue < k_CustomQuality)
if (m_QualitySetting.value.intValue < k_CustomQuality && QualityEnabled())
LoadSettingsFromQualityPreset(pipeline.currentPlatformRenderPipelineSettings, m_QualitySetting.value.intValue);

serializedObject.ApplyModifiedProperties();
Expand All @@ -161,7 +161,7 @@ public override void OnInspectorGUI()
// When a quality preset changes, we want to detect and reflect the settings in the UI. PropertyFields mirror the contents of one memory loccation, so
// the idea is that we copy the presets to that location. This logic is optional, if volume components don't override the helper functions at the end,
// they will continue to work, but the preset settings will not be reflected in the UI.
if (EditorGUI.EndChangeCheck())
if (EditorGUI.EndChangeCheck() && QualityEnabled())
{
int newQualityLevel = m_QualitySetting.value.intValue;

Expand Down Expand Up @@ -242,5 +242,11 @@ public virtual void LoadSettingsFromQualityPreset(RenderPipelineSettings setting
/// This function should be overriden by a volume component to load a custom preset setting from an opaque binary blob (as returned from SaveCustomQualitySettingsAsObject)
/// </summary>
public virtual void LoadSettingsFromObject(QualitySettingsBlob settings) {}

/// <summary>
/// This function should be overriden by a volume component to enable the quality setting functionality only in certain cases.
/// </summary>
/// <returns></returns>
public virtual bool QualityEnabled() => true;
}
}

0 comments on commit d29c35a

Please sign in to comment.