From 73f2073cb68df5798768e5be50e6943e7eed3067 Mon Sep 17 00:00:00 2001 From: John Parsaie Date: Wed, 28 Oct 2020 15:11:56 -0400 Subject: [PATCH] Initial commit --- .../Lighting/Shadow/HDShadowSettingsEditor.cs | 35 +++++++++--------- .../PathTracing/PathTracingEditor.cs | 17 ++++----- .../Raytracing/RecursiveRenderingEditor.cs | 14 ++++---- .../Raytracing/SubSurfaceScatteringEditor.cs | 7 ++-- .../PhysicallyBasedSkyEditor.cs | 20 ++++++----- .../Editor/Sky/SkySettingsEditor.cs | 36 ++++++++++--------- 6 files changed, 70 insertions(+), 59 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs index 36cd9bcf464..dd1c8e1bef3 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/HDShadowSettingsEditor.cs @@ -78,26 +78,30 @@ public override void OnInspectorGUI() if (!m_CascadeShadowSplitCount.value.hasMultipleDifferentValues) { - EditorGUI.indentLevel++; - int cascadeCount = m_CascadeShadowSplitCount.value.intValue; - Debug.Assert(cascadeCount <= 4); // If we add support for more than 4 cascades, then we should add new entries in the next line - string[] cascadeOrder = { "first", "second", "third" }; + int cascadeCount; - for (int i = 0; i < cascadeCount - 1; i++) + using (new HDEditorUtils.IndentScope()) { - string tooltipOverride = (unit == Unit.Metric) ? - $"Distance from the Camera (in meters) to the {cascadeOrder[i]} cascade split." : - $"Distance from the Camera (as a percentage of Max Distance) to the {cascadeOrder[i]} cascade split."; - PropertyField(m_CascadeShadowSplits[i], EditorGUIUtility.TrTextContent(string.Format("Split {0}", i + 1), tooltipOverride)); - } + cascadeCount = m_CascadeShadowSplitCount.value.intValue; + Debug.Assert(cascadeCount <= 4); // If we add support for more than 4 cascades, then we should add new entries in the next line + string[] cascadeOrder = { "first", "second", "third" }; - if (HDRenderPipeline.s_UseCascadeBorders) - { - EditorGUILayout.Space(); + for (int i = 0; i < cascadeCount - 1; i++) + { + string tooltipOverride = (unit == Unit.Metric) ? + $"Distance from the Camera (in meters) to the {cascadeOrder[i]} cascade split." : + $"Distance from the Camera (as a percentage of Max Distance) to the {cascadeOrder[i]} cascade split."; + PropertyField(m_CascadeShadowSplits[i], EditorGUIUtility.TrTextContent(string.Format("Split {0}", i + 1), tooltipOverride)); + } - for (int i = 0; i < cascadeCount; i++) + if (HDRenderPipeline.s_UseCascadeBorders) { - PropertyField(m_CascadeShadowBorders[i], EditorGUIUtility.TrTextContent(string.Format("Border {0}", i + 1))); + EditorGUILayout.Space(); + + for (int i = 0; i < cascadeCount; i++) + { + PropertyField(m_CascadeShadowBorders[i], EditorGUIUtility.TrTextContent(string.Format("Border {0}", i + 1))); + } } } @@ -105,7 +109,6 @@ public override void OnInspectorGUI() GUILayout.Label("Cascade splits"); ShadowCascadeGUI.DrawCascadeSplitGUI(m_CascadeShadowSplits, HDRenderPipeline.s_UseCascadeBorders ? m_CascadeShadowBorders : null, (uint)cascadeCount, blendLastCascade: true, useMetric: unit == Unit.Metric, baseMetric: m_MaxShadowDistance.value.floatValue); - EditorGUI.indentLevel--; } HDRenderPipeline hdrp = UnityEngine.Rendering.RenderPipelineManager.currentPipeline as HDRenderPipeline; diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/PathTracing/PathTracingEditor.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/PathTracing/PathTracingEditor.cs index 38718398b5f..714dd9d27e9 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/PathTracing/PathTracingEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/PathTracing/PathTracingEditor.cs @@ -1,7 +1,7 @@ using System; using UnityEditor.Rendering; - +using UnityEditor.Rendering.HighDefinition; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; @@ -47,13 +47,14 @@ public override void OnInspectorGUI() if (m_Enable.overrideState.boolValue && m_Enable.value.boolValue) { - EditorGUI.indentLevel++; - PropertyField(m_LayerMask); - PropertyField(m_MaxSamples); - PropertyField(m_MinDepth); - PropertyField(m_MaxDepth); - PropertyField(m_MaxIntensity); - EditorGUI.indentLevel--; + using (new HDEditorUtils.IndentScope()) + { + PropertyField(m_LayerMask); + PropertyField(m_MaxSamples); + PropertyField(m_MinDepth); + PropertyField(m_MaxDepth); + PropertyField(m_MaxIntensity); + } // Make sure MaxDepth is always greater or equal than MinDepth m_MaxDepth.value.intValue = Math.Max(m_MinDepth.value.intValue, m_MaxDepth.value.intValue); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RecursiveRenderingEditor.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RecursiveRenderingEditor.cs index 75d54e0d7c3..96783615007 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RecursiveRenderingEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RecursiveRenderingEditor.cs @@ -1,4 +1,5 @@ using UnityEditor.Rendering; +using UnityEditor.Rendering.HighDefinition; using UnityEngine.Rendering.HighDefinition; using UnityEngine.Rendering; @@ -42,12 +43,13 @@ public override void OnInspectorGUI() if (m_Enable.overrideState.boolValue && m_Enable.value.boolValue) { - EditorGUI.indentLevel++; - PropertyField(m_LayerMask); - PropertyField(m_MaxDepth); - PropertyField(m_RayLength); - PropertyField(m_MinSmoothness); - EditorGUI.indentLevel--; + using (new HDEditorUtils.IndentScope()) + { + PropertyField(m_LayerMask); + PropertyField(m_MaxDepth); + PropertyField(m_RayLength); + PropertyField(m_MinSmoothness); + } } } } diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/SubSurfaceScatteringEditor.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/SubSurfaceScatteringEditor.cs index a9bcd92ee4d..2b83edeb1b0 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/SubSurfaceScatteringEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/SubSurfaceScatteringEditor.cs @@ -34,9 +34,10 @@ public override void OnInspectorGUI() PropertyField(m_RayTracing); if (m_RayTracing.overrideState.boolValue && m_RayTracing.value.boolValue) { - EditorGUI.indentLevel++; - PropertyField(m_SampleCount); - EditorGUI.indentLevel--; + using (new HDEditorUtils.IndentScope()) + { + PropertyField(m_SampleCount); + } } } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Sky/PhysicallyBasedSky/PhysicallyBasedSkyEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Sky/PhysicallyBasedSky/PhysicallyBasedSkyEditor.cs index a2490a76a33..5dd28e72c96 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Sky/PhysicallyBasedSky/PhysicallyBasedSkyEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Sky/PhysicallyBasedSky/PhysicallyBasedSkyEditor.cs @@ -118,17 +118,19 @@ public override void OnInspectorGUI() else { PropertyField(m_SphericalMode); - EditorGUI.indentLevel++; - bool isSpherical = !m_SphericalMode.overrideState.boolValue || m_SphericalMode.value.boolValue; - if (isSpherical) + + using (new HDEditorUtils.IndentScope()) { - PropertyField(m_PlanetCenterPosition); - if (type == PhysicallyBasedSkyModel.Custom) - PropertyField(m_PlanetaryRadius); + bool isSpherical = !m_SphericalMode.overrideState.boolValue || m_SphericalMode.value.boolValue; + if (isSpherical) + { + PropertyField(m_PlanetCenterPosition); + if (type == PhysicallyBasedSkyModel.Custom) + PropertyField(m_PlanetaryRadius); + } + else + PropertyField(m_SeaLevel); } - else - PropertyField(m_SeaLevel); - EditorGUI.indentLevel--; PropertyField(m_PlanetRotation); PropertyField(m_GroundColorTexture); diff --git a/com.unity.render-pipelines.high-definition/Editor/Sky/SkySettingsEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Sky/SkySettingsEditor.cs index 6c80fe66d21..e64a036d7d7 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Sky/SkySettingsEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Sky/SkySettingsEditor.cs @@ -91,23 +91,24 @@ protected void CommonSkySettingsGUI() } } - EditorGUI.indentLevel++; - if (m_IntensityMode.value.GetEnumValue() == SkyIntensityMode.Exposure) - PropertyField(m_SkyExposure); - else if (m_IntensityMode.value.GetEnumValue() == SkyIntensityMode.Multiplier) - PropertyField(m_SkyMultiplier); - else if (m_IntensityMode.value.GetEnumValue() == SkyIntensityMode.Lux) + using (new HDEditorUtils.IndentScope()) { - PropertyField(m_DesiredLuxValue); + if (m_IntensityMode.value.GetEnumValue() == SkyIntensityMode.Exposure) + PropertyField(m_SkyExposure); + else if (m_IntensityMode.value.GetEnumValue() == SkyIntensityMode.Multiplier) + PropertyField(m_SkyMultiplier); + else if (m_IntensityMode.value.GetEnumValue() == SkyIntensityMode.Lux) + { + PropertyField(m_DesiredLuxValue); - // Show the multiplier - EditorGUILayout.HelpBox(System.String.Format("Upper hemisphere lux value: {0}\nAbsolute multiplier: {1}", - m_UpperHemisphereLuxValue.value.floatValue, - (m_DesiredLuxValue.value.floatValue / m_UpperHemisphereLuxValue.value.floatValue) - ), MessageType.Info); + // Show the multiplier + EditorGUILayout.HelpBox(System.String.Format( + "Upper hemisphere lux value: {0}\nAbsolute multiplier: {1}", + m_UpperHemisphereLuxValue.value.floatValue, + (m_DesiredLuxValue.value.floatValue / m_UpperHemisphereLuxValue.value.floatValue) + ), MessageType.Info); + } } - - EditorGUI.indentLevel--; } if ((m_CommonUIElementsMask & (uint)SkySettingsUIElement.Rotation) != 0) PropertyField(m_SkyRotation); @@ -117,9 +118,10 @@ protected void CommonSkySettingsGUI() PropertyField(m_EnvUpdateMode); if (!m_EnvUpdateMode.value.hasMultipleDifferentValues && m_EnvUpdateMode.value.intValue == (int)EnvironmentUpdateMode.Realtime) { - EditorGUI.indentLevel++; - PropertyField(m_EnvUpdatePeriod); - EditorGUI.indentLevel--; + using (new HDEditorUtils.IndentScope()) + { + PropertyField(m_EnvUpdatePeriod); + } } } if ((m_CommonUIElementsMask & (uint)SkySettingsUIElement.IncludeSunInBaking) != 0)