浏览代码

Lw/review camera and light editors (#1899)

*  Updated Camera and Light inspector UI. MSAA tooltip on camera inspector now displays correctly. Made camera and light classes internal.

*  Renamed camera and light editor classes.

*  Added info boxes to camera editor and fixed tooltip text.

*  updated release notes

* Update CHANGELOG.md
/main
GitHub 6 年前
当前提交
16ef6af0
共有 7 个文件被更改,包括 180 次插入189 次删除
  1. 15
      com.unity.render-pipelines.lightweight/CHANGELOG.md
  2. 18
      com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightRenderPipelineLightEditor.cs
  3. 163
      com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightRenderPipelineCameraEditor.cs
  4. 173
      com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightCameraEditor.cs
  5. 0
      /com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightRenderPipelineCameraEditor.cs.meta
  6. 0
      /com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightRenderPipelineLightEditor.cs.meta
  7. 0
      /com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightRenderPipelineLightEditor.cs

15
com.unity.render-pipelines.lightweight/CHANGELOG.md


### Added
- When you have enabled Gizmos, they now appear correctly in the Game view.
- Added requiresDepthPrepass field to RenderingData struct to tell if the runtime platform requires a depth prepass to generate a camera depth texture.
- The _RenderingData_ struct now holds a reference to _CullResults_.
- The `RenderingData` struct now holds a reference to `CullResults`.
- When __HDR__ is enabled in the Camera but disabled in the Asset, an information box in the Camera Inspector informs you about it.
- When __MSAA__ is enabled in the Camera but disabled in the Asset, an information box in the Camera Inspector informs you about it.
- The _RenderingData_ struct is now read-only.
- _ScriptableRenderer_ always perform a Clear before calling _IRendererSetup::Setup_.
- _ScriptableRenderPass::Execute_ no longer takes _CullResults_ as input. Instead, use _RenderingData_ as input, since that references _CullResults_.
- _IRendererSetup::Setup_ no longer takes _ScriptableRenderContext_ and _CullResults_ as input.
- The `RenderingData` struct is now read-only.
- `ScriptableRenderer`always perform a Clear before calling `IRendererSetup::Setup.`
- `ScriptableRenderPass::Execute` no longer takes `CullResults` as input. Instead, use `RenderingData`as input, since that references `CullResults`.
- `IRendererSetup_Setup` no longer takes `ScriptableRenderContext` and `CullResults` as input.
- The tooltip for the the camera __MSAA__ property now appears correctly.
- Add callbacks to LWRP that can be attached to a camera (IBeforeCameraRender, IAfterDepthPrePass, IAfterOpaquePass, IAfterOpaquePostProcess, IAfterSkyboxPass, IAfterTransparentPass, IAfterRender)
- Added callbacks to LWRP that can be attached to a camera (IBeforeCameraRender, IAfterDepthPrePass, IAfterOpaquePass, IAfterOpaquePostProcess, IAfterSkyboxPass, IAfterTransparentPass, IAfterRender)
###Changed
- Clean up LWRP creation of render textures. If we are not going straight to screen ensure that we create both depth and color targets.

18
com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightRenderPipelineLightEditor.cs


{
[CanEditMultipleObjects]
[CustomEditorForRenderPipeline(typeof(Light), typeof(LightweightPipelineAsset))]
class LightweightLightEditor : LightEditor
internal class LightweightRenderPipelineLightEditor : LightEditor
{
AnimBool m_AnimSpotOptions = new AnimBool();
AnimBool m_AnimPointOptions = new AnimBool();

class Styles
{
public readonly GUIContent SpotAngle = new GUIContent("Spot Angle", "Controls the angle in degrees at the base of a Spot light's cone.");
public readonly GUIContent Cookie = new GUIContent("Cookie", "Specifies the Texture mask to cast shadows, create silhouettes, or patterned illumination for the light.");
public readonly GUIContent CookieSize = new GUIContent("Cookie Size", "Controls the size of the cookie mask currently assigned to the light.");
public readonly GUIContent SpotAngle = EditorGUIUtility.TrTextContent("Spot Angle", "Controls the angle in degrees at the base of a Spot light's cone.");
public readonly GUIStyle invisibleButton = "InvisibleButton";
public readonly GUIContent Cookie = EditorGUIUtility.TrTextContent("Cookie", "Specifies the Texture mask to cast shadows, create silhouettes, or patterned illumination for the light.");
public readonly GUIContent CookieSize = EditorGUIUtility.TrTextContent("Cookie Size", "Controls the size of the cookie mask currently assigned to the light.");
public readonly GUIContent BakingWarning = new GUIContent("Light mode is currently overridden to Realtime mode. Enable Baked Global Illumination to use Mixed or Baked light modes.");
public readonly GUIContent CookieWarning = new GUIContent("Cookie textures for spot lights should be set to clamp, not repeat, to avoid artifacts.");
public readonly GUIContent DisabledLightWarning = new GUIContent("Lighting has been disabled in at least one Scene view. Any changes applied to lights in the Scene will not be updated in these views until Lighting has been enabled again.");
public readonly GUIContent BakingWarning = EditorGUIUtility.TrTextContent("Light mode is currently overridden to Realtime mode. Enable Baked Global Illumination to use Mixed or Baked light modes.");
public readonly GUIContent CookieWarning = EditorGUIUtility.TrTextContent("Cookie textures for spot lights should be set to clamp, not repeat, to avoid artifacts.");
public readonly GUIContent DisabledLightWarning = EditorGUIUtility.TrTextContent("Lighting has been disabled in at least one Scene view. Any changes applied to lights in the Scene will not be updated in these views until Lighting has been enabled again.");
public readonly GUIContent ShadowsNotSupportedWarning = new GUIContent("Realtime shadows for point lights are not supported. Either disable shadows or set the light mode to Baked.");
public readonly GUIContent ShadowsNotSupportedWarning = EditorGUIUtility.TrTextContent("Realtime shadows for point lights are not supported. Either disable shadows or set the light mode to Baked.");
}
static Styles s_Styles;

163
com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightRenderPipelineCameraEditor.cs


using System;
using UnityEditor.AnimatedValues;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering.LightweightPipeline;
namespace UnityEditor.Experimental.Rendering.LightweightPipeline
{
[CustomEditorForRenderPipeline(typeof(Camera), typeof(LightweightPipelineAsset))]
[CanEditMultipleObjects]
internal class LightweightRenderPipelineCameraEditor : CameraEditor
{
internal class Styles
{
public readonly GUIContent renderingPathLabel = EditorGUIUtility.TrTextContent("Rendering Path", "Lightweight Render Pipeline only supports Forward rendering path.");
public readonly GUIContent[] renderingPathOptions = { EditorGUIUtility.TrTextContent("Forward") };
public readonly string hdrDisabledWarning = "HDR rendering is disabled in the Lightweight Render Pipeline asset.";
public readonly string mssaDisabledWarning = "Anti-aliasing is disabled in the Lightweight Render Pipeline asset.";
};
public Camera camera { get { return target as Camera; } }
// Animation Properties
public bool isSameClearFlags { get { return !settings.clearFlags.hasMultipleDifferentValues; } }
public bool isSameOrthographic { get { return !settings.orthographic.hasMultipleDifferentValues; } }
static readonly int[] s_RenderingPathValues = {0};
static Styles s_Styles;
LightweightPipelineAsset m_LightweightPipeline;
readonly AnimBool m_ShowBGColorAnim = new AnimBool();
readonly AnimBool m_ShowOrthoAnim = new AnimBool();
readonly AnimBool m_ShowTargetEyeAnim = new AnimBool();
void SetAnimationTarget(AnimBool anim, bool initialize, bool targetValue)
{
if (initialize)
{
anim.value = targetValue;
anim.valueChanged.AddListener(Repaint);
}
else
{
anim.target = targetValue;
}
}
void UpdateAnimationValues(bool initialize)
{
SetAnimationTarget(m_ShowBGColorAnim, initialize, isSameClearFlags && (camera.clearFlags == CameraClearFlags.SolidColor || camera.clearFlags == CameraClearFlags.Skybox));
SetAnimationTarget(m_ShowOrthoAnim, initialize, isSameOrthographic && camera.orthographic);
SetAnimationTarget(m_ShowTargetEyeAnim, initialize, settings.targetEye.intValue != (int)StereoTargetEyeMask.Both || PlayerSettings.virtualRealitySupported);
}
public new void OnEnable()
{
m_LightweightPipeline = GraphicsSettings.renderPipelineAsset as LightweightPipelineAsset;
settings.OnEnable();
UpdateAnimationValues(true);
}
public void OnDisable()
{
m_ShowBGColorAnim.valueChanged.RemoveListener(Repaint);
m_ShowOrthoAnim.valueChanged.RemoveListener(Repaint);
m_ShowTargetEyeAnim.valueChanged.RemoveListener(Repaint);
m_LightweightPipeline = null;
}
public override void OnInspectorGUI()
{
if (s_Styles == null)
s_Styles = new Styles();
settings.Update();
UpdateAnimationValues(false);
settings.DrawClearFlags();
using (var group = new EditorGUILayout.FadeGroupScope(m_ShowBGColorAnim.faded))
if (group.visible) settings.DrawBackgroundColor();
settings.DrawCullingMask();
EditorGUILayout.Space();
settings.DrawProjection();
settings.DrawClippingPlanes();
settings.DrawNormalizedViewPort();
EditorGUILayout.Space();
settings.DrawDepth();
DrawRenderingPath();
DrawTargetTexture();
settings.DrawOcclusionCulling();
DrawHDR();
DrawMSAA();
settings.DrawVR();
settings.DrawMultiDisplay();
using (var group = new EditorGUILayout.FadeGroupScope(m_ShowTargetEyeAnim.faded))
if (group.visible) settings.DrawTargetEye();
EditorGUILayout.Space();
EditorGUILayout.Space();
settings.ApplyModifiedProperties();
}
void DrawRenderingPath()
{
using (new EditorGUI.DisabledScope(true))
{
EditorGUILayout.IntPopup(s_Styles.renderingPathLabel, 0, s_Styles.renderingPathOptions, s_RenderingPathValues);
}
}
void DrawHDR()
{
bool disabled = settings.HDR.boolValue && !m_LightweightPipeline.supportsHDR;
using (new EditorGUI.DisabledScope(disabled))
{
settings.DrawHDR();
}
if (disabled)
EditorGUILayout.HelpBox(s_Styles.hdrDisabledWarning, MessageType.Info);
}
void DrawTargetTexture()
{
EditorGUILayout.PropertyField(settings.targetTexture);
if (!settings.targetTexture.hasMultipleDifferentValues)
{
var texture = settings.targetTexture.objectReferenceValue as RenderTexture;
int pipelineSamplesCount = m_LightweightPipeline.msaaSampleCount;
if (texture && texture.antiAliasing > pipelineSamplesCount)
{
string pipelineMSAACaps = (pipelineSamplesCount > 1)
? String.Format("is set to support {0}x", pipelineSamplesCount)
: "has MSAA disabled";
EditorGUILayout.HelpBox(String.Format("Camera target texture requires {0}x MSAA. Lightweight pipeline {1}.", texture.antiAliasing, pipelineMSAACaps),
MessageType.Warning, true);
}
}
}
void DrawMSAA()
{
bool disabled = settings.allowMSAA.boolValue && m_LightweightPipeline.msaaSampleCount <= 1;
using (new EditorGUI.DisabledScope(disabled))
{
settings.DrawMSAA();
}
if (disabled)
EditorGUILayout.HelpBox(s_Styles.mssaDisabledWarning, MessageType.Info);
}
}
}

173
com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightCameraEditor.cs


using System;
using UnityEditor.AnimatedValues;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering.LightweightPipeline;
namespace UnityEditor
{
[CustomEditorForRenderPipeline(typeof(Camera), typeof(LightweightPipelineAsset))]
[CanEditMultipleObjects]
public class LightweightameraEditor : CameraEditor
{
public class Styles
{
public readonly GUIContent renderingPathLabel = new GUIContent("Rendering Path");
public readonly GUIContent[] renderingPathOptions = { new GUIContent("Forward") };
public readonly GUIContent renderingPathInfo = new GUIContent("Lightweight Pipeline only supports Forward rendering path.");
public readonly GUIContent fixNow = new GUIContent("Fix now");
public readonly GUIContent additionalCameraDataLabel = new GUIContent("Add Additional Camera Data");
public readonly string mssaDisabledWarning = "Anti Aliasing is disabled in Lightweight Pipeline settings.";
};
public Camera camera { get { return target as Camera; } }
// Animation Properties
public bool isSameClearFlags { get { return !settings.clearFlags.hasMultipleDifferentValues; } }
public bool isSameOrthographic { get { return !settings.orthographic.hasMultipleDifferentValues; } }
static readonly int[] s_RenderingPathValues = {0};
static Styles s_Styles;
LightweightPipelineAsset m_LightweightPipeline;
readonly AnimBool m_ShowBGColorAnim = new AnimBool();
readonly AnimBool m_ShowOrthoAnim = new AnimBool();
readonly AnimBool m_ShowTargetEyeAnim = new AnimBool();
void SetAnimationTarget(AnimBool anim, bool initialize, bool targetValue)
{
if (initialize)
{
anim.value = targetValue;
anim.valueChanged.AddListener(Repaint);
}
else
{
anim.target = targetValue;
}
}
void UpdateAnimationValues(bool initialize)
{
SetAnimationTarget(m_ShowBGColorAnim, initialize, isSameClearFlags && (camera.clearFlags == CameraClearFlags.SolidColor || camera.clearFlags == CameraClearFlags.Skybox));
SetAnimationTarget(m_ShowOrthoAnim, initialize, isSameOrthographic && camera.orthographic);
SetAnimationTarget(m_ShowTargetEyeAnim, initialize, settings.targetEye.intValue != (int)StereoTargetEyeMask.Both || PlayerSettings.virtualRealitySupported);
}
public new void OnEnable()
{
m_LightweightPipeline = GraphicsSettings.renderPipelineAsset as LightweightPipelineAsset;
settings.OnEnable();
UpdateAnimationValues(true);
}
public void OnDisable()
{
m_ShowBGColorAnim.valueChanged.RemoveListener(Repaint);
m_ShowOrthoAnim.valueChanged.RemoveListener(Repaint);
m_ShowTargetEyeAnim.valueChanged.RemoveListener(Repaint);
m_LightweightPipeline = null;
}
public override void OnInspectorGUI()
{
if (s_Styles == null)
s_Styles = new Styles();
settings.Update();
UpdateAnimationValues(false);
settings.DrawClearFlags();
using (var group = new EditorGUILayout.FadeGroupScope(m_ShowBGColorAnim.faded))
if (group.visible) settings.DrawBackgroundColor();
settings.DrawCullingMask();
EditorGUILayout.Space();
settings.DrawProjection();
settings.DrawClippingPlanes();
settings.DrawNormalizedViewPort();
EditorGUILayout.Space();
settings.DrawDepth();
DrawRenderingPath();
DrawTargetTexture();
settings.DrawOcclusionCulling();
DrawHDR();
DrawMSAA();
settings.DrawVR();
settings.DrawMultiDisplay();
using (var group = new EditorGUILayout.FadeGroupScope(m_ShowTargetEyeAnim.faded))
if (group.visible) settings.DrawTargetEye();
EditorGUILayout.Space();
EditorGUILayout.Space();
GameObject gameObject = camera.gameObject;
if (gameObject.GetComponent<LightweightAdditionalCameraData>() == null)
{
if (GUILayout.Button(s_Styles.additionalCameraDataLabel))
{
gameObject.AddComponent<LightweightAdditionalCameraData>();
}
}
settings.ApplyModifiedProperties();
}
void DrawRenderingPath()
{
using (new EditorGUI.DisabledScope(true))
{
EditorGUILayout.IntPopup(s_Styles.renderingPathLabel, 0, s_Styles.renderingPathOptions, s_RenderingPathValues);
}
EditorGUILayout.HelpBox(s_Styles.renderingPathInfo.text, MessageType.Info);
}
void DrawHDR()
{
settings.DrawHDR();
if (settings.HDR.boolValue && !m_LightweightPipeline.supportsHDR)
EditorGUILayout.HelpBox("HDR rendering is disabled in Lightweight Pipeline asset.", MessageType.Warning);
}
void DrawTargetTexture()
{
EditorGUILayout.PropertyField(settings.targetTexture);
if (!settings.targetTexture.hasMultipleDifferentValues)
{
var texture = settings.targetTexture.objectReferenceValue as RenderTexture;
int pipelineSamplesCount = m_LightweightPipeline.msaaSampleCount;
if (texture && texture.antiAliasing > pipelineSamplesCount)
{
string pipelineMSAACaps = (pipelineSamplesCount > 1)
? String.Format("is set to support {0}x", pipelineSamplesCount)
: "has MSAA disabled";
EditorGUILayout.HelpBox(String.Format("Camera target texture requires {0}x MSAA. Lightweight pipeline {1}.", texture.antiAliasing, pipelineMSAACaps),
MessageType.Warning, true);
if (GUILayout.Button(s_Styles.fixNow))
m_LightweightPipeline.msaaSampleCount = texture.antiAliasing;
}
}
}
void DrawMSAA()
{
EditorGUILayout.PropertyField(settings.allowMSAA);
if (settings.allowMSAA.boolValue && m_LightweightPipeline.msaaSampleCount <= 1)
{
EditorGUILayout.HelpBox(s_Styles.mssaDisabledWarning, MessageType.Warning);
if (GUILayout.Button(s_Styles.fixNow))
m_LightweightPipeline.msaaSampleCount = 4;
}
}
}
}

/com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightCameraEditor.cs.meta → /com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightRenderPipelineCameraEditor.cs.meta

/com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightLightEditor.cs.meta → /com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightRenderPipelineLightEditor.cs.meta

/com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightLightEditor.cs → /com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightRenderPipelineLightEditor.cs

正在加载...
取消
保存