浏览代码

[HDCameraEditor] Refactoring of FrameSettings UI

/main
Frédéric Vauchelles 7 年前
当前提交
ccc9a3ac
共有 5 个文件被更改,包括 105 次插入75 次删除
  1. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Data.cs
  2. 50
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedFrameSettingsUI.cs
  3. 38
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedLightLoopSettingsUI.cs
  4. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedUIBase.cs
  5. 84
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineInspector.cs

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Data.cs


public void Reset(SerializedHDCamera serializedHdCamera, UnityAction repaint)
{
m_SerializedHdCamera = serializedHdCamera;
serializedFrameSettingsUI.Reset(serializedHdCamera.frameSettings, repaint);
for (var i = 0; i < m_AnimBools.Length; ++i)
{

Update();
serializedFrameSettingsUI.Reset(repaint);
}
public void Update()

50
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedFrameSettingsUI.cs


using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<SerializedFrameSettingsUI, SerializedFrameSettings>;
class SerializedFrameSettingsUI : SerializedUIBase
class SerializedFrameSettingsUI : SerializedUIBase<SerializedFrameSettings>
{
public static CED.IDrawer SectionRenderingPasses = CED.FoldoutGroup(
"Rendering Passes",

"Rendering Settings",
(s, p, o) => s.isSectionExpandedRenderingSettings,
true,
CED.Action(Drawer_SectionRenderingSettings));
CED.Action(Drawer_FieldForwardRenderingOnly),
CED.FadeGroup(
(s, d, o, i) => s.isSectionExpandedUseForwardOnly.faded,
false,
CED.Action(Drawer_FieldUseDepthPrepassWithDefferedRendering),
CED.FadeGroup(
(s, d, o, i) => s.isSectionExpandedUseDepthPrepass.faded,
true,
CED.Action(Drawer_FieldRenderAlphaTestOnlyInDeferredPrepass))),
CED.Action(Drawer_SectionOtherRenderingSettings));
public static CED.IDrawer SectionXRSettings = CED.FadeGroup(
(s, d, o, i) => s.isSectionExpandedXRSupported.faded,

public AnimBool isSectionExpandedRenderingSettings { get { return m_AnimBools[2]; } }
public AnimBool isSectionExpandedXRSettings { get { return m_AnimBools[3]; } }
public AnimBool isSectionExpandedXRSupported { get { return m_AnimBools[4]; } }
public AnimBool isSectionExpandedUseForwardOnly { get { return m_AnimBools[5]; } }
public AnimBool isSectionExpandedUseDepthPrepass { get { return m_AnimBools[6]; } }
: base(5)
: base(7)
public override void Reset(UnityAction repaint)
public override void Reset(SerializedFrameSettings data, UnityAction repaint)
base.Reset(repaint);
serializedLightLoopSettingsUI.Reset(repaint);
serializedLightLoopSettingsUI.Reset(data.lightLoopSettings, repaint);
base.Reset(data, repaint);
isSectionExpandedUseForwardOnly.target = !data.enableForwardRenderingOnly.boolValue;
isSectionExpandedUseDepthPrepass.target = data.enableDepthPrepassWithDeferredRendering.boolValue;
serializedLightLoopSettingsUI.Update();
}

EditorGUILayout.PropertyField(p.enableDepthPrepassWithDeferredRendering, _.GetContent("Enable Depth Prepass With Deferred Rendering"));
EditorGUILayout.PropertyField(p.enableAlphaTestOnlyInDeferredPrepass, _.GetContent("Enable Alpha Test Only In Deferred Prepass"));
EditorGUILayout.PropertyField(p.enableAsyncCompute, _.GetContent("Enable Async Compute"));
EditorGUILayout.PropertyField(p.enableOpaqueObjects, _.GetContent("Enable Opaque Objects"));
EditorGUILayout.PropertyField(p.enableTransparentObjects, _.GetContent("Enable Transparent Objects"));
EditorGUILayout.PropertyField(p.enableMSAA, _.GetContent("Enable MSAA"));
}
static void Drawer_FieldForwardRenderingOnly(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
{
EditorGUILayout.PropertyField(p.enableForwardRenderingOnly, _.GetContent("Enable Forward Rendering Only"));
}
static void Drawer_FieldUseDepthPrepassWithDefferedRendering(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
{
EditorGUILayout.PropertyField(p.enableDepthPrepassWithDeferredRendering, _.GetContent("Enable Depth Prepass With Deferred Rendering"));
}
static void Drawer_FieldRenderAlphaTestOnlyInDeferredPrepass(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
{
EditorGUILayout.PropertyField(p.enableAlphaTestOnlyInDeferredPrepass, _.GetContent("Enable Alpha Test Only In Deferred Prepass"));
}
static void Drawer_SectionOtherRenderingSettings(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
{
EditorGUILayout.PropertyField(p.enableAsyncCompute, _.GetContent("Enable Async Compute"));
EditorGUILayout.PropertyField(p.enableOpaqueObjects, _.GetContent("Enable Opaque Objects"));

38
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedLightLoopSettingsUI.cs


using UnityEditor.AnimatedValues;
using UnityEngine.Events;
namespace UnityEditor.Experimental.Rendering
{

class SerializedLightLoopSettingsUI : SerializedUIBase
class SerializedLightLoopSettingsUI : SerializedUIBase<SerializedLightLoopSettings>
{
public static CED.IDrawer SectionLightLoopSettings = CED.FoldoutGroup(
"Light Loop Settings",

public AnimBool isSectionExpandedLightLoopSettings { get { return m_AnimBools[0]; } }
public AnimBool isSectionExpandedEnableTileAndCluster { get { return m_AnimBools[1]; } }
public AnimBool isSectionExpandedComputeLightEvaluation { get { return m_AnimBools[2]; } }
: base(1)
: base(3)
{
}
public override void Update()
isSectionExpandedEnableTileAndCluster.target = data.enableTileAndCluster.boolValue;
isSectionExpandedComputeLightEvaluation.target = data.enableComputeLightEvaluation.boolValue;
base.Update();
EditorGUILayout.PropertyField(p.enableComputeLightEvaluation, _.GetContent("Enable Compute Light Evaluation"));
EditorGUILayout.PropertyField(p.enableComputeLightVariants, _.GetContent("Enable Compute Light Variants"));
EditorGUILayout.PropertyField(p.enableComputeMaterialVariants, _.GetContent("Enable Compute Material Variants"));
if (EditorGUILayout.BeginFadeGroup(s.isSectionExpandedEnableTileAndCluster.faded))
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(p.enableBigTilePrepass, _.GetContent("Enable Big Tile Prepass"));
// Allow to disable cluster for forward opaque when in forward only (option have no effect when MSAA is enabled)
// Deferred opaque are always tiled
EditorGUILayout.PropertyField(p.enableFptlForForwardOpaque, _.GetContent("Enable FPTL For Forward Opaque"));
EditorGUILayout.PropertyField(p.enableComputeLightEvaluation, _.GetContent("Enable Compute Light Evaluation"));
if (EditorGUILayout.BeginFadeGroup(s.isSectionExpandedComputeLightEvaluation.faded))
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(p.enableComputeLightVariants, _.GetContent("Enable Compute Light Variants"));
EditorGUILayout.PropertyField(p.enableComputeMaterialVariants, _.GetContent("Enable Compute Material Variants"));
EditorGUI.indentLevel--;
}
EditorGUILayout.EndFadeGroup();
EditorGUI.indentLevel--;
}
EditorGUILayout.EndFadeGroup();
EditorGUILayout.PropertyField(p.enableBigTilePrepass, _.GetContent("Enable Big Tile Prepass"));
}
}
}

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedUIBase.cs


namespace UnityEditor.Experimental.Rendering
{
class SerializedUIBase
class SerializedUIBase<TType>
protected TType data { get; private set; }
public SerializedUIBase(int animBoolCount)
{

}
public virtual void Reset(UnityAction repaint)
public virtual void Reset(TType data, UnityAction repaint)
this.data = data;
for (var i = 0; i < m_AnimBools.Length; ++i)
{
m_AnimBools[i].valueChanged.RemoveAllListeners();

84
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineInspector.cs


using System.Linq;
using System.Reflection;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;

using CED = CoreEditorDrawer<SerializedFrameSettingsUI, SerializedFrameSettings>;
static readonly CED.IDrawer[] k_FrameSettings = new[]
{
SerializedFrameSettingsUI.SectionRenderingPasses,
SerializedFrameSettingsUI.SectionRenderingSettings
}.Concat(CED.Select(
(s, d, o) => s.serializedLightLoopSettingsUI,
(s, d, o) => d.lightLoopSettings,
SerializedLightLoopSettingsUI.SectionLightLoopSettings))
.Concat(new[]
{
SerializedFrameSettingsUI.SectionXRSettings
})
.ToArray();
SerializedProperty m_RenderPipelineResources;
// Global Frame Settings

// Subsurface Scattering Settings
SerializedProperty m_SubsurfaceScatteringSettings;
SerializedFrameSettings serializedFrameSettings = null;
SerializedFrameSettingsUI SerializedFrameSettingsUI = new SerializedFrameSettingsUI();
void InitializeProperties()
{
m_RenderPipelineResources = properties.Find("m_RenderPipelineResources");

// Subsurface Scattering Settings
m_SubsurfaceScatteringSettings = properties.Find(x => x.sssSettings);
serializedFrameSettings = new SerializedFrameSettings(properties.Find(x => x.serializedFrameSettings));
SerializedFrameSettingsUI.Reset(serializedFrameSettings, Repaint);
}
static void HackSetDirty(RenderPipelineAsset asset)

EditorGUI.indentLevel--;
}
void LightLoopSettingsUI(HDRenderPipelineAsset hdAsset)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField(s_Styles.lightLoopSettings);
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_enableTileAndCluster, s_Styles.enableTileAndCluster);
if (m_enableTileAndCluster.boolValue)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_enableBigTilePrepass, s_Styles.enableBigTilePrepass);
// Allow to disable cluster for forward opaque when in forward only (option have no effect when MSAA is enabled)
// Deferred opaque are always tiled
EditorGUILayout.PropertyField(m_enableFptlForForwardOpaque, s_Styles.enableFptlForForwardOpaque);
EditorGUILayout.PropertyField(m_enableComputeLightEvaluation, s_Styles.enableComputeLightEvaluation);
if (m_enableComputeLightEvaluation.boolValue)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_enableComputeLightVariants, s_Styles.enableComputeLightVariants);
EditorGUILayout.PropertyField(m_enableComputeMaterialVariants, s_Styles.enableComputeMaterialVariants);
EditorGUI.indentLevel--;
}
}
if (EditorGUI.EndChangeCheck())
{
HackSetDirty(hdAsset); // Repaint
}
EditorGUI.indentLevel--;
}
void RendereringSettingsUI(HDRenderPipelineAsset hdAsset)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField(s_Styles.renderingSettingsLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_RenderingUseForwardOnly, s_Styles.useForwardRenderingOnly);
if (!m_RenderingUseForwardOnly.boolValue) // If we are deferred
{
EditorGUILayout.PropertyField(m_RenderingUseDepthPrepass, s_Styles.useDepthPrepassWithDeferredRendering);
if (m_RenderingUseDepthPrepass.boolValue)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_RenderingUseDepthPrepassAlphaTestOnly, s_Styles.renderAlphaTestOnlyInDeferredPrepass);
EditorGUI.indentLevel--;
}
}
EditorGUILayout.PropertyField(m_enableAsyncCompute, s_Styles.enableAsyncCompute);
EditorGUILayout.PropertyField(m_enableShadowMask, s_Styles.enableShadowMask);
EditorGUI.indentLevel--;
}
void SettingsUI(HDRenderPipelineAsset hdAsset)
{
EditorGUILayout.LabelField(s_Styles.renderPipelineSettings, EditorStyles.boldLabel);

EditorGUILayout.Space();
EditorGUILayout.LabelField(s_Styles.defaultFrameSettings, EditorStyles.boldLabel);
RendereringSettingsUI(hdAsset);
LightLoopSettingsUI(hdAsset);
}
protected override void OnEnable()

EditorGUILayout.Space();
SettingsUI(m_Target);
k_FrameSettings.Draw(SerializedFrameSettingsUI, serializedFrameSettings, this);
serializedObject.ApplyModifiedProperties();
}
正在加载...
取消
保存