浏览代码

[PlanarReflection]Update UI

/main
Frédéric Vauchelles 7 年前
当前提交
1d4bba47
共有 15 个文件被更改,包括 157 次插入64 次删除
  1. 15
      ScriptableRenderPipeline/Core/CoreRP/Editor/CoreEditorDrawers.cs
  2. 9
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Drawers.cs
  3. 17
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Handles.cs
  4. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.cs
  5. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedPlanarReflectionProbe.cs
  6. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.Gizmos.cs
  7. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.Handles.cs
  8. 30
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/FrameSettingsUI.cs
  9. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/LightLoopSettingsUI.cs
  10. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedFrameSettings.cs
  11. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedLightLoopSettings.cs
  12. 27
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/PlanarReflectionProbe.cs
  13. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ProbeWrapper.cs
  14. 30
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ReflectionSystem.cs
  15. 52
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ReflectionSystemInternal.cs

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


using System;
using System.Security.Principal;
using UnityEditor.AnimatedValues;
using UnityEngine;

public static IDrawer Group(params IDrawer[] drawers)
{
return new GroupDrawerInternal(drawers);
}
public static IDrawer LabelWidth(float width, params IDrawer[] drawers)
{
return Action((s, d, o) =>
{
var l = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = width;
for (var i = 0; i < drawers.Length; ++i)
drawers[i].Draw(s, d, o);
EditorGUIUtility.labelWidth = l;
}
);
}
public static IDrawer Action(params ActionDrawer[] drawers)

9
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Drawers.cs


),
SectionFoldoutInfluenceSettings,
SectionFoldoutCaptureSettings,
CED.Select(
(s, d, o) => s.frameSettings,
(s, d, o) => d.frameSettings,
FrameSettingsUI.Inspector
),
CED.space,
CED.Action(Drawer_SectionBakeButton)
);

static void Drawer_SectionCaptureSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.captureOffset, _.GetContent("Capture Offset"));
EditorGUILayout.PropertyField(d.captureLocalPosition, _.GetContent("Capture Local Position"));
}
static void Drawer_SectionProbeModeCustomSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)

EditorGUIUtility.IconContent("EditCollider", "|Modify the base shape. (SHIFT+1)"),
EditorGUIUtility.IconContent("PreMatCube", "|Modify the influence volume. (SHIFT+2)"),
EditorGUIUtility.IconContent("SceneViewOrtho", "|Modify the influence normal volume. (SHIFT+3)"),
EditorGUIUtility.IconContent("MoveTool", "|Move the center.")
EditorGUIUtility.IconContent("MoveTool", "|Move the capture position.")
});
}
}

17
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Handles.cs


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

InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, d.influenceVolume, o, mat, d);
break;
case EditCenter:
InfluenceVolumeUI.DrawHandles_EditCenter(s.influenceVolume, d.influenceVolume, o, d.transform, d);
break;
{
EditorGUI.BeginChangeCheck();
var m = Handles.matrix;
Handles.matrix = mat;
d.captureLocalPosition = Handles.PositionHandle(d.captureLocalPosition, d.transform.rotation);
if (EditorGUI.EndChangeCheck())
EditorUtility.SetDirty(d);
Handles.matrix = m;
break;
}
}
}

break;
case EditInfluenceNormalShape:
InfluenceVolumeUI.DrawGizmos_EditInfluenceNormal(s.influenceVolume, d.influenceVolume, mat);
break;
case EditCenter:
InfluenceVolumeUI.DrawGizmos_EditCenter(s.influenceVolume, d.influenceVolume, mat);
break;
default:
InfluenceVolumeUI.DrawGizmos_EditNone(s.influenceVolume, d.influenceVolume, mat);

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.cs


static readonly int k_AnimBoolTotal = k_AnimBoolFields + k_ReflectionProbeModeModeCount;
public InfluenceVolumeUI influenceVolume = new InfluenceVolumeUI();
public FrameSettingsUI frameSettings = new FrameSettingsUI();
public AnimBool isSectionExpandedInfluenceSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount]; } }
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 1]; } }

public override void Reset(SerializedPlanarReflectionProbe data, UnityAction repaint)
{
frameSettings.Reset(data.frameSettings, repaint);
influenceVolume.Reset(data.influenceVolume, repaint);
base.Reset(data, repaint);
}

for (var i = 0; i < k_ReflectionProbeModeModeCount; i++)
m_AnimBools[i].target = i == data.mode.intValue;
frameSettings.Update();
influenceVolume.Update();
base.Update();
}

8
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedPlanarReflectionProbe.cs


public SerializedProperty proxyVolumeReference;
public SerializedInfluenceVolume influenceVolume;
public SerializedProperty captureOffset;
public SerializedProperty captureLocalPosition;
public SerializedFrameSettings frameSettings;
public PlanarReflectionProbe target { get { return serializedObject.targetObject as PlanarReflectionProbe; } }

proxyVolumeReference = serializedObject.Find((PlanarReflectionProbe p) => p.proxyVolumeReference);
influenceVolume = new SerializedInfluenceVolume(serializedObject.Find((PlanarReflectionProbe p) => p.influenceVolume));
captureOffset = serializedObject.Find((PlanarReflectionProbe p) => p.centerOffset);
captureLocalPosition = serializedObject.Find((PlanarReflectionProbe p) => p.captureLocalPosition);
frameSettings = new SerializedFrameSettings(serializedObject.Find((PlanarReflectionProbe p) => p.frameSettings));
}
public void Update()

7
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.Gizmos.cs


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

{
DrawGizmos_Generic(s, d, matrix, 2);
}
public static void DrawGizmos_EditCenter(InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix)
{
}
public static void DrawGizmos_EditNone(InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix)

7
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.Handles.cs


using System;
using System;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;

}
Handles.matrix = mat;
Handles.color = c;
}
public static void DrawHandles_EditCenter(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Transform transform, Object sourceAsset)
{
}
static void DrawBoxHandle(

30
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/FrameSettingsUI.cs


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

"Rendering Passes",
(s, p, o) => s.isSectionExpandedRenderingPasses,
true,
CED.Action(Drawer_SectionRenderingPasses));
CED.LabelWidth(200, CED.Action(Drawer_SectionRenderingPasses))
);
CED.Action(Drawer_FieldForwardRenderingOnly),
CED.FadeGroup(
(s, d, o, i) => s.isSectionExpandedUseForwardOnly,
false,
CED.Action(Drawer_FieldUseDepthPrepassWithDefferedRendering),
CED.LabelWidth(300,
CED.Action(Drawer_FieldForwardRenderingOnly),
(s, d, o, i) => s.isSectionExpandedUseDepthPrepass,
true,
CED.Action(Drawer_FieldRenderAlphaTestOnlyInDeferredPrepass))),
CED.Action(Drawer_SectionOtherRenderingSettings));
(s, d, o, i) => s.isSectionExpandedUseForwardOnly,
false,
CED.Action(Drawer_FieldUseDepthPrepassWithDefferedRendering),
CED.FadeGroup(
(s, d, o, i) => s.isSectionExpandedUseDepthPrepass,
true,
CED.Action(Drawer_FieldRenderAlphaTestOnlyInDeferredPrepass))),
CED.Action(Drawer_SectionOtherRenderingSettings)
)
);
public static CED.IDrawer SectionXRSettings = CED.FadeGroup(
(s, d, o, i) => s.isSectionExpandedXRSupported,

(s, p, o) => s.isSectionExpandedXRSettings,
true,
CED.Action(Drawer_FieldStereoEnabled)));
CED.LabelWidth(200, CED.Action(Drawer_FieldStereoEnabled))));
CED.Action(Drawer_SectionLightingSettings));
CED.LabelWidth(250, CED.Action(Drawer_SectionLightingSettings)));
public AnimBool isSectionExpandedRenderingPasses { get { return m_AnimBools[0]; } }
public AnimBool isSectionExpandedLightingSettings { get { return m_AnimBools[1]; } }

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/LightLoopSettingsUI.cs


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

"Light Loop Settings",
(s, p, o) => s.isSectionExpandedLightLoopSettings,
true,
CED.Action(Drawer_SectionLightLoopSettings));
CED.LabelWidth(250, CED.Action(Drawer_SectionLightLoopSettings)));
public AnimBool isSectionExpandedLightLoopSettings { get { return m_AnimBools[0]; } }
public AnimBool isSectionExpandedEnableTileAndCluster { get { return m_AnimBools[1]; } }

5
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedFrameSettings.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Experimental.Rendering.HDPipeline;
class SerializedFrameSettings
public class SerializedFrameSettings
{
public SerializedProperty root;

public SerializedProperty enableShadowMask;
public SerializedLightLoopSettings lightLoopSettings;
public SerializedFrameSettings(SerializedProperty root)
{

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedLightLoopSettings.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Experimental.Rendering.HDPipeline;
class SerializedLightLoopSettings
public class SerializedLightLoopSettings
{
public SerializedProperty root;

27
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/PlanarReflectionProbe.cs


[SerializeField]
InfluenceVolume m_InfluenceVolume;
[SerializeField]
Vector3 m_CenterOffset;
Vector3 m_CaptureLocalPosition;
[SerializeField]
[Range(0, 1)]
float m_Dimmer = 1;

ReflectionProbeRefreshMode m_RefreshMode = ReflectionProbeRefreshMode.OnAwake;
[SerializeField]
Texture m_CustomTexture;
[SerializeField]
FrameSettings m_FrameSettings;
public ProxyVolumeComponent proxyVolumeReference { get { return m_ProxyVolumeReference; } }
public InfluenceVolume influenceVolume { get { return m_InfluenceVolume; } }

public Vector3 centerOffset { get { return m_CenterOffset; } }
public Vector3 captureLocalPosition { get { return m_CaptureLocalPosition; } set { m_CaptureLocalPosition = value; } }
public Vector3 capturePosition { get { return transform.position; } }
public Vector3 influencePosition { get { return transform.TransformPoint(m_CenterOffset); } }
public Vector3 capturePosition
{
get { return transform.TransformPoint(m_CaptureLocalPosition); }
set { m_CaptureLocalPosition = transform.InverseTransformPoint(value); }
}
public Vector3 influencePosition { get { return transform.position; } }
public FrameSettings frameSettings { get { return m_FrameSettings; } }
#region Proxy Properties
public Vector3 proxyRight

public bool infiniteProjection { get { return m_ProxyVolumeReference != null && m_ProxyVolumeReference.projectionVolume.infiniteProjection; } }
#endregion
public void SetBakeDirty()
{
if (enabled)
ReflectionSystem.RequestRender(this);
}
void OnEnable()
{
ReflectionSystem.RegisterProbe(this);

void OnValidate()
{
ReflectionSystem.SetProbeBoundsDirty(this);
if (enabled)
{
ReflectionSystem.UnregisterProbe(this);
ReflectionSystem.RegisterProbe(this);
}
}
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ProbeWrapper.cs


public override Vector3 influenceForward { get { return probe.influenceForward; } }
public override Vector3 capturePosition { get { return probe.capturePosition; } }
public override Texture texture { get { return probe.texture; } }
public override Vector3 centerOffsetCaptureSpace { get { return probe.centerOffset; } }
public override Vector3 centerOffsetCaptureSpace { get { return probe.captureLocalPosition; } }
public override EnvShapeType influenceShapeType { get { return ConvertShape(probe.influenceVolume.shapeType); } }
public override float dimmer { get { return probe.dimmer; } }
public override Vector3 influenceExtents

30
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ReflectionSystem.cs


using UnityEngine.Experimental.Rendering.HDPipeline.Internal;
using UnityEngine.Experimental.Rendering.HDPipeline.Internal;
using UnityEngine.Rendering.PostProcessing;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{

static Camera s_RenderCamera = null;
static HDAdditionalCameraData s_RenderCameraData;
public static void SetParameters(ReflectionSystemParameters parameters)
{

s_Instance.Cull(camera, results);
}
public static void SetProbeBoundsDirty(PlanarReflectionProbe planarProbe)
public static void RequestRender(PlanarReflectionProbe probe)
{
s_Instance.RequestRender(probe);
}
public static void Render(PlanarReflectionProbe probe, RenderTexture target)
s_Instance.SetProbeBoundsDirty(planarProbe);
var renderCamera = GetRenderCamera(probe);
renderCamera.targetTexture = target;
}
static Camera GetRenderCamera(PlanarReflectionProbe probe)
{
if (s_RenderCamera == null)
{
s_RenderCamera = new GameObject("Probe Render Camera").
AddComponent<Camera>();
s_RenderCameraData = s_RenderCamera.gameObject.AddComponent<HDAdditionalCameraData>();
}
probe.frameSettings.CopyTo(s_RenderCameraData.GetFrameSettings());
return s_RenderCamera;
}
}
}

52
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ReflectionSystemInternal.cs


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

HashSet<PlanarReflectionProbe> m_DirtyPlanarReflectionProbeBounds;
HashSet<PlanarReflectionProbe> m_PlanarReflectionProbe_DirtyBounds;
HashSet<PlanarReflectionProbe> m_PlanarReflectionProbe_RequestRender;
HashSet<PlanarReflectionProbe> m_PlanarReflectionProbe_RealtimeUpdate;
Dictionary<PlanarReflectionProbe, BoundingSphere> m_PlanarReflectionProbeBounds;
PlanarReflectionProbe[] m_PlanarReflectionProbesArray;

{
m_PlanarReflectionProbes = new HashSet<PlanarReflectionProbe>();
m_DirtyPlanarReflectionProbeBounds = new HashSet<PlanarReflectionProbe>();
m_PlanarReflectionProbe_DirtyBounds = new HashSet<PlanarReflectionProbe>();
m_PlanarReflectionProbe_RequestRender = new HashSet<PlanarReflectionProbe>();
m_PlanarReflectionProbe_RealtimeUpdate = new HashSet<PlanarReflectionProbe>();
m_DirtyPlanarReflectionProbeBounds.UnionWith(m_PlanarReflectionProbes);
m_PlanarReflectionProbe_DirtyBounds.UnionWith(m_PlanarReflectionProbes);
}
}

m_DirtyPlanarReflectionProbeBounds.Add(planarProbe);
SetProbeBoundsDirty(planarProbe);
if (planarProbe.mode == ReflectionProbeMode.Realtime)
{
switch (planarProbe.refreshMode)
{
case ReflectionProbeRefreshMode.OnAwake:
m_PlanarReflectionProbe_RequestRender.Add(planarProbe);
break;
case ReflectionProbeRefreshMode.EveryFrame:
m_PlanarReflectionProbe_RealtimeUpdate.Add(planarProbe);
break;
}
}
m_DirtyPlanarReflectionProbeBounds.Remove(planarProbe);
m_PlanarReflectionProbe_DirtyBounds.Remove(planarProbe);
m_PlanarReflectionProbe_RequestRender.Remove(planarProbe);
m_PlanarReflectionProbe_RealtimeUpdate.Remove(planarProbe);
}
public void Cull(Camera camera, ReflectionProbeCullResults results)

cullingGroup.Dispose();
}
public void SetProbeBoundsDirty(PlanarReflectionProbe planarProbe)
public void RenderRequestedProbes()
m_DirtyPlanarReflectionProbeBounds.Add(planarProbe);
}
void SetProbeBoundsDirty(PlanarReflectionProbe planarProbe)
{
m_PlanarReflectionProbe_DirtyBounds.Add(planarProbe);
if (m_DirtyPlanarReflectionProbeBounds.Count > 0)
if (m_PlanarReflectionProbe_DirtyBounds.Count > 0)
m_DirtyPlanarReflectionProbeBounds.IntersectWith(m_PlanarReflectionProbes);
foreach (var planarReflectionProbe in m_DirtyPlanarReflectionProbeBounds)
m_PlanarReflectionProbe_DirtyBounds.IntersectWith(m_PlanarReflectionProbes);
foreach (var planarReflectionProbe in m_PlanarReflectionProbe_DirtyBounds)
UpdatePlanarReflectionProbeBounds(planarReflectionProbe);
m_PlanarReflectionProbeBounds.Values.CopyTo(m_PlanarReflectionProbeBoundsArray, 0);

void UpdatePlanarReflectionProbeBounds(PlanarReflectionProbe planarReflectionProbe)
{
m_PlanarReflectionProbeBounds[planarReflectionProbe] = planarReflectionProbe.boundingSphere;
}
public void RequestRender(PlanarReflectionProbe probe)
{
m_PlanarReflectionProbe_RequestRender.Add(probe);
}
}
}
正在加载...
取消
保存