浏览代码

[HDCameraEditor] (wip)

/main
Frédéric Vauchelles 7 年前
当前提交
6bdf3918
共有 18 个文件被更改,包括 668 次插入58 次删除
  1. 18
      ScriptableRenderPipeline/Core/CoreRP/Editor/CoreEditorDrawers.cs
  2. 29
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDAdditionalCameraData.cs
  3. 77
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditor.Data.cs
  4. 18
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditor.Drawers.cs
  5. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera.meta
  6. 54
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Data.cs
  7. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Data.cs.meta
  8. 222
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Drawers.cs
  9. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Drawers.cs.meta
  10. 34
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.cs
  11. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.cs.meta
  12. 76
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedFrameSettings.cs
  13. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedFrameSettings.cs.meta
  14. 94
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedHDCamera.cs
  15. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedHDCamera.cs.meta
  16. 30
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedLightLoopSettings.cs
  17. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedLightLoopSettings.cs.meta

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


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

public delegate void ActionDrawer(TUIState s, TData p, Editor owner);
public delegate float FloatGetter(TUIState s, TData p, Editor owner, int i);
public delegate SerializedProperty SerializedPropertyGetter(TUIState s, TData p, Editor o);
public delegate AnimBool AnimBoolGetter(TUIState s, TData p, Editor owner);
public static readonly IDrawer space = Action((state, data, owner) => EditorGUILayout.Space());
public static readonly IDrawer noop = Action((state, data, owner) => { });

return new FadeGroupsDrawerInternal(fadeGetter, indent, groupDrawers);
}
public static IDrawer FoldoutGroup(string title, SerializedPropertyGetter root, bool indent, params IDrawer[] bodies)
public static IDrawer FoldoutGroup(string title, AnimBoolGetter root, bool indent, params IDrawer[] bodies)
{
return new FoldoutDrawerInternal(title, root, indent, bodies);
}

class FoldoutDrawerInternal : IDrawer
{
IDrawer[] bodies;
SerializedPropertyGetter root;
AnimBoolGetter isExpanded;
public FoldoutDrawerInternal(string title, SerializedPropertyGetter root, bool indent, params IDrawer[] bodies)
public FoldoutDrawerInternal(string title, AnimBoolGetter isExpanded, bool indent, params IDrawer[] bodies)
this.root = root;
this.isExpanded = isExpanded;
this.bodies = bodies;
this.indent = indent;
}

var r = root(s, p, owner);
var r = isExpanded(s, p, owner);
r.isExpanded = CoreEditorUtils.DrawHeaderFoldout(title, r.isExpanded);
if (r.isExpanded)
r.target = CoreEditorUtils.DrawHeaderFoldout(title, r.target);
if (EditorGUILayout.BeginFadeGroup(r.faded))
{
if (indent)
++EditorGUI.indentLevel;

--EditorGUI.indentLevel;
}
EditorGUILayout.EndFadeGroup();
}
}
}

29
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDAdditionalCameraData.cs


using UnityEngine.Serialization;
public class HDAdditionalCameraData : MonoBehaviour
public class HDAdditionalCameraData : MonoBehaviour, ISerializationCallbackReceiver
{
#pragma warning disable 414 // CS0414 The private field '...' is assigned but its value is never used
// We can't rely on Unity for our additional data, we need to version it ourself.

// To be able to turn on/off FrameSettings properties at runtime for debugging purpose without affecting the original one
// we create a runtime copy (m_ActiveFrameSettings that is used, and any parametrization is done on serialized frameSettings)
public FrameSettings serializedFrameSettings = new FrameSettings(); // Serialize frameSettings
[SerializeField]
[FormerlySerializedAs("serializedFrameSettings")]
FrameSettings m_FrameSettings = new FrameSettings(); // Serialize frameSettings
FrameSettings m_FrameSettings = new FrameSettings();
FrameSettings m_FrameSettingsRuntime = new FrameSettings();
return m_FrameSettings;
return m_FrameSettingsRuntime;
}
bool m_IsDebugRegistered = false;

m_camera = GetComponent<Camera>();
m_camera.allowHDR = false;
serializedFrameSettings.CopyTo(m_FrameSettings);
m_FrameSettings.CopyTo(m_FrameSettingsRuntime);
RegisterDebug();
}

#endif
}
void OnValidate()
void OnDisable()
// Modification of frameSettings in the inspector will call OnValidate().
// We do a copy of the settings to those effectively used
serializedFrameSettings.CopyTo(m_FrameSettings);
UnRegisterDebug();
void OnDisable()
public void OnBeforeSerialize()
UnRegisterDebug();
}
public void OnAfterDeserialize()
{
// We do a copy of the settings to those effectively used
m_FrameSettings.CopyTo(m_FrameSettingsRuntime);
}
}
}

77
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditor.Data.cs


using System;
using System.Collections.Generic;
using UnityEditor.AnimatedValues;
using UnityEditor.IMGUI.Controls;
using UnityEditorInternal;

internal class UIState
{
AnimBool[] m_ModeSettingsDisplays = new AnimBool[Enum.GetValues(typeof(ReflectionProbeMode)).Length];
AnimBool[] m_InfluenceShapeDisplays = new AnimBool[Enum.GetValues(typeof(ReflectionInfluenceShape)).Length];
AnimBool[] m_IsSectionExpandedModeSettings = new AnimBool[Enum.GetValues(typeof(ReflectionProbeMode)).Length];
AnimBool[] m_IsSectionExpandedInfluenceShape = new AnimBool[Enum.GetValues(typeof(ReflectionInfluenceShape)).Length];
public AnimBool useSeparateProjectionVolumeDisplay { get; private set; }
public bool HasOperation(Operation op) { return (operations & op) == op; }
public void ClearOperation(Operation op) { operations &= ~op; }
public void AddOperation(Operation op) { operations |= op; }

public SphereBoundsHandle sphereBlendNormalHandle = new SphereBoundsHandle();
public Matrix4x4 oldLocalSpace = Matrix4x4.identity;
public AnimBool isSectionExpandedInfluenceVolume = new AnimBool();
public AnimBool isSectionExpandedSeparateProjection = new AnimBool();
public AnimBool isSectionExpandedCaptureSettings = new AnimBool();
public AnimBool isSectionExpandedAdditional = new AnimBool();
List<AnimBool> m_AnimBools = new List<AnimBool>();
public bool HasAndClearOperation(Operation op)
{
var has = HasOperation(op);

internal UIState()
{
for (var i = 0; i < m_ModeSettingsDisplays.Length; i++)
m_ModeSettingsDisplays[i] = new AnimBool();
for (var i = 0; i < m_InfluenceShapeDisplays.Length; i++)
m_InfluenceShapeDisplays[i] = new AnimBool();
useSeparateProjectionVolumeDisplay = new AnimBool();
for (var i = 0; i < m_IsSectionExpandedModeSettings.Length; i++)
{
m_IsSectionExpandedModeSettings[i] = new AnimBool();
m_AnimBools.Add(m_IsSectionExpandedModeSettings[i]);
}
for (var i = 0; i < m_IsSectionExpandedInfluenceShape.Length; i++)
{
m_IsSectionExpandedInfluenceShape[i] = new AnimBool();
m_AnimBools.Add(m_IsSectionExpandedInfluenceShape[i]);
}
m_AnimBools.Add(isSectionExpandedInfluenceVolume);
m_AnimBools.Add(isSectionExpandedSeparateProjection);
m_AnimBools.Add(isSectionExpandedCaptureSettings);
m_AnimBools.Add(isSectionExpandedAdditional);
}
internal void Reset(

this.owner = owner;
operations = 0;
for (var i = 0; i < m_ModeSettingsDisplays.Length; i++)
{
m_ModeSettingsDisplays[i].valueChanged.RemoveAllListeners();
m_ModeSettingsDisplays[i].valueChanged.AddListener(repaint);
m_ModeSettingsDisplays[i].value = p.mode.intValue == i;
}
for (var i = 0; i < m_IsSectionExpandedModeSettings.Length; i++)
m_IsSectionExpandedModeSettings[i].value = p.mode.intValue == i;
for (var i = 0; i < m_IsSectionExpandedInfluenceShape.Length; i++)
m_IsSectionExpandedInfluenceShape[i].value = p.influenceShape.intValue == i;
isSectionExpandedSeparateProjection.value = p.useSeparateProjectionVolume.boolValue;
isSectionExpandedCaptureSettings.value = true;
isSectionExpandedInfluenceVolume.value = true;
isSectionExpandedAdditional.value = false;
for (var i = 0; i < m_InfluenceShapeDisplays.Length; i++)
for (var i = 0; i < m_AnimBools.Count; ++i)
m_InfluenceShapeDisplays[i].valueChanged.RemoveAllListeners();
m_InfluenceShapeDisplays[i].valueChanged.AddListener(repaint);
m_InfluenceShapeDisplays[i].value = p.influenceShape.intValue == i;
m_AnimBools[i].valueChanged.RemoveAllListeners();
m_AnimBools[i].valueChanged.AddListener(repaint);
useSeparateProjectionVolumeDisplay.valueChanged.RemoveAllListeners();
useSeparateProjectionVolumeDisplay.valueChanged.AddListener(repaint);
useSeparateProjectionVolumeDisplay.value = p.useSeparateProjectionVolume.boolValue;
public float GetModeFaded(ReflectionProbeMode mode)
public float IsSectionExpandedMode(ReflectionProbeMode mode)
return m_ModeSettingsDisplays[(int)mode].faded;
return m_IsSectionExpandedModeSettings[(int)mode].faded;
for (var i = 0; i < m_ModeSettingsDisplays.Length; i++)
m_ModeSettingsDisplays[i].target = i == value;
for (var i = 0; i < m_IsSectionExpandedModeSettings.Length; i++)
m_IsSectionExpandedModeSettings[i].target = i == value;
public float GetShapeFaded(ReflectionInfluenceShape value)
public float IsSectionExpandedShape(ReflectionInfluenceShape value)
return m_InfluenceShapeDisplays[(int)value].faded;
return m_IsSectionExpandedInfluenceShape[(int)value].faded;
for (var i = 0; i < m_InfluenceShapeDisplays.Length; i++)
m_InfluenceShapeDisplays[i].target = i == value;
for (var i = 0; i < m_IsSectionExpandedInfluenceShape.Length; i++)
m_IsSectionExpandedInfluenceShape[i].target = i == value;
}
internal void UpdateOldLocalSpace(ReflectionProbe target)

18
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditor.Drawers.cs


static readonly CED.IDrawer[] k_PrimarySection =
{
CED.Action(Drawer_ReflectionProbeMode),
CED.FadeGroup((s, p, o, i) => s.GetModeFaded((ReflectionProbeMode)i),
CED.FadeGroup((s, p, o, i) => s.IsSectionExpandedMode((ReflectionProbeMode)i),
true,
CED.noop, // Baked
CED.Action(Drawer_ModeSettingsRealtime), // Realtime

static readonly CED.IDrawer k_InfluenceVolumeSection = CED.FoldoutGroup(
"Influence volume settings",
(s, p, o) => p.blendDistancePositive,
(s, p, o) => s.isSectionExpandedInfluenceVolume,
(s, p, o, i) => s.GetShapeFaded((ReflectionInfluenceShape)i),
(s, p, o, i) => s.IsSectionExpandedShape((ReflectionInfluenceShape)i),
false,
CED.Action(Drawer_InfluenceBoxSettings), // Box
CED.Action(Drawer_InfluenceSphereSettings) // Sphere

static readonly CED.IDrawer k_SeparateProjectionVolumeSection = CED.FadeGroup(
(s, p, o, i) => s.useSeparateProjectionVolumeDisplay.faded,
(s, p, o, i) => s.isSectionExpandedSeparateProjection.faded,
(s, p, o) => p.useSeparateProjectionVolume,
(s, p, o) => s.isSectionExpandedSeparateProjection,
(s, p, o, i) => s.GetShapeFaded((ReflectionInfluenceShape)i),
(s, p, o, i) => s.IsSectionExpandedShape((ReflectionInfluenceShape)i),
false,
CED.Action(Drawer_ProjectionBoxSettings), // Box
CED.Action(Drawer_ProjectionSphereSettings) // Sphere

static readonly CED.IDrawer k_CaptureSection = CED.FoldoutGroup(
"Capture settings",
(s, p, o) => p.shadowDistance,
(s, p, o) => s.isSectionExpandedCaptureSettings,
true,
CED.Action(Drawer_CaptureSettings)
);

(s, p, o) => p.dimmer,
(s, p, o) => s.isSectionExpandedAdditional,
true,
CED.Action(Drawer_AdditionalSettings)
);

static void Drawer_UseSeparateProjectionVolume(UIState s, SerializedReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.useSeparateProjectionVolume);
s.useSeparateProjectionVolumeDisplay.target = p.useSeparateProjectionVolume.boolValue;
s.isSectionExpandedSeparateProjection.target = p.useSeparateProjectionVolume.boolValue;
}
static void Drawer_ProjectionBoxSettings(UIState s, SerializedReflectionProbe p, Editor owner)

8
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera.meta


fileFormatVersion: 2
guid: 9dc3c4b1d2c33704f894c37b8b2a1057
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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


using System;
using System.Collections.Generic;
using UnityEditor.AnimatedValues;
using UnityEngine;
using UnityEngine.Events;
namespace UnityEditor.Experimental.Rendering
{
partial class HDCameraEditor
{
public class UIState
{
SerializedHDCamera m_SerializedHdCamera;
AnimBool[] m_AnimBools = new AnimBool[4];
public AnimBool isSectionExpandedBGColorOptions { get { return m_AnimBools[0]; } }
public AnimBool isSectionExpandedOrthoOptions { get { return m_AnimBools[1]; } }
public AnimBool isSectionExpandedTargetEyeOptions { get { return m_AnimBools[2]; } }
public AnimBool isSectionExpandedMiscellaneous { get { return m_AnimBools[3]; } }
public UIState()
{
for (var i = 0 ; i < m_AnimBools.Length; ++i)
m_AnimBools[i] = new AnimBool();
}
public void Reset(SerializedHDCamera serializedHdCamera, UnityAction repaint)
{
m_SerializedHdCamera = serializedHdCamera;
for (var i = 0; i < m_AnimBools.Length; ++i)
{
m_AnimBools[i].valueChanged.RemoveAllListeners();
m_AnimBools[i].valueChanged.AddListener(repaint);
}
Update();
}
public void Update()
{
var clearFlags = (CameraClearFlags)m_SerializedHdCamera.clearFlags.intValue;
var clearFlagsHasMultipleValues = m_SerializedHdCamera.clearFlags.hasMultipleDifferentValues;
isSectionExpandedBGColorOptions.target = !clearFlagsHasMultipleValues && (clearFlags == CameraClearFlags.SolidColor || clearFlags == CameraClearFlags.Skybox);
isSectionExpandedOrthoOptions.target = !m_SerializedHdCamera.orthographic.hasMultipleDifferentValues && m_SerializedHdCamera.orthographic.boolValue;
var targetEyeValue = (StereoTargetEyeMask)m_SerializedHdCamera.targetEye.intValue;
isSectionExpandedTargetEyeOptions.target = targetEyeValue != StereoTargetEyeMask.Both || PlayerSettings.virtualRealitySupported;
}
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Data.cs.meta


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

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


using System;
using System.Reflection;
using UnityEngine;
namespace UnityEditor.Experimental.Rendering
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<HDCameraEditor.UIState, SerializedHDCamera>;
partial class HDCameraEditor
{
static readonly CED.IDrawer[] k_PrimarySection =
{
CED.Action(Drawer_FieldClearFlags),
CED.FadeGroup(
(s, d, o, i) => s.isSectionExpandedBGColorOptions.faded,
true,
CED.Action(Drawer_FieldBackgroundColor)),
CED.Action(Drawer_FieldCullingMask),
CED.space,
CED.Action(Drawer_Projection),
CED.Action(Drawer_FieldClippingPlanes),
CED.Action(Drawer_FieldNormalizedViewPort),
CED.space,
CED.Action(Drawer_FieldDepth),
CED.Action(Drawer_FieldRenderingPath),
CED.Action(Drawer_DeferredOrthographicWarning),
CED.Action(Drawer_FieldRenderTarget),
CED.Action(Drawer_FieldOcclusionCulling),
CED.Action(Drawer_FieldAllowMSAA),
CED.Action(Drawer_FieldAllowDynamicResolution),
CED.Action(Drawer_CameraWarnings),
CED.Action(Drawer_FieldVR),
#if ENABLE_MULTIPLE_DISPLAYS
CED.Action(Drawer_SectionMultiDisplay),
#endif
CED.FadeGroup(
(s, d, o, i) => s.isSectionExpandedTargetEyeOptions.faded,
true,
CED.Action(Drawer_FieldTargetEye)),
CED.FoldoutGroup(
"Misc",
(s, p, o) => s.isSectionExpandedMiscellaneous,
true,
CED.Action(Drawer_SectionMiscellaneous))
};
static void Drawer_FieldClearFlags(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.clearFlags, _.GetContent("Clear Flags|What to display in empty areas of this Camera's view.\n\nChoose Skybox to display a skybox in empty areas, defaulting to a background color if no skybox is found.\n\nChoose Solid Color to display a background color in empty areas.\n\nChoose Depth Only to display nothing in empty areas.\n\nChoose Don't Clear to display whatever was displayed in the previous frame in empty areas."));
}
static void Drawer_FieldBackgroundColor(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.backgroundColor, _.GetContent("Background|The Camera clears the screen to this color before rendering."));
}
static void Drawer_FieldCullingMask(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.cullingMask, _.GetContent("Culling Mask"));
}
static void Drawer_Projection(UIState s, SerializedHDCamera p, Editor owner)
{
ProjectionType projectionType = p.orthographic.boolValue ? ProjectionType.Orthographic : ProjectionType.Perspective;
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = p.orthographic.hasMultipleDifferentValues;
projectionType = (ProjectionType)EditorGUILayout.EnumPopup(_.GetContent("Projection|How the Camera renders perspective.\n\nChoose Perspective to render objects with perspective.\n\nChoose Orthographic to render objects uniformly, with no sense of perspective."), projectionType);
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck())
p.orthographic.boolValue = (projectionType == ProjectionType.Orthographic);
if (!p.orthographic.hasMultipleDifferentValues)
{
if (projectionType == ProjectionType.Orthographic)
EditorGUILayout.PropertyField(p.orthographicSize, _.GetContent("Size"));
else
EditorGUILayout.Slider(p.fieldOfView, 1f, 179f, _.GetContent("Field of View|The width of the Camera’s view angle, measured in degrees along the local Y axis."));
}
}
static void Drawer_FieldClippingPlanes(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.nearClippingPlane, _.GetContent("Near|The closest point relative to the camera that drawing will occur."));
EditorGUILayout.PropertyField(p.farClippingPlane, _.GetContent("Far|The furthest point relative to the camera that drawing will occur.\n"));
}
static void Drawer_FieldNormalizedViewPort(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.normalizedViewPortRect, _.GetContent("Viewport Rect|Four values that indicate where on the screen this camera view will be drawn. Measured in Viewport Coordinates (values 0–1)."));
}
static void Drawer_FieldDepth(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.depth, _.GetContent("Depth"));
}
static void Drawer_FieldRenderingPath(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.renderingPath, _.GetContent("Rendering Path"));
}
static void Drawer_DeferredOrthographicWarning(UIState s, SerializedHDCamera p, Editor owner)
{
if (p.orthographic.boolValue && !p.frameSettings.enableForwardRenderingOnly.boolValue)
EditorGUILayout.HelpBox("Deferred rendering does not work with Orthographic camera, will use Forward.",
MessageType.Warning, true);
}
static void Drawer_FieldRenderTarget(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.targetTexture);
// show warning if we have deferred but manual MSAA set
// only do this if the m_TargetTexture has the same values across all target cameras
if (!p.targetTexture.hasMultipleDifferentValues)
{
var targetTexture = p.targetTexture.objectReferenceValue as RenderTexture;
if (targetTexture
&& targetTexture.antiAliasing > 1
&& !p.frameSettings.enableForwardRenderingOnly.boolValue)
{
EditorGUILayout.HelpBox("Manual MSAA target set with deferred rendering. This will lead to undefined behavior.", MessageType.Warning, true);
}
}
}
static void Drawer_FieldOcclusionCulling(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.occlusionCulling, _.GetContent("Occlusion Culling"));
}
static void Drawer_FieldAllowMSAA(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.allowMSAA, _.GetContent("Allow MSAA"));
}
static void Drawer_FieldAllowDynamicResolution(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.allowDynamicResolution, _.GetContent("Allow Dynamic Resolution"));
}
static void Drawer_CameraWarnings(UIState s, SerializedHDCamera p, Editor owner)
{
foreach (Camera camera in p.serializedObject.targetObjects)
{
var warnings = GetCameraBufferWarnings(camera);
if (warnings.Length > 0)
EditorGUILayout.HelpBox(string.Join("\n\n", warnings), MessageType.Warning, true);
}
}
static void Drawer_FieldVR(UIState s, SerializedHDCamera p, Editor owner)
{
if (PlayerSettings.virtualRealitySupported)
{
EditorGUILayout.PropertyField(p.stereoSeparation, _.GetContent("Stereo Separation"));
EditorGUILayout.PropertyField(p.stereoConvergence, _.GetContent("Stereo Convergence"));
}
}
#if ENABLE_MULTIPLE_DISPLAYS
static void Drawer_SectionMultiDisplay(UIState s, SerializedHDCamera p, Editor owner)
{
if (ModuleManager_ShouldShowMultiDisplayOption())
{
var prevDisplay = p.targetDisplay.intValue;
EditorGUILayout.Space();
EditorGUILayout.IntPopup(p.targetDisplay, DisplayUtility_GetDisplayNames(), DisplayUtility_GetDisplayIndices(), _.GetContent("Target Display"));
if (prevDisplay != p.targetDisplay.intValue)
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
}
}
#endif
static readonly int[] k_TargetEyeValues = { (int)StereoTargetEyeMask.Both, (int)StereoTargetEyeMask.Left, (int)StereoTargetEyeMask.Right, (int)StereoTargetEyeMask.None };
static readonly GUIContent[] k_TargetEyes =
{
new GUIContent("Both"),
new GUIContent("Left"),
new GUIContent("Right"),
new GUIContent("None (Main Display)"),
};
static void Drawer_FieldTargetEye(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.IntPopup(p.targetEye, k_TargetEyes, k_TargetEyeValues, _.GetContent("Target Eye"));
}
static void Drawer_SectionMiscellaneous(UIState s, SerializedHDCamera p, Editor owner)
{
EditorGUILayout.PropertyField(p.frameSettings.enableSSAO, _.GetContent("Enable SSAO"));
}
static MethodInfo k_DisplayUtility_GetDisplayIndices = Type.GetType("UnityEditor.DisplayUtility,UnityEditor")
.GetMethod("GetDisplayIndices");
static int[] DisplayUtility_GetDisplayIndices()
{
return (int[])k_DisplayUtility_GetDisplayIndices.Invoke(null, null);
}
static MethodInfo k_DisplayUtility_GetDisplayNames = Type.GetType("UnityEditor.DisplayUtility,UnityEditor")
.GetMethod("GetDisplayNames");
static GUIContent[] DisplayUtility_GetDisplayNames()
{
return (GUIContent[])k_DisplayUtility_GetDisplayNames.Invoke(null, null);
}
static MethodInfo k_ModuleManager_ShouldShowMultiDisplayOption = Type.GetType("UnityEditor.Modules.ModuleManager,UnityEditor")
.GetMethod("ShouldShowMultiDisplayOption", BindingFlags.Static | BindingFlags.NonPublic);
static bool ModuleManager_ShouldShowMultiDisplayOption()
{
return (bool)k_ModuleManager_ShouldShowMultiDisplayOption.Invoke(null, null);
}
static readonly MethodInfo k_Camera_GetCameraBufferWarnings = typeof(Camera).GetMethod("GetCameraBufferWarnings", BindingFlags.Instance | BindingFlags.NonPublic);
static string[] GetCameraBufferWarnings(Camera camera)
{
return (string[])k_Camera_GetCameraBufferWarnings.Invoke(camera, null);
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Drawers.cs.meta


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

34
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.cs


using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering
{
[CustomEditorForRenderPipeline(typeof(Camera), typeof(HDRenderPipelineAsset))]
[CanEditMultipleObjects]
partial class HDCameraEditor : Editor
{
enum ProjectionType { Perspective, Orthographic };
SerializedHDCamera m_SerializedCamera;
UIState m_UIState = new UIState();
void OnEnable()
{
m_SerializedCamera = new SerializedHDCamera(serializedObject);
m_UIState.Reset(m_SerializedCamera, Repaint);
}
public override void OnInspectorGUI()
{
var s = m_UIState;
var d = m_SerializedCamera;
d.Update();
s.Update();
k_PrimarySection.Draw(s, d, this);
d.Apply();
}
}
}

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


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

76
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedFrameSettings.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering
{
class SerializedFrameSettings
{
public SerializedProperty root;
public SerializedProperty enableShadow;
public SerializedProperty enableSSR;
public SerializedProperty enableSSAO;
public SerializedProperty enableSSSAndTransmission;
public SerializedProperty diffuseGlobalDimmer;
public SerializedProperty specularGlobalDimmer;
public SerializedProperty enableForwardRenderingOnly;
public SerializedProperty enableDepthPrepassWithDeferredRendering;
public SerializedProperty enableAlphaTestOnlyInDeferredPrepass;
public SerializedProperty enableTransparentPrepass;
public SerializedProperty enableMotionVectors;
public SerializedProperty enableObjectMotionVectors;
public SerializedProperty enableDBuffer;
public SerializedProperty enableAtmosphericScattering;
public SerializedProperty enableRoughRefraction;
public SerializedProperty enableTransparentPostpass;
public SerializedProperty enableDistortion;
public SerializedProperty enablePostprocess;
public SerializedProperty enableStereo;
public SerializedProperty enableAsyncCompute;
public SerializedProperty enableOpaqueObjects;
public SerializedProperty enableTransparentObjects;
public SerializedProperty enableMSAA;
public SerializedProperty enableShadowMask;
public SerializedLightLoopSettings lightLoopSettings;
public SerializedFrameSettings(SerializedProperty root)
{
this.root = root;
enableShadow = root.Find((FrameSettings d) => d.enableShadow);
enableSSR = root.Find((FrameSettings d) => d.enableSSR);
enableSSAO = root.Find((FrameSettings d) => d.enableSSAO);
enableSSSAndTransmission = root.Find((FrameSettings d) => d.enableSSSAndTransmission);
diffuseGlobalDimmer = root.Find((FrameSettings d) => d.diffuseGlobalDimmer);
specularGlobalDimmer = root.Find((FrameSettings d) => d.specularGlobalDimmer);
enableForwardRenderingOnly = root.Find((FrameSettings d) => d.enableForwardRenderingOnly);
enableDepthPrepassWithDeferredRendering = root.Find((FrameSettings d) => d.enableDepthPrepassWithDeferredRendering);
enableAlphaTestOnlyInDeferredPrepass = root.Find((FrameSettings d) => d.enableAlphaTestOnlyInDeferredPrepass);
enableTransparentPrepass = root.Find((FrameSettings d) => d.enableTransparentPrepass);
enableMotionVectors = root.Find((FrameSettings d) => d.enableMotionVectors);
enableObjectMotionVectors = root.Find((FrameSettings d) => d.enableObjectMotionVectors);
enableDBuffer = root.Find((FrameSettings d) => d.enableDBuffer);
enableAtmosphericScattering = root.Find((FrameSettings d) => d.enableAtmosphericScattering);
enableRoughRefraction = root.Find((FrameSettings d) => d.enableRoughRefraction);
enableTransparentPostpass = root.Find((FrameSettings d) => d.enableTransparentPostpass);
enableDistortion = root.Find((FrameSettings d) => d.enableDistortion);
enablePostprocess = root.Find((FrameSettings d) => d.enablePostprocess);
enableStereo = root.Find((FrameSettings d) => d.enableStereo);
enableAsyncCompute = root.Find((FrameSettings d) => d.enableAsyncCompute);
enableOpaqueObjects = root.Find((FrameSettings d) => d.enableOpaqueObjects);
enableTransparentObjects = root.Find((FrameSettings d) => d.enableTransparentObjects);
enableMSAA = root.Find((FrameSettings d) => d.enableMSAA);
enableShadowMask = root.Find((FrameSettings d) => d.enableShadowMask);
lightLoopSettings = new SerializedLightLoopSettings(root.Find((FrameSettings d) => d.lightLoopSettings));
}
}
}

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


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

94
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedHDCamera.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering
{
class SerializedHDCamera
{
public SerializedObject serializedObject;
public SerializedObject serializedAdditionalDataObject;
public SerializedProperty clearFlags;
public SerializedProperty backgroundColor;
public SerializedProperty normalizedViewPortRect;
public SerializedProperty fieldOfView;
public SerializedProperty orthographic;
public SerializedProperty orthographicSize;
public SerializedProperty depth;
public SerializedProperty cullingMask;
public SerializedProperty _renderingPath; // Legacy rendering path
public SerializedProperty occlusionCulling;
public SerializedProperty targetTexture;
public SerializedProperty HDR;
public SerializedProperty allowMSAA;
public SerializedProperty allowDynamicResolution;
public SerializedProperty stereoConvergence;
public SerializedProperty stereoSeparation;
public SerializedProperty nearClippingPlane;
public SerializedProperty farClippingPlane;
public SerializedProperty targetEye;
#if ENABLE_MULTIPLE_DISPLAYS
public SerializedProperty targetDisplay;
#endif
public SerializedProperty renderingPath;
public SerializedProperty volumeLayerMask;
public SerializedFrameSettings frameSettings;
public SerializedHDCamera(SerializedObject serializedObject)
{
this.serializedObject = serializedObject;
var additionals = CoreEditorUtils.GetAdditionalData<HDAdditionalCameraData>(serializedObject.targetObjects);
serializedAdditionalDataObject = new SerializedObject(additionals);
clearFlags = serializedObject.FindProperty("m_ClearFlags");
backgroundColor = serializedObject.FindProperty("m_BackGroundColor");
normalizedViewPortRect = serializedObject.FindProperty("m_NormalizedViewPortRect");
nearClippingPlane = serializedObject.FindProperty("near clip plane");
farClippingPlane = serializedObject.FindProperty("far clip plane");
fieldOfView = serializedObject.FindProperty("field of view");
orthographic = serializedObject.FindProperty("orthographic");
orthographicSize = serializedObject.FindProperty("orthographic size");
depth = serializedObject.FindProperty("m_Depth");
cullingMask = serializedObject.FindProperty("m_CullingMask");
_renderingPath = serializedObject.FindProperty("m_RenderingPath");
occlusionCulling = serializedObject.FindProperty("m_OcclusionCulling");
targetTexture = serializedObject.FindProperty("m_TargetTexture");
HDR = serializedObject.FindProperty("m_HDR");
allowMSAA = serializedObject.FindProperty("m_AllowMSAA");
allowDynamicResolution = serializedObject.FindProperty("m_AllowDynamicResolution");
stereoConvergence = serializedObject.FindProperty("m_StereoConvergence");
stereoSeparation = serializedObject.FindProperty("m_StereoSeparation");
#if ENABLE_MULTIPLE_DISPLAYS
targetDisplay = serializedObject.FindProperty("m_TargetDisplay");
#endif
targetEye = serializedObject.FindProperty("m_TargetEye");
renderingPath = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.renderingPath);
volumeLayerMask = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.volumeLayerMask);
frameSettings = new SerializedFrameSettings(serializedAdditionalDataObject.FindProperty("m_FrameSettings"));
}
public void Update()
{
serializedObject.Update();
serializedAdditionalDataObject.Update();
// Be sure legacy HDR option is disable on camera as it cause banding in SceneView. Yes, it is a contradiction, but well, Unity...
// When HDR option is enabled, Unity render in FP16 then convert to 8bit with a stretch copy (this cause banding as it should be convert to sRGB (or other color appropriate color space)), then do a final shader with sRGB conversion
// When LDR, unity render in 8bitSRGB, then do a final shader with sRGB conversion
// What should be done is just in our Post process we convert to sRGB and store in a linear 10bit, but require C++ change...
HDR.boolValue = false;
}
public void Apply()
{
serializedObject.ApplyModifiedProperties();
serializedAdditionalDataObject.ApplyModifiedProperties();
}
}
}

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


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

30
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedLightLoopSettings.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering
{
class SerializedLightLoopSettings
{
public SerializedProperty root;
public SerializedProperty enableTileAndCluster;
public SerializedProperty enableComputeLightEvaluation;
public SerializedProperty enableComputeLightVariants;
public SerializedProperty enableComputeMaterialVariants;
public SerializedProperty enableFptlForForwardOpaque;
public SerializedProperty enableBigTilePrepass;
public SerializedProperty isFptlEnabled;
public SerializedLightLoopSettings(SerializedProperty root)
{
this.root = root;
enableTileAndCluster = root.Find((LightLoopSettings l) => l.enableTileAndCluster);
enableComputeLightEvaluation = root.Find((LightLoopSettings l) => l.enableComputeLightEvaluation);
enableComputeLightVariants = root.Find((LightLoopSettings l) => l.enableComputeLightVariants);
enableComputeMaterialVariants = root.Find((LightLoopSettings l) => l.enableComputeMaterialVariants);
enableFptlForForwardOpaque = root.Find((LightLoopSettings l) => l.enableFptlForForwardOpaque);
enableBigTilePrepass = root.Find((LightLoopSettings l) => l.enableBigTilePrepass);
isFptlEnabled = root.Find((LightLoopSettings l) => l.isFptlEnabled);
}
}
}

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


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