浏览代码

[HDCameraEditor] Synchronize PostProcessLayer and HDAdditionalCameraData for preview camera

/main
Frédéric Vauchelles 7 年前
当前提交
b9c816c4
共有 5 个文件被更改,包括 64 次插入29 次删除
  1. 12
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Data.cs
  2. 44
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Drawers.cs
  3. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Handlers.cs
  4. 25
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.cs
  5. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedHDCamera.cs

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


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

{
SerializedHDCamera m_SerializedHdCamera;
AnimBool[] m_AnimBools = new AnimBool[7];
AnimBool[] m_AnimBools = new AnimBool[8];
public AnimBool isSectionExpandedBGColorOptions { get { return m_AnimBools[0]; } }
public AnimBool isSectionExpandedOrthoOptions { get { return m_AnimBools[1]; } }

public AnimBool isSectionExpandedScreenSpace { get { return m_AnimBools[5]; } }
public AnimBool isSectionExpandedMiscellaneous { get { return m_AnimBools[6]; } }
public AnimBool isSectionExpandedRenderLoopSettings { get { return m_AnimBools[7]; } }
public UIState()
{

var targetEyeValue = (StereoTargetEyeMask)m_SerializedHdCamera.targetEye.intValue;
isSectionExpandedTargetEyeOptions.target = targetEyeValue != StereoTargetEyeMask.Both || PlayerSettings.virtualRealitySupported;
// SRP settings are available only if the rendering path is not the Default one (configured by the SRP asset)
var renderingPath = (HDAdditionalCameraData.RenderingPath)m_SerializedHdCamera.renderingPath.intValue;
isSectionExpandedRenderLoopSettings.target = renderingPath != HDAdditionalCameraData.RenderingPath.Default;
}
}
}

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


partial class HDCameraEditor
{
static readonly CED.IDrawer[] k_PrimarySection =
{
CED.Action(Drawer_FieldClearFlags),

(s, d, o, i) => s.isSectionExpandedTargetEyeOptions.faded,
true,
CED.Action(Drawer_FieldTargetEye)),
CED.FoldoutGroup(
"Shader Features",
(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)),
CED.FadeGroup(
(s, d, o, i) => s.isSectionExpandedRenderLoopSettings.faded,
false,
CED.FoldoutGroup(
"Shader Features",
(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)))
};
static void Drawer_FieldClearFlags(UIState s, SerializedHDCamera p, Editor owner)

5
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Handlers.cs


using System.Reflection;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering.PostProcessing;
using Object = UnityEngine.Object;
namespace UnityEditor.Experimental.Rendering

m_PreviewCamera.targetTexture = previewTexture;
m_PreviewCamera.pixelRect = new Rect(0, 0, cameraRect.width, cameraRect.height);
//Handles.EmitGUIGeometryForCamera(c, m_PreviewCamera);
SynchronizePreviewCameraWithCamera(c);
m_PreviewCamera.Render();
GL.sRGBWrite = false;
Graphics.DrawTexture(cameraRect, previewTexture, new Rect(0, 0, 1, 1), 0, 0, 0, 0, GUI.color, GUITextureBlit2SRGBMaterial);

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


using UnityEngine;
using System;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
namespace UnityEditor.Experimental.Rendering
{

RenderTexture m_PreviewTexture;
Camera m_PreviewCamera;
HDAdditionalCameraData m_PreviewAdditionalCameraData;
PostProcessLayer m_PreviewPostProcessLayer;
void OnEnable()
{

m_PreviewCamera = EditorUtility.CreateGameObjectWithHideFlags("Preview Camera", HideFlags.HideAndDontSave, typeof(Camera)).GetComponent<Camera>();
m_PreviewAdditionalCameraData = m_PreviewCamera.gameObject.AddComponent<HDAdditionalCameraData>();
m_PreviewPostProcessLayer = m_PreviewCamera.gameObject.AddComponent<PostProcessLayer>();
m_PreviewCamera.enabled = false;
}

k_PrimarySection.Draw(s, d, this);
d.Apply();
}
void SynchronizePreviewCameraWithCamera(Camera c)
{
EditorUtility.CopySerialized(c.GetComponent<HDAdditionalCameraData>(), m_PreviewAdditionalCameraData);
var layer = c.GetComponent<PostProcessLayer>();
if (layer != null)
{
if (m_PreviewPostProcessLayer == null)
m_PreviewPostProcessLayer = c.gameObject.AddComponent<PostProcessLayer>();
EditorUtility.CopySerialized(layer, m_PreviewPostProcessLayer);
}
else if (m_PreviewPostProcessLayer != null)
{
DestroyImmediate(m_PreviewPostProcessLayer);
m_PreviewPostProcessLayer = null;
}
}
}
}

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


using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering
{

this.serializedObject = serializedObject;
var additionals = CoreEditorUtils.GetAdditionalData<HDAdditionalCameraData>(serializedObject.targetObjects);
serializedAdditionalDataObject = new SerializedObject(additionals);
var hideFlags = serializedAdditionalDataObject.FindProperty("m_ObjectHideFlags");
hideFlags.intValue = (int)HideFlags.HideInInspector;
serializedAdditionalDataObject.ApplyModifiedProperties();
clearFlags = serializedObject.FindProperty("m_ClearFlags");
backgroundColor = serializedObject.FindProperty("m_BackGroundColor");

正在加载...
取消
保存