浏览代码

[PlanarReflection] (wip) Added Projection Volume Editor

/main
Frédéric Vauchelles 7 年前
当前提交
bf8823a7
共有 5 个文件被更改,包括 89 次插入13 次删除
  1. 6
      SampleScenes/HDTest/PlanarReflectionTests.unity
  2. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeComponentUI.cs
  3. 13
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeEditor.cs
  4. 69
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/ProjectionVolumeUI.cs
  5. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProjectionVolume.cs

6
SampleScenes/HDTest/PlanarReflectionTests.unity


m_EditorClassIdentifier:
m_ProjectionVolume:
m_ShapeType: 0
m_BoxSize: {x: 0, y: 0, z: 0}
m_BoxOffset: {x: 0, y: 0, z: 0}
m_BoxSize: {x: 20, y: 10, z: 20}
m_BoxOffset: {x: 0, y: 5, z: 0}
m_SphereRadius: 0
m_SphereRadius: 12.3
m_SphereOffset: {x: 0, y: 0, z: 0}
m_SphereInfiniteProjection: 0
--- !u!1 &1662809620

6
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
{

{
projectionVolume.Update();
base.Update();
}
public static void DrawHandles(ProjectionVolumeComponent target, ProjectionVolumeComponentUI ui)
{
ProjectionVolumeUI.DrawHandles(target.transform, target.projectionVolume, ui.projectionVolume, target);
}
}
}

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


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

ProjectionVolumeComponent[] m_TypedTargets;
SerializedProjectionVolumeComponent m_SerializedData;
ProjectionVolumeComponentUI m_UIState = new ProjectionVolumeComponentUI();
ProjectionVolumeComponentUI[] m_UIHandlerState;
void OnEnable()
{

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()

void OnSceneGUI()
{
for (var i = 0; i < m_TypedTargets.Length; i++)
DoHandles(m_TypedTargets[i]);
}
static void DoHandles(ProjectionVolumeComponent target)
{
ProjectionVolumeComponentUI.DrawHandles(m_TypedTargets[i], m_UIHandlerState[i]);
}
}
}

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


using System;
using UnityEditor.AnimatedValues;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
using Object = UnityEngine.Object;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{

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 BoxBoundsHandle boxProjectionHandle = new BoxBoundsHandle();
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle();
public ProjectionVolumeUI()
: base(k_ShapeCount)

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;
}
}
}

8
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProjectionVolume.cs


public ShapeType shapeType { get { return m_ShapeType; } }
public Vector3 boxSize { get { return m_BoxSize; } }
public Vector3 boxOffset { get { return m_BoxOffset; } }
public Vector3 boxSize { get { return m_BoxSize; } set { m_BoxSize = value; } }
public Vector3 boxOffset { get { return m_BoxOffset; } set { m_BoxOffset = value; } }
public float sphereRadius { get { return m_SphereRadius; } }
public Vector3 sphereOffset { get { return m_SphereOffset; } }
public float sphereRadius { get { return m_SphereRadius; } set { m_SphereRadius = value; } }
public Vector3 sphereOffset { get { return m_SphereOffset; } set { m_SphereOffset = value; } }
public bool sphereInfiniteProjection { get { return m_SphereInfiniteProjection; } }
}
}
正在加载...
取消
保存