浏览代码

[PlanarReflection] Updated UI

/main
Frédéric Vauchelles 7 年前
当前提交
8b418188
共有 34 个文件被更改,包括 576 次插入323 次删除
  1. 100
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/EditorReflectionSystem.cs
  2. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeEditor.cs
  3. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Handles.cs
  4. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.cs
  5. 32
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedPlanarReflectionProbe.cs
  6. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeComponentUI.cs.meta
  7. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeEditor.cs.meta
  8. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeUI.cs.meta
  9. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolume.cs.meta
  10. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolumeComponent.cs.meta
  11. 10
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/PlanarReflectionProbe.cs
  12. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ReflectionSystem.cs
  13. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolumeComponent.cs
  14. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolume.cs
  15. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolume.cs.meta
  16. 56
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeComponentUI.cs
  17. 48
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeEditor.cs
  18. 184
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeUI.cs
  19. 30
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolume.cs
  20. 28
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolumeComponent.cs
  21. 67
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ReflectionSystemSceneDictionary.cs
  22. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ReflectionSystemSceneDictionary.cs.meta
  23. 144
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeUI.cs
  24. 30
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProjectionVolume.cs
  25. 48
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeComponentUI.cs
  26. 48
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeEditor.cs
  27. 28
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProjectionVolumeComponent.cs
  28. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeComponentUI.cs.meta
  29. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeEditor.cs.meta
  30. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeUI.cs.meta
  31. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolume.cs.meta
  32. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolumeComponent.cs.meta
  33. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolume.cs
  34. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolume.cs.meta

100
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/EditorReflectionSystem.cs


using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;

public static class EditorReflectionSystem
{
static int _Cubemap = Shader.PropertyToID("_Cubemap");
const HideFlags k_ReflectionSystemDictionaryHideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector | HideFlags.DontSaveInBuild;
public static bool IsCollidingWithOtherProbes(string targetPath, ReflectionProbe targetProbe, out ReflectionProbe collidingProbe)
{

public static bool BakeReflectionProbeSnapshot(PlanarReflectionProbe probe)
{
throw new NotImplementedException();
var rt = ReflectionSystem.NewRenderTarget(probe);
var bakedTexture = probe.bakedTexture as Texture2D;
if (bakedTexture == null)
{
bakedTexture = new Texture2D(rt.width, rt.height, TextureFormat.RGBAHalf, true, false);
probe.bakedTexture = bakedTexture;
var bakedAssetPath = GetBakePath(probe);
AssetDatabase.CreateAsset(bakedTexture, bakedAssetPath);
}
ReflectionSystem.Render(probe, rt);
var art = RenderTexture.active;
RenderTexture.active = rt;
bakedTexture.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0, false);
RenderTexture.active = art;
var assetPath = AssetDatabase.GetAssetPath(bakedTexture);
var bytes = bakedTexture.EncodeToEXR();
File.WriteAllBytes(assetPath, bytes);
return true;
}
static MethodInfo k_Lightmapping_BakeAllReflectionProbesSnapshots = typeof(UnityEditor.Lightmapping).GetMethod("BakeAllReflectionProbesSnapshots", BindingFlags.Static | BindingFlags.NonPublic);

if (string.IsNullOrEmpty(path) || Path.GetExtension(path) != "." + targetExtension)
{
// We use the path of the active scene as the target path
var targetPath = SceneManager.GetActiveScene().path;
targetPath = Path.Combine(Path.GetDirectoryName(targetPath), Path.GetFileNameWithoutExtension(targetPath));
if (string.IsNullOrEmpty(targetPath))
targetPath = "Assets";
else if (Directory.Exists(targetPath) == false)
var targetPath = GetSceneBakeDirectoryPath(SceneManager.GetActiveScene());
if (Directory.Exists(targetPath) == false)
Directory.CreateDirectory(targetPath);
var fileName = probeName + (hdr ? "-reflectionHDR" : "-reflection") + "." + targetExtension;

return false;
}
return true;
}
static string GetBakePath(PlanarReflectionProbe probe)
{
var id = GetProbePersistentID(probe);
if (id == -1)
return string.Empty;
var scene = probe.gameObject.scene;
var targetPath = GetSceneBakeDirectoryPath(scene);
if (Directory.Exists(targetPath) == false)
Directory.CreateDirectory(targetPath);
var fileName = probe.name + "-reflectionHDR.exr";
return Path.GetFileNameWithoutExtension(AssetDatabase.GenerateUniqueAssetPath(Path.Combine(targetPath, fileName)));
}
static string GetSceneBakeDirectoryPath(Scene scene)
{
var targetPath = scene.path;
targetPath = Path.Combine(Path.GetDirectoryName(targetPath), Path.GetFileNameWithoutExtension(targetPath));
if (string.IsNullOrEmpty(targetPath))
targetPath = "Assets";
else if (Directory.Exists(targetPath) == false)
Directory.CreateDirectory(targetPath);
return targetPath;
}
static int GetProbePersistentID(PlanarReflectionProbe probe)
{
var scene = probe.gameObject.scene;
if (!scene.IsValid())
return -1;
var reflectionDictionary = GetReflectionDictionaryFor(scene);
return reflectionDictionary.GetIdFor(probe);
}
static ReflectionSystemSceneDictionary GetReflectionDictionaryFor(Scene scene)
{
ReflectionSystemSceneDictionary result = null;
var roots = new List<GameObject>();
scene.GetRootGameObjects(roots);
for (var i = 0; i < roots.Count; i++)
{
result = roots[i].GetComponent<ReflectionSystemSceneDictionary>();
if (result != null)
break;
}
if (result == null)
{
result = EditorUtility.CreateGameObjectWithHideFlags(
"Reflection System Dictionary",
k_ReflectionSystemDictionaryHideFlags,
typeof(ReflectionSystemSceneDictionary))
.GetComponent<ReflectionSystemSceneDictionary>();
SceneManager.MoveGameObjectToScene(result.gameObject, scene);
result.gameObject.SetActive(false);
}
result.gameObject.hideFlags = k_ReflectionSystemDictionaryHideFlags;
return result;
}
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeEditor.cs


using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;

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


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

break;
}
}
if (d.proxyVolumeReference != null)
ProxyVolumeComponentUI.DrawHandles_EditNone(s.proxyVolume, d.proxyVolumeReference);
}
[DrawGizmo(GizmoType.Selected)]

InfluenceVolumeUI.DrawGizmos_EditNone(s.influenceVolume, d.influenceVolume, mat);
break;
}
if (d.proxyVolumeReference != null)
ProxyVolumeComponentUI.DrawGizmos_EditNone(s.proxyVolume, d.proxyVolumeReference);
}
}
}

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


using System;
using System;
using UnityEditor.AnimatedValues;
using UnityEngine.Events;
using UnityEngine.Rendering;

public InfluenceVolumeUI influenceVolume = new InfluenceVolumeUI();
public FrameSettingsUI frameSettings = new FrameSettingsUI();
public ProxyVolumeComponentUI proxyVolume = new ProxyVolumeComponentUI();
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)
{
proxyVolume.Reset(data.proxyVolume, 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;
proxyVolume.Update();
frameSettings.Update();
influenceVolume.Update();
base.Update();

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


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

public SerializedObject serializedObject;
public SerializedProperty proxyVolumeReference;
public SerializedProxyVolumeComponent proxyVolume;
public SerializedInfluenceVolume influenceVolume;
public SerializedProperty captureLocalPosition;

customTexture = serializedObject.Find((PlanarReflectionProbe p) => p.customTexture);
frameSettings = new SerializedFrameSettings(serializedObject.Find((PlanarReflectionProbe p) => p.frameSettings));
InstantiateProxyVolume(serializedObject);
}
void InstantiateProxyVolume(SerializedObject serializedObject)
{
var objs = new List<Object>();
for (var i = 0; i < serializedObject.targetObjects.Length; i++)
objs.Add(((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolumeReference);
proxyVolume = new SerializedProxyVolumeComponent(new SerializedObject(objs.ToArray()));
var updateProxyVolume = serializedObject.targetObjects.Length != proxyVolume.serializedObject.targetObjects.Length;
if (!updateProxyVolume)
{
var proxyVolumeTargets = proxyVolume.serializedObject.targetObjects;
for (var i = 0; i < serializedObject.targetObjects.Length; i++)
{
if (proxyVolumeTargets[i] != ((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolumeReference)
{
updateProxyVolume = true;
break;
}
}
}
if (updateProxyVolume)
InstantiateProxyVolume(serializedObject);
proxyVolume.Apply();
}
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeComponentUI.cs.meta


fileFormatVersion: 2
guid: 4db48f42cf8b74e4b973195bf39276a0
guid: 4b6bbac268fd0dc4d9d733d02e4278e3
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeEditor.cs.meta


fileFormatVersion: 2
guid: 355b47aafeafb8443bf3760898b49f20
guid: 24ca572dc137d34439ad95a2c8336336
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeUI.cs.meta


fileFormatVersion: 2
guid: 93d6acd797ec99740a1e2c37a27277b7
guid: 6fa8333659902954aa87fcfcc6fde7eb
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolume.cs.meta


fileFormatVersion: 2
guid: 824c577d61e129b4d9d203d1d6cfb0e8
guid: 2903adf6630c9534f894c6df5a7937f2
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolumeComponent.cs.meta


fileFormatVersion: 2
guid: 2b1d0bff72b8f41449ffffdec532090b
guid: 16786f9d437cbcc4db44cce8cb8e5714
MonoImporter:
externalObjects: {}
serializedVersion: 2

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


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

}
public Vector3 influencePosition { get { return transform.position; } }
public Texture customTexture { get { return m_CustomTexture; } }
public Texture bakedTexture { get { return m_BakedTexture; } }
public Texture bakedTexture { get { return m_BakedTexture; } set { m_BakedTexture = value; }}
public RenderTexture realtimeTexture { get { return m_RealtimeTexture; } internal set { m_RealtimeTexture = value; } }
public ReflectionProbeRefreshMode refreshMode { get { return m_RefreshMode; } }
public FrameSettings frameSettings { get { return m_FrameSettings; } }

get
{
return m_ProxyVolumeReference != null
? m_ProxyVolumeReference.projectionVolume.shapeType
? m_ProxyVolumeReference.proxyVolume.shapeType
: influenceVolume.shapeType;
}
}

{
return m_ProxyVolumeReference != null
? m_ProxyVolumeReference.projectionVolume.boxSize
? m_ProxyVolumeReference.proxyVolume.boxSize
public bool infiniteProjection { get { return m_ProxyVolumeReference != null && m_ProxyVolumeReference.projectionVolume.infiniteProjection; } }
public bool infiniteProjection { get { return m_ProxyVolumeReference != null && m_ProxyVolumeReference.proxyVolume.infiniteProjection; } }
#endregion
public void RequestRealtimeRender()

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


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

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolumeComponent.cs


public class ProxyVolumeComponent : MonoBehaviour
{
[SerializeField]
ProjectionVolume m_ProjectionVolume = new ProjectionVolume();
ProxyVolume m_ProxyVolume = new ProxyVolume();
public ProjectionVolume projectionVolume { get { return m_ProjectionVolume; } }
public ProxyVolume proxyVolume { get { return m_ProxyVolume; } }
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolume.cs


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
[Serializable]
public class ProjectionVolume
public class ProxyVolume
{
[SerializeField]
ShapeType m_ShapeType;

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolume.cs.meta


fileFormatVersion: 2
guid: 79a580bb2ae531a489f5c37a4328f44e
guid: 8a74f3556a5711b46ad9e1ba585e0b3f
MonoImporter:
externalObjects: {}
serializedVersion: 2

56
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeComponentUI.cs


using UnityEngine.Events;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using CED = CoreEditorDrawer<ProxyVolumeComponentUI, SerializedProxyVolumeComponent>;
class ProxyVolumeComponentUI : BaseUI<SerializedProxyVolumeComponent>
{
public static readonly CED.IDrawer Inspector;
static ProxyVolumeComponentUI()
{
Inspector = CED.Select(
(s, d, o) => s.proxyVolume,
(s, d, o) => d.proxyVolume,
ProxyVolumeUI.SectionShape
);
}
public ProxyVolumeUI proxyVolume = new ProxyVolumeUI();
public ProxyVolumeComponentUI()
: base(0)
{
}
public override void Reset(SerializedProxyVolumeComponent data, UnityAction repaint)
{
proxyVolume.Reset(data.proxyVolume, repaint);
base.Reset(data, repaint);
}
public override void Update()
{
proxyVolume.Update();
base.Update();
}
public static void DrawHandles_EditBase(ProxyVolumeComponentUI ui, ProxyVolumeComponent target)
{
ProxyVolumeUI.DrawHandles_EditBase(target.transform, target.proxyVolume, ui.proxyVolume, target);
}
public static void DrawHandles_EditNone(ProxyVolumeComponentUI ui, ProxyVolumeComponent target)
{
ProxyVolumeUI.DrawHandles_EditNone(target.transform, target.proxyVolume, ui.proxyVolume, target);
}
public static void DrawGizmos_EditNone(ProxyVolumeComponentUI ui, ProxyVolumeComponent target)
{
ProxyVolumeUI.DrawGizmos_EditNone(target.transform, target.proxyVolume, ui.proxyVolume, target);
}
}
}

48
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeEditor.cs


using System.Linq;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
[CustomEditor(typeof(ProxyVolumeComponent))]
[CanEditMultipleObjects]
class ProxyVolumeEditor : Editor
{
ProxyVolumeComponent[] m_TypedTargets;
SerializedProxyVolumeComponent m_SerializedData;
ProxyVolumeComponentUI m_UIState = new ProxyVolumeComponentUI();
ProxyVolumeComponentUI[] m_UIHandlerState;
void OnEnable()
{
m_TypedTargets = targets.Cast<ProxyVolumeComponent>().ToArray();
m_SerializedData = new SerializedProxyVolumeComponent(serializedObject);
m_UIState.Reset(m_SerializedData, Repaint);
m_UIHandlerState = new ProxyVolumeComponentUI[m_TypedTargets.Length];
for (var i = 0; i < m_UIHandlerState.Length; i++)
m_UIHandlerState[i] = new ProxyVolumeComponentUI();
}
public override void OnInspectorGUI()
{
var s = m_UIState;
var d = m_SerializedData;
var o = this;
d.Update();
s.Update();
ProxyVolumeComponentUI.Inspector.Draw(s, d, o);
d.Apply();
}
void OnSceneGUI()
{
for (var i = 0; i < m_TypedTargets.Length; i++)
ProxyVolumeComponentUI.DrawHandles_EditBase(m_UIHandlerState[i], m_TypedTargets[i]);
}
}
}

184
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeUI.cs


using System;
using UnityEditor.AnimatedValues;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using Object = UnityEngine.Object;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<ProxyVolumeUI, SerializedProxyVolume>;
class ProxyVolumeUI : BaseUI<SerializedProxyVolume>
{
internal static Color k_GizmoThemeColorProjection = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static Color k_GizmoThemeColorProjectionFace = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static Color k_GizmoThemeColorDisabled = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
internal static Color k_GizmoThemeColorDisabledFace = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
static readonly int k_ShapeCount = Enum.GetValues(typeof(ShapeType)).Length;
public static readonly CED.IDrawer SectionShape;
public static readonly CED.IDrawer SectionShapeBox = CED.Action(Drawer_SectionShapeBox);
public static readonly CED.IDrawer SectionShapeSphere = CED.Action(Drawer_SectionShapeSphere);
static ProxyVolumeUI()
{
SectionShape = CED.Group(
CED.Action(Drawer_FieldShapeType),
CED.FadeGroup(
(s, d, o, i) => s.IsSectionExpanded_Shape((ShapeType)i),
true,
SectionShapeBox,
SectionShapeSphere
)
);
}
public BoxBoundsHandle boxProjectionHandle = new BoxBoundsHandle();
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle();
public ProxyVolumeUI()
: base(k_ShapeCount)
{
}
public override void Update()
{
base.Update();
SetIsSectionExpanded_Shape((ShapeType)data.shapeType.intValue);
}
void SetIsSectionExpanded_Shape(ShapeType shape)
{
for (var i = 0; i < k_ShapeCount; i++)
m_AnimBools[i].target = (int)shape == i;
}
public AnimBool IsSectionExpanded_Shape(ShapeType shapeType)
{
return m_AnimBools[(int)shapeType];
}
static void Drawer_FieldShapeType(ProxyVolumeUI s, SerializedProxyVolume d, Editor o)
{
EditorGUILayout.PropertyField(d.shapeType, _.GetContent("Shape Type"));
}
static void Drawer_SectionShapeBox(ProxyVolumeUI s, SerializedProxyVolume d, Editor o)
{
EditorGUILayout.PropertyField(d.boxSize, _.GetContent("Box Size"));
EditorGUILayout.PropertyField(d.boxOffset, _.GetContent("Box Offset"));
EditorGUILayout.PropertyField(d.boxInfiniteProjection, _.GetContent("Infinite Projection"));
}
static void Drawer_SectionShapeSphere(ProxyVolumeUI s, SerializedProxyVolume d, Editor o)
{
EditorGUILayout.PropertyField(d.sphereRadius, _.GetContent("Sphere Radius"));
EditorGUILayout.PropertyField(d.sphereOffset, _.GetContent("Sphere Offset"));
EditorGUILayout.PropertyField(d.sphereInfiniteProjection, _.GetContent("Infinite Projection"));
}
public static void DrawHandles_EditBase(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI ui, Object sourceAsset)
{
switch (proxyVolume.shapeType)
{
case ShapeType.Box:
Handles_EditBase_Box(transform, proxyVolume, ui, sourceAsset);
break;
case ShapeType.Sphere:
Handles_EditBase_Sphere(transform, proxyVolume, ui, sourceAsset);
break;
}
}
public static void DrawHandles_EditNone(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI ui, Object sourceAsset)
{
}
static void Handles_EditBase_Sphere(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI s, Object sourceAsset)
{
s.sphereProjectionHandle.center = proxyVolume.sphereOffset;
s.sphereProjectionHandle.radius = proxyVolume.sphereRadius;
var mat = Handles.matrix;
Handles.matrix = transform.localToWorldMatrix;
Handles.color = k_GizmoThemeColorProjection;
EditorGUI.BeginChangeCheck();
s.sphereProjectionHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sourceAsset, "Modified Projection Volume");
proxyVolume.sphereOffset = s.sphereProjectionHandle.center;
proxyVolume.sphereRadius = s.sphereProjectionHandle.radius;
EditorUtility.SetDirty(sourceAsset);
}
Handles.matrix = mat;
}
static void Handles_EditBase_Box(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI s, Object sourceAsset)
{
s.boxProjectionHandle.center = proxyVolume.boxOffset;
s.boxProjectionHandle.size = proxyVolume.boxSize;
var mat = Handles.matrix;
Handles.matrix = transform.localToWorldMatrix;
Handles.color = k_GizmoThemeColorProjection;
EditorGUI.BeginChangeCheck();
s.boxProjectionHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sourceAsset, "Modified Projection Volume AABB");
proxyVolume.boxOffset = s.boxProjectionHandle.center;
proxyVolume.boxSize = s.boxProjectionHandle.size;
EditorUtility.SetDirty(sourceAsset);
}
Handles.matrix = mat;
}
public static void DrawGizmos_EditNone(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI ui, Object sourceAsset)
{
switch (proxyVolume.shapeType)
{
case ShapeType.Box:
Gizmos_EditNone_Box(transform, proxyVolume, ui, sourceAsset);
break;
case ShapeType.Sphere:
Gizmos_EditNone_Sphere(transform, proxyVolume, ui, sourceAsset);
break;
}
}
static void Gizmos_EditNone_Sphere(Transform t, ProxyVolume d, ProxyVolumeUI s, Object o)
{
var mat = Gizmos.matrix;
Gizmos.matrix = t.localToWorldMatrix;
Gizmos.color = k_GizmoThemeColorProjection;
Gizmos.DrawWireSphere(d.sphereOffset, d.sphereRadius);
Gizmos.matrix = mat;
}
static void Gizmos_EditNone_Box(Transform t, ProxyVolume d, ProxyVolumeUI s, Object o)
{
var mat = Gizmos.matrix;
Gizmos.matrix = t.localToWorldMatrix;
Gizmos.color = k_GizmoThemeColorProjection;
Gizmos.DrawWireCube(d.boxOffset, d.boxSize);
Gizmos.matrix = mat;
}
}
}

30
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolume.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
public class SerializedProxyVolume
{
public SerializedProperty root;
public SerializedProperty shapeType;
public SerializedProperty boxSize;
public SerializedProperty boxOffset;
public SerializedProperty boxInfiniteProjection;
public SerializedProperty sphereRadius;
public SerializedProperty sphereOffset;
public SerializedProperty sphereInfiniteProjection;
public SerializedProxyVolume(SerializedProperty root)
{
this.root = root;
shapeType = root.Find((ProxyVolume p) => p.shapeType);
boxSize = root.Find((ProxyVolume p) => p.boxSize);
boxOffset = root.Find((ProxyVolume p) => p.boxOffset);
boxInfiniteProjection = root.Find((ProxyVolume p) => p.boxInfiniteProjection);
sphereRadius = root.Find((ProxyVolume p) => p.sphereRadius);
sphereOffset = root.Find((ProxyVolume p) => p.sphereOffset);
sphereInfiniteProjection = root.Find((ProxyVolume p) => p.sphereInfiniteProjection);
}
}
}

28
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolumeComponent.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
public class SerializedProxyVolumeComponent
{
public SerializedObject serializedObject;
public SerializedProxyVolume proxyVolume;
public SerializedProxyVolumeComponent(SerializedObject serializedObject)
{
this.serializedObject = serializedObject;
proxyVolume = new SerializedProxyVolume(serializedObject.Find((ProxyVolumeComponent c) => c.proxyVolume));
}
public void Update()
{
serializedObject.Update();
}
public void Apply()
{
serializedObject.ApplyModifiedProperties();
}
}
}

67
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ReflectionSystemSceneDictionary.cs


using System;
using System.Collections.Generic;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class ReflectionSystemSceneDictionary : MonoBehaviour, ISerializationCallbackReceiver
{
[Serializable]
class ObjectIDPair
{
public int Key;
public Object Value;
}
[SerializeField]
List<ObjectIDPair> m_ObjectList = new List<ObjectIDPair>();
Dictionary<Object, int> m_ObjectIndex = new Dictionary<Object, int>();
Dictionary<int, Object> m_IDIndex = new Dictionary<int, Object>();
public int GetIdFor(PlanarReflectionProbe probe)
{
if (m_ObjectIndex.ContainsKey(probe))
return m_ObjectIndex[probe];
var id = FindNextId();
m_ObjectList.Add(new ObjectIDPair
{
Key = id,
Value = probe
});
m_ObjectIndex[probe] = id;
m_IDIndex[id] = probe;
return id;
}
public void OnBeforeSerialize()
{
for (var i = m_ObjectList.Count - 1; i >= 0; --i)
{
if (m_ObjectList[i].Value == null)
m_ObjectList.RemoveAt(i);
}
}
public void OnAfterDeserialize()
{
for (int i = 0; i < m_ObjectList.Count; i++)
{
if (m_IDIndex.ContainsKey(m_ObjectList[i].Key))
Debug.LogErrorFormat(this, "ID {0} is a duplicated in ReflectionSystemSceneDictionary ({1}) for {2}", m_ObjectList[i].Key, this, m_ObjectList[i].Value);
m_ObjectIndex[m_ObjectList[i].Value] = m_ObjectList[i].Key;
m_IDIndex[m_ObjectList[i].Key] = m_ObjectList[i].Value;
}
}
int FindNextId()
{
var id = 0;
while (m_IDIndex.ContainsKey(id)) ++id;
return id;
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/ReflectionSystemSceneDictionary.cs.meta


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

144
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeUI.cs


using System;
using UnityEditor.AnimatedValues;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using Object = UnityEngine.Object;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<ProjectionVolumeUI, SerializedProjectionVolume>;
class ProjectionVolumeUI : BaseUI<SerializedProjectionVolume>
{
internal static Color k_GizmoThemeColorProjection = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static Color k_GizmoThemeColorProjectionFace = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static Color k_GizmoThemeColorDisabled = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
internal static Color k_GizmoThemeColorDisabledFace = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
static readonly int k_ShapeCount = Enum.GetValues(typeof(ShapeType)).Length;
public static readonly CED.IDrawer SectionShape;
public static readonly CED.IDrawer SectionShapeBox = CED.Action(Drawer_SectionShapeBox);
public static readonly CED.IDrawer SectionShapeSphere = CED.Action(Drawer_SectionShapeSphere);
static ProjectionVolumeUI()
{
SectionShape = CED.Group(
CED.Action(Drawer_FieldShapeType),
CED.FadeGroup(
(s, d, o, i) => s.IsSectionExpanded_Shape((ShapeType)i),
true,
SectionShapeBox,
SectionShapeSphere
)
);
}
public BoxBoundsHandle boxProjectionHandle = new BoxBoundsHandle();
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle();
public ProjectionVolumeUI()
: base(k_ShapeCount)
{
}
public override void Update()
{
base.Update();
SetIsSectionExpanded_Shape((ShapeType)data.shapeType.intValue);
}
void SetIsSectionExpanded_Shape(ShapeType shape)
{
for (var i = 0; i < k_ShapeCount; i++)
m_AnimBools[i].target = (int)shape == i;
}
public AnimBool IsSectionExpanded_Shape(ShapeType shapeType)
{
return m_AnimBools[(int)shapeType];
}
static void Drawer_FieldShapeType(ProjectionVolumeUI s, SerializedProjectionVolume d, Editor o)
{
EditorGUILayout.PropertyField(d.shapeType, _.GetContent("Shape Type"));
}
static void Drawer_SectionShapeBox(ProjectionVolumeUI s, SerializedProjectionVolume d, Editor o)
{
EditorGUILayout.PropertyField(d.boxSize, _.GetContent("Box Size"));
EditorGUILayout.PropertyField(d.boxOffset, _.GetContent("Box Offset"));
EditorGUILayout.PropertyField(d.boxInfiniteProjection, _.GetContent("Infinite Projection"));
}
static void Drawer_SectionShapeSphere(ProjectionVolumeUI s, SerializedProjectionVolume d, Editor o)
{
EditorGUILayout.PropertyField(d.sphereRadius, _.GetContent("Sphere Radius"));
EditorGUILayout.PropertyField(d.sphereOffset, _.GetContent("Sphere Offset"));
EditorGUILayout.PropertyField(d.sphereInfiniteProjection, _.GetContent("Infinite Projection"));
}
public static void DrawHandles(Transform transform, ProjectionVolume projectionVolume, ProjectionVolumeUI ui, Object sourceAsset)
{
switch (projectionVolume.shapeType)
{
case ShapeType.Box:
Handles_Box(transform, projectionVolume, ui, sourceAsset);
break;
case ShapeType.Sphere:
Handles_Sphere(transform, projectionVolume, ui, sourceAsset);
break;
}
}
static void Handles_Sphere(Transform transform, ProjectionVolume projectionVolume, ProjectionVolumeUI s, Object sourceAsset)
{
s.sphereProjectionHandle.center = projectionVolume.sphereOffset;
s.sphereProjectionHandle.radius = projectionVolume.sphereRadius;
var mat = Handles.matrix;
Handles.matrix = transform.localToWorldMatrix;
Handles.color = k_GizmoThemeColorProjection;
EditorGUI.BeginChangeCheck();
s.sphereProjectionHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sourceAsset, "Modified Projection Volume");
projectionVolume.sphereOffset = s.sphereProjectionHandle.center;
projectionVolume.sphereRadius = s.sphereProjectionHandle.radius;
EditorUtility.SetDirty(sourceAsset);
}
Handles.matrix = mat;
}
static void Handles_Box(Transform transform, ProjectionVolume projectionVolume, ProjectionVolumeUI s, Object sourceAsset)
{
s.boxProjectionHandle.center = projectionVolume.boxOffset;
s.boxProjectionHandle.size = projectionVolume.boxSize;
var mat = Handles.matrix;
Handles.matrix = transform.localToWorldMatrix;
Handles.color = k_GizmoThemeColorProjection;
EditorGUI.BeginChangeCheck();
s.boxProjectionHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sourceAsset, "Modified Projection Volume AABB");
projectionVolume.boxOffset = s.boxProjectionHandle.center;
projectionVolume.boxSize = s.boxProjectionHandle.size;
EditorUtility.SetDirty(sourceAsset);
}
Handles.matrix = mat;
}
}
}

30
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProjectionVolume.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
class SerializedProjectionVolume
{
public SerializedProperty root;
public SerializedProperty shapeType;
public SerializedProperty boxSize;
public SerializedProperty boxOffset;
public SerializedProperty boxInfiniteProjection;
public SerializedProperty sphereRadius;
public SerializedProperty sphereOffset;
public SerializedProperty sphereInfiniteProjection;
public SerializedProjectionVolume(SerializedProperty root)
{
this.root = root;
shapeType = root.Find((ProjectionVolume p) => p.shapeType);
boxSize = root.Find((ProjectionVolume p) => p.boxSize);
boxOffset = root.Find((ProjectionVolume p) => p.boxOffset);
boxInfiniteProjection = root.Find((ProjectionVolume p) => p.boxInfiniteProjection);
sphereRadius = root.Find((ProjectionVolume p) => p.sphereRadius);
sphereOffset = root.Find((ProjectionVolume p) => p.sphereOffset);
sphereInfiniteProjection = root.Find((ProjectionVolume p) => p.sphereInfiniteProjection);
}
}
}

48
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeComponentUI.cs


using UnityEditor.Experimental.UIElements;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<ProjectionVolumeComponentUI, SerializedProjectionVolumeComponent>;
class ProjectionVolumeComponentUI : BaseUI<SerializedProjectionVolumeComponent>
{
public static readonly CED.IDrawer Inspector;
static ProjectionVolumeComponentUI()
{
Inspector = CED.Select(
(s, d, o) => s.projectionVolume,
(s, d, o) => d.projectionVolume,
ProjectionVolumeUI.SectionShape
);
}
public ProjectionVolumeUI projectionVolume = new ProjectionVolumeUI();
public ProjectionVolumeComponentUI()
: base(0)
{
}
public override void Reset(SerializedProjectionVolumeComponent data, UnityAction repaint)
{
projectionVolume.Reset(data.projectionVolume, repaint);
base.Reset(data, repaint);
}
public override void Update()
{
projectionVolume.Update();
base.Update();
}
public static void DrawHandles(ProxyVolumeComponent target, ProjectionVolumeComponentUI ui)
{
ProjectionVolumeUI.DrawHandles(target.transform, target.projectionVolume, ui.projectionVolume, target);
}
}
}

48
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeEditor.cs


using System.Linq;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
[CustomEditor(typeof(ProxyVolumeComponent))]
[CanEditMultipleObjects]
class ProjectionVolumeEditor : Editor
{
ProxyVolumeComponent[] m_TypedTargets;
SerializedProjectionVolumeComponent m_SerializedData;
ProjectionVolumeComponentUI m_UIState = new ProjectionVolumeComponentUI();
ProjectionVolumeComponentUI[] m_UIHandlerState;
void OnEnable()
{
m_TypedTargets = targets.Cast<ProxyVolumeComponent>().ToArray();
m_SerializedData = new SerializedProjectionVolumeComponent(serializedObject);
m_UIState.Reset(m_SerializedData, Repaint);
m_UIHandlerState = new ProjectionVolumeComponentUI[m_TypedTargets.Length];
for (var i = 0; i < m_UIHandlerState.Length; i++)
m_UIHandlerState[i] = new ProjectionVolumeComponentUI();
}
public override void OnInspectorGUI()
{
var s = m_UIState;
var d = m_SerializedData;
var o = this;
d.Update();
s.Update();
ProjectionVolumeComponentUI.Inspector.Draw(s, d, o);
d.Apply();
}
void OnSceneGUI()
{
for (var i = 0; i < m_TypedTargets.Length; i++)
ProjectionVolumeComponentUI.DrawHandles(m_TypedTargets[i], m_UIHandlerState[i]);
}
}
}

28
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProjectionVolumeComponent.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
class SerializedProjectionVolumeComponent
{
public SerializedObject serializedObject;
public SerializedProjectionVolume projectionVolume;
public SerializedProjectionVolumeComponent(SerializedObject serializedObject)
{
this.serializedObject = serializedObject;
projectionVolume = new SerializedProjectionVolume(serializedObject.Find((ProxyVolumeComponent c) => c.projectionVolume));
}
public void Update()
{
serializedObject.Update();
}
public void Apply()
{
serializedObject.ApplyModifiedProperties();
}
}
}

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeComponentUI.cs.meta → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeComponentUI.cs.meta

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeEditor.cs.meta → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeEditor.cs.meta

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeUI.cs.meta → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProxyVolumeUI.cs.meta

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProjectionVolume.cs.meta → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolume.cs.meta

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProjectionVolumeComponent.cs.meta → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedProxyVolumeComponent.cs.meta

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProjectionVolume.cs → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolume.cs

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProjectionVolume.cs.meta → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProxyVolume.cs.meta

正在加载...
取消
保存