浏览代码

[HDCameraEditor] Refactored drawers for frame settings

/main
Frédéric Vauchelles 7 年前
当前提交
43c18028
共有 9 个文件被更改,包括 282 次插入91 次删除
  1. 47
      ScriptableRenderPipeline/Core/CoreRP/Editor/CoreEditorDrawers.cs
  2. 26
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Data.cs
  3. 94
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Drawers.cs
  4. 104
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedFrameSettingsUI.cs
  5. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedFrameSettingsUI.cs.meta
  6. 37
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedLightLoopSettingsUI.cs
  7. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedLightLoopSettingsUI.cs.meta
  8. 32
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedUIBase.cs
  9. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedUIBase.cs.meta

47
ScriptableRenderPipeline/Core/CoreRP/Editor/CoreEditorDrawers.cs


using System.Collections.Generic;
using System;
using System.Collections.Generic;
using UnityEditor.AnimatedValues;
namespace UnityEditor.Experimental.Rendering

{
void Draw(TUIState s, TData p, Editor owner);
}
public delegate T2UIState StateSelect<T2UIState>(TUIState s, TData d, Editor o);
public delegate T2Data DataSelect<T2Data>(TUIState s, TData d, Editor o);
public delegate void ActionDrawer(TUIState s, TData p, Editor owner);
public delegate float FloatGetter(TUIState s, TData p, Editor owner, int i);

public static IDrawer FoldoutGroup(string title, AnimBoolGetter root, bool indent, params IDrawer[] bodies)
{
return new FoldoutDrawerInternal(title, root, indent, bodies);
}
public static IEnumerable<IDrawer> Select<T2UIState, T2Data>(
StateSelect<T2UIState> stateSelect,
DataSelect<T2Data> dataSelect,
params CoreEditorDrawer<T2UIState, T2Data>.IDrawer[] otherDrawers)
{
var result = new IDrawer[otherDrawers.Length];
for (var i = 0; i < result.Length; i++)
result[i] = new SelectDrawerInternal<T2UIState, T2Data>(stateSelect, dataSelect, otherDrawers[i]);
return result;
}
public static IDrawer SelectSingle<T2UIState, T2Data>(
StateSelect<T2UIState> stateSelect,
DataSelect<T2Data> dataSelect,
CoreEditorDrawer<T2UIState, T2Data>.IDrawer otherDrawers)
{
return new SelectDrawerInternal<T2UIState, T2Data>(stateSelect, dataSelect, otherDrawers);
}
class SelectDrawerInternal<T2UIState, T2Data> : IDrawer
{
StateSelect<T2UIState> m_StateSelect;
DataSelect<T2Data> m_DataSelect;
CoreEditorDrawer<T2UIState, T2Data>.IDrawer[] m_SourceDrawers;
public SelectDrawerInternal(StateSelect<T2UIState> stateSelect,
DataSelect<T2Data> dataSelect,
params CoreEditorDrawer<T2UIState, T2Data>.IDrawer[] otherDrawers)
{
m_SourceDrawers = otherDrawers;
m_StateSelect = stateSelect;
m_DataSelect = dataSelect;
}
void IDrawer.Draw(TUIState s, TData p, Editor o)
{
for (var i = 0; i < m_SourceDrawers.Length; i++)
m_SourceDrawers[i].Draw(m_StateSelect(s, p, o), m_DataSelect(s, p, o), o);
}
}
class ActionDrawerInternal : IDrawer

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


{
SerializedHDCamera m_SerializedHdCamera;
AnimBool[] m_AnimBools = new AnimBool[10];
AnimBool[] m_AnimBools = new AnimBool[6];
public AnimBool isSectionExpandedShaderFeature { get { return m_AnimBools[1]; } }
public AnimBool isSectionExpandedLightLoop { get { return m_AnimBools[2]; } }
public AnimBool isSectionExpandedScreenSpace { get { return m_AnimBools[3]; } }
public AnimBool isSectionExpandedMiscellaneous { get { return m_AnimBools[4]; } }
public AnimBool isSectionExpandedRenderLoopSettings { get { return m_AnimBools[5]; } }
public AnimBool isSectionExpandedXR { get { return m_AnimBools[6]; } }
public AnimBool isSectionExpandedXRSupported { get { return m_AnimBools[7]; } }
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[8]; } }
public AnimBool isSectionExpandedOutputSettings { get { return m_AnimBools[9]; } }
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[1]; } }
public AnimBool isSectionExpandedOutputSettings { get { return m_AnimBools[2]; } }
public AnimBool isSectionAvailableRenderLoopSettings { get { return m_AnimBools[3]; } }
public AnimBool isSectionExpandedXRSettings { get { return m_AnimBools[4]; } }
public AnimBool isSectionAvailableXRSettings { get { return m_AnimBools[5]; } }
public SerializedFrameSettingsUI serializedFrameSettingsUI = new SerializedFrameSettingsUI();
public UIState()
{

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

isSectionExpandedOrthoOptions.target = !m_SerializedHdCamera.orthographic.hasMultipleDifferentValues && m_SerializedHdCamera.orthographic.boolValue;
isSectionExpandedXRSupported.target = PlayerSettings.virtualRealitySupported;
isSectionAvailableXRSettings.target = PlayerSettings.virtualRealitySupported;
isSectionExpandedRenderLoopSettings.target = canOverrideRenderLoopSettings;
isSectionAvailableRenderLoopSettings.target = canOverrideRenderLoopSettings;
serializedFrameSettingsUI.Update();
}
}
}

94
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Drawers.cs


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

CED.Action(Drawer_FieldDepth),
CED.Action(Drawer_FieldRenderTarget)),
CED.FadeGroup(
(s, d, o, i) => s.isSectionExpandedXRSupported.faded,
(s, d, o, i) => s.isSectionAvailableXRSettings.faded,
"XR",
(s, p, o) => s.isSectionExpandedXR,
"XR Settings",
(s, p, o) => s.isSectionExpandedXRSettings,
true,
CED.Action(Drawer_FieldVR),
CED.Action(Drawer_FieldTargetEye))),

(s, d, o, i) => s.isSectionExpandedRenderLoopSettings.faded,
false,
CED.FoldoutGroup(
"Shader Passes",
(s, p, o) => s.isSectionExpandedShaderFeature,
true,
CED.Action(Drawer_SectionShaderFeature)),
CED.FoldoutGroup(
"Screen Space",
(s, p, o) => s.isSectionExpandedScreenSpace,
true,
CED.Action(Drawer_SectionScreenSpace)),
CED.FoldoutGroup(
"Miscellaneous",
(s, p, o) => s.isSectionExpandedMiscellaneous,
true,
CED.Action(Drawer_SectionMiscellaneous)),
CED.FoldoutGroup(
"Light Loop",
(s, p, o) => s.isSectionExpandedLightLoop,
true,
CED.Action(Drawer_SectionLightLoop))),
(s, d, o, i) => s.isSectionAvailableRenderLoopSettings.faded,
false,
CED.Select(
(s, d, o) => s.serializedFrameSettingsUI,
(s, d, o) => d.frameSettings,
SerializedFrameSettingsUI.SectionRenderingPasses,
SerializedFrameSettingsUI.SectionRenderingSettings,
SerializedFrameSettingsUI.SectionLightingSettings)
.Concat(CED.Select(
(s, d, o) => s.serializedFrameSettingsUI.serializedLightLoopSettingsUI,
(s, d, o) => d.frameSettings.lightLoopSettings,
SerializedLightLoopSettingsUI.SectionLightLoopSettings)).ToArray())
};
static void Drawer_FieldBackgroundColor(UIState s, SerializedHDCamera p, Editor owner)

{
EditorGUILayout.IntPopup(p.targetEye, k_TargetEyes, k_TargetEyeValues, _.GetContent("Target Eye"));
}
static void Drawer_SectionShaderFeature(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.frameSettings.enableTransparentPrepass, _.GetContent("Enable Transparent Prepass"));
EditorGUILayout.PropertyField(p.frameSettings.enableTransparentPostpass, _.GetContent("Enable Transparent Postpass"));
EditorGUILayout.PropertyField(p.frameSettings.enableMotionVectors, _.GetContent("Enable Motion Vectors"));
EditorGUILayout.PropertyField(p.frameSettings.enableObjectMotionVectors, _.GetContent("Enable Object Motion Vectors"));
EditorGUILayout.PropertyField(p.frameSettings.enableDBuffer, _.GetContent("Enable DBuffer"));
EditorGUILayout.PropertyField(p.frameSettings.enableAtmosphericScattering, _.GetContent("Enable Atmospheric Scattering"));
EditorGUILayout.PropertyField(p.frameSettings.enableRoughRefraction, _.GetContent("Enable Rough Refraction"));
EditorGUILayout.PropertyField(p.frameSettings.enableDistortion, _.GetContent("Enable Distortion"));
EditorGUILayout.PropertyField(p.frameSettings.enablePostprocess, _.GetContent("Enable Postprocess"));
}
static void Drawer_SectionScreenSpace(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.frameSettings.enableSSR, _.GetContent("Enable SSR"));
EditorGUILayout.PropertyField(p.frameSettings.enableSSAO, _.GetContent("Enable SSAO"));
EditorGUILayout.PropertyField(p.frameSettings.enableSSSAndTransmission, _.GetContent("Enable SSS And Transmission"));
}
static void Drawer_SectionMiscellaneous(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.frameSettings.enableShadow, _.GetContent("Enable Shadow"));
EditorGUILayout.PropertyField(p.frameSettings.enableShadowMask, _.GetContent("Enable Shadow Masks"));
EditorGUILayout.PropertyField(p.frameSettings.enableForwardRenderingOnly, _.GetContent("Enable Forward Rendering Only"));
EditorGUILayout.PropertyField(p.frameSettings.enableDepthPrepassWithDeferredRendering, _.GetContent("Enable Depth Prepass With Deferred Rendering"));
EditorGUILayout.PropertyField(p.frameSettings.enableAlphaTestOnlyInDeferredPrepass, _.GetContent("Enable Alpha Test Only In Deferred Prepass"));
EditorGUILayout.PropertyField(p.frameSettings.enableAsyncCompute, _.GetContent("Enable Async Compute"));
EditorGUILayout.PropertyField(p.frameSettings.enableOpaqueObjects, _.GetContent("Enable Opaque Objects"));
EditorGUILayout.PropertyField(p.frameSettings.enableTransparentObjects, _.GetContent("Enable Transparent Objects"));
EditorGUILayout.PropertyField(p.frameSettings.enableMSAA, _.GetContent("Enable MSAA"));
}
static void Drawer_SectionLightLoop(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.frameSettings.lightLoopSettings.enableTileAndCluster, _.GetContent("Enable Tile And Cluster"));
EditorGUILayout.PropertyField(p.frameSettings.lightLoopSettings.enableComputeLightEvaluation, _.GetContent("Enable Compute Light Evaluation"));
EditorGUILayout.PropertyField(p.frameSettings.lightLoopSettings.enableComputeLightVariants, _.GetContent("Enable Compute Light Variants"));
EditorGUILayout.PropertyField(p.frameSettings.lightLoopSettings.enableComputeMaterialVariants, _.GetContent("Enable Compute Material Variants"));
EditorGUILayout.PropertyField(p.frameSettings.lightLoopSettings.isFptlEnabled, _.GetContent("Enable FPTL"));
EditorGUILayout.PropertyField(p.frameSettings.lightLoopSettings.enableFptlForForwardOpaque, _.GetContent("Enable FPTL For Forward Opaque"));
EditorGUILayout.PropertyField(p.frameSettings.lightLoopSettings.enableBigTilePrepass, _.GetContent("Enable Big Tile Prepass"));
}
static MethodInfo k_DisplayUtility_GetDisplayIndices = Type.GetType("UnityEditor.DisplayUtility,UnityEditor")
.GetMethod("GetDisplayIndices");
static int[] DisplayUtility_GetDisplayIndices()

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


using UnityEditor.AnimatedValues;
using UnityEngine.Events;
namespace UnityEditor.Experimental.Rendering
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<SerializedFrameSettingsUI, SerializedFrameSettings>;
class SerializedFrameSettingsUI : SerializedUIBase
{
public static CED.IDrawer SectionRenderingPasses = CED.FoldoutGroup(
"Rendering Passes",
(s, p, o) => s.isSectionExpandedRenderingPasses,
true,
CED.Action(Drawer_SectionRenderingPasses));
public static CED.IDrawer SectionRenderingSettings = CED.FoldoutGroup(
"Rendering Settings",
(s, p, o) => s.isSectionExpandedRenderingSettings,
true,
CED.Action(Drawer_SectionRenderingSettings));
public static CED.IDrawer SectionXRSettings = CED.FadeGroup(
(s, d, o, i) => s.isSectionExpandedXRSupported.faded,
false,
CED.FoldoutGroup(
"XR Settings",
(s, p, o) => s.isSectionExpandedXRSettings,
true,
CED.Action(Drawer_FieldStereoEnabled)));
public static CED.IDrawer SectionLightingSettings = CED.FoldoutGroup(
"Lighting Settings",
(s, p, o) => s.isSectionExpandedLightingSettings,
true,
CED.Action(Drawer_SectionLightingSettings));
public AnimBool isSectionExpandedRenderingPasses { get { return m_AnimBools[0]; } }
public AnimBool isSectionExpandedLightingSettings { get { return m_AnimBools[1]; } }
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 SerializedLightLoopSettingsUI serializedLightLoopSettingsUI = new SerializedLightLoopSettingsUI();
public SerializedFrameSettingsUI()
: base(5)
{
}
public override void Reset(UnityAction repaint)
{
base.Reset(repaint);
serializedLightLoopSettingsUI.Reset(repaint);
}
public override void Update()
{
isSectionExpandedXRSupported.target = PlayerSettings.virtualRealitySupported;
serializedLightLoopSettingsUI.Update();
}
static void Drawer_SectionRenderingPasses(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
{
EditorGUILayout.PropertyField(p.enableTransparentPrepass, _.GetContent("Enable Transparent Prepass"));
EditorGUILayout.PropertyField(p.enableTransparentPostpass, _.GetContent("Enable Transparent Postpass"));
EditorGUILayout.PropertyField(p.enableMotionVectors, _.GetContent("Enable Motion Vectors"));
EditorGUILayout.PropertyField(p.enableObjectMotionVectors, _.GetContent("Enable Object Motion Vectors"));
EditorGUILayout.PropertyField(p.enableDBuffer, _.GetContent("Enable DBuffer"));
EditorGUILayout.PropertyField(p.enableAtmosphericScattering, _.GetContent("Enable Atmospheric Scattering"));
EditorGUILayout.PropertyField(p.enableRoughRefraction, _.GetContent("Enable Rough Refraction"));
EditorGUILayout.PropertyField(p.enableDistortion, _.GetContent("Enable Distortion"));
EditorGUILayout.PropertyField(p.enablePostprocess, _.GetContent("Enable Postprocess"));
}
static void Drawer_SectionRenderingSettings(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
{
EditorGUILayout.PropertyField(p.enableForwardRenderingOnly, _.GetContent("Enable Forward Rendering Only"));
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_FieldStereoEnabled(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
{
EditorGUILayout.PropertyField(p.enableStereo, _.GetContent("Enable Stereo"));
}
static void Drawer_SectionLightingSettings(SerializedFrameSettingsUI s, SerializedFrameSettings p, Editor owner)
{
EditorGUILayout.PropertyField(p.enableSSR, _.GetContent("Enable SSR"));
EditorGUILayout.PropertyField(p.enableSSAO, _.GetContent("Enable SSAO"));
EditorGUILayout.PropertyField(p.enableSSSAndTransmission, _.GetContent("Enable SSS And Transmission"));
EditorGUILayout.PropertyField(p.enableShadow, _.GetContent("Enable Shadow"));
EditorGUILayout.PropertyField(p.enableShadowMask, _.GetContent("Enable Shadow Masks"));
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedFrameSettingsUI.cs.meta


fileFormatVersion: 2
guid: e5017bb8546839c4ca4e816932f0245d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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


using UnityEditor.AnimatedValues;
using UnityEngine.Events;
namespace UnityEditor.Experimental.Rendering
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<SerializedLightLoopSettingsUI, SerializedLightLoopSettings>;
class SerializedLightLoopSettingsUI : SerializedUIBase
{
public static CED.IDrawer SectionLightLoopSettings = CED.FoldoutGroup(
"Light Loop Settings",
(s, p, o) => s.isSectionExpandedLightLoopSettings,
true,
CED.Action(Drawer_SectionLightLoopSettings));
public AnimBool isSectionExpandedLightLoopSettings { get { return m_AnimBools[0]; } }
public SerializedLightLoopSettingsUI()
: base(1)
{
}
static void Drawer_SectionLightLoopSettings(SerializedLightLoopSettingsUI s, SerializedLightLoopSettings p, Editor owner)
{
EditorGUILayout.PropertyField(p.enableTileAndCluster, _.GetContent("Enable Tile And Cluster"));
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"));
EditorGUILayout.PropertyField(p.isFptlEnabled, _.GetContent("Enable FPTL"));
EditorGUILayout.PropertyField(p.enableFptlForForwardOpaque, _.GetContent("Enable FPTL For Forward Opaque"));
EditorGUILayout.PropertyField(p.enableBigTilePrepass, _.GetContent("Enable Big Tile Prepass"));
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedLightLoopSettingsUI.cs.meta


fileFormatVersion: 2
guid: 035f43bd7b3c01b4dbd3d7e33382ec8e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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


using UnityEditor.AnimatedValues;
using UnityEngine.Events;
namespace UnityEditor.Experimental.Rendering
{
class SerializedUIBase
{
protected AnimBool[] m_AnimBools = null;
public SerializedUIBase(int animBoolCount)
{
m_AnimBools = new AnimBool[animBoolCount];
for (var i = 0; i < m_AnimBools.Length; ++i)
m_AnimBools[i] = new AnimBool();
}
public virtual void Reset(UnityAction repaint)
{
for (var i = 0; i < m_AnimBools.Length; ++i)
{
m_AnimBools[i].valueChanged.RemoveAllListeners();
m_AnimBools[i].valueChanged.AddListener(repaint);
}
Update();
}
public virtual void Update()
{
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedUIBase.cs.meta


fileFormatVersion: 2
guid: 552d470a524dbaa44bd6833071913719
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存