浏览代码

[PlanarReflection] Added editor

/main
Frédéric Vauchelles 7 年前
当前提交
9f1e2799
共有 16 个文件被更改,包括 696 次插入147 次删除
  1. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeUI.cs
  2. 29
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeEditor.cs
  3. 19
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.cs
  4. 122
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.cs
  5. 12
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedInfluenceVolume.cs
  6. 40
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/InfluenceVolume.cs
  7. 84
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Drawers.cs
  8. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Drawers.cs.meta
  9. 58
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Handles.cs
  10. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Handles.cs.meta
  11. 77
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.Drawers.cs
  12. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.Drawers.cs.meta
  13. 115
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.Gizmos.cs
  14. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.Gizmos.cs.meta
  15. 230
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.Handles.cs
  16. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.Handles.cs.meta

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


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

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


using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEditor.Experimental.Rendering.HDPipeline;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{

{
static Dictionary<PlanarReflectionProbe, PlanarReflectionProbeUI> s_StateMap = new Dictionary<PlanarReflectionProbe, PlanarReflectionProbeUI>();
public static bool TryGetUIStateFor(PlanarReflectionProbe p, out PlanarReflectionProbeUI r)
{
return s_StateMap.TryGetValue(p, out r);
}
SerializedPlanarReflectionProbe m_SerializedAsset;
PlanarReflectionProbeUI m_UIState = new PlanarReflectionProbeUI();
PlanarReflectionProbeUI[] m_UIHandleState;

m_TypedTargets[i] = (PlanarReflectionProbe)targets[i];
m_UIHandleState[i] = new PlanarReflectionProbeUI();
m_UIHandleState[i].Reset(m_SerializedAsset, Repaint);
s_StateMap[m_TypedTargets[i]] = m_UIHandleState[i];
void OnDisable()
{
for (var i = 0; i < m_TypedTargets.Length; i++)
s_StateMap.Remove(m_TypedTargets[i]);
}
public override void OnInspectorGUI()
{
var s = m_UIState;

PlanarReflectionProbeUI.Inspector.Draw(s, d, o);
d.Apply();
}
void OnSceneGUI()
{
for (var i = 0; i < m_TypedTargets.Length; i++)
PlanarReflectionProbeUI.DrawHandles(m_UIHandleState[i], m_TypedTargets[i], this);
}
}
}

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


namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<PlanarReflectionProbeUI, SerializedPlanarReflectionProbe>;
class PlanarReflectionProbeUI : BaseUI<SerializedPlanarReflectionProbe>
partial class PlanarReflectionProbeUI : BaseUI<SerializedPlanarReflectionProbe>
public static readonly CED.IDrawer Inspector = CED.Group(
CED.Action(Drawer_FieldProjectionVolumeReference),
CED.Select(
(s, d, o) => s.influenceVolume,
(s, d, o) => d.influenceVolume,
InfluenceVolumeUI.SectionShapeBox
)
);
public InfluenceVolumeUI influenceVolume = new InfluenceVolumeUI();
public PlanarReflectionProbeUI()

{
influenceVolume.Update();
base.Update();
}
static void Drawer_FieldProjectionVolumeReference(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.projectionVolumeReference, _.GetContent("Projection Volume Reference"));
}
}
}

122
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.cs


using System;
using UnityEditor.AnimatedValues;
using UnityEditor.IMGUI.Controls;
using Object = UnityEngine.Object;
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<InfluenceVolumeUI, SerializedInfluenceVolume>;
partial class InfluenceVolumeUI : BaseUI<SerializedInfluenceVolume>
{
internal static Color k_GizmoThemeColorBase = new Color(255f / 255f, 229f / 255f, 148f / 255f, 80f / 255f);
internal static Color k_GizmoThemeColorBaseFace = new Color(255f / 255f, 229f / 255f, 148f / 255f, 45f / 255f);
internal static Color k_GizmoThemeColorInfluence = new Color(83f / 255f, 255f / 255f, 95f / 255f, 75f / 255f);
internal static Color k_GizmoThemeColorInfluenceFace = new Color(83f / 255f, 255f / 255f, 95f / 255f, 17f / 255f);
internal static Color k_GizmoThemeColorInfluenceNormal = new Color(0f / 255f, 229f / 255f, 255f / 255f, 80f / 255f);
internal static Color k_GizmoThemeColorInfluenceNormalFace = new Color(0f / 255f, 229f / 255f, 255f / 255f, 36f / 255f);
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);
class InfluenceVolumeUI : BaseUI<SerializedInfluenceVolume>
{
public static readonly CED.IDrawer SectionShape;
public BoxBoundsHandle boxBaseHandle = new BoxBoundsHandle();
public BoxBoundsHandle boxInfluenceHandle = new BoxBoundsHandle();
public BoxBoundsHandle boxInfluenceNormalHandle = new BoxBoundsHandle();
public static readonly CED.IDrawer SectionShapeBox = CED.Action(Drawer_SectionShapeBox);
public static readonly CED.IDrawer SectionShapeSphere = CED.Action(Drawer_SectionShapeSphere);
static InfluenceVolumeUI()
{
SectionShape = CED.Group(
CED.Action(Drawer_FieldShapeType),
CED.FadeGroup(
(s, d, o, i) => s.IsSectionExpanded_Shape((ShapeType)i),
true,
SectionShapeBox,
SectionShapeSphere
)
);
}
public SphereBoundsHandle sphereBaseHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereInfluenceHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereInfluenceNormalHandle = new SphereBoundsHandle();
public InfluenceVolumeUI()
: base(k_ShapeCount)

public AnimBool IsSectionExpanded_Shape(ShapeType shapeType)
{
return m_AnimBools[(int)shapeType];
}
static void Drawer_FieldShapeType(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o)
{
EditorGUILayout.PropertyField(d.shapeType, _.GetContent("Shape Type"));
}
static void Drawer_SectionShapeBox(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o)
{
EditorGUILayout.PropertyField(d.boxBaseSize, _.GetContent("Box Size"));
EditorGUILayout.PropertyField(d.boxBaseOffset, _.GetContent("Box Offset"));
EditorGUILayout.PropertyField(d.boxInfluencePositiveFade, _.GetContent("Influence Fade (Positive)"));
EditorGUILayout.PropertyField(d.boxInfluenceNegativeFade, _.GetContent("Influence Fade (Negative)"));
EditorGUILayout.PropertyField(d.boxInfluenceNormalPositiveFade, _.GetContent("Influence Normal Fade (Positive)"));
EditorGUILayout.PropertyField(d.boxInfluenceNormalNegativeFade, _.GetContent("Influence Normal Fade (Negative)"));
}
static void Drawer_SectionShapeSphere(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o)
{
EditorGUILayout.PropertyField(d.sphereBaseRadius, _.GetContent("Radius"));
EditorGUILayout.PropertyField(d.sphereBaseOffset, _.GetContent("Offset"));
EditorGUILayout.PropertyField(d.sphereInfluenceRadius, _.GetContent("Influence Radius"));
EditorGUILayout.PropertyField(d.sphereInfluenceNormalRadius, _.GetContent("Influence Normal Radius"));
}
public static void DrawHandles(Transform transform, ProjectionVolume projectionVolume, InfluenceVolumeUI 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, InfluenceVolumeUI 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, InfluenceVolumeUI 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;
}
}
}

12
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedInfluenceVolume.cs


public SerializedProperty boxInfluenceNegativeFade;
public SerializedProperty boxInfluenceNormalPositiveFade;
public SerializedProperty boxInfluenceNormalNegativeFade;
public SerializedProperty boxPositiveFaceFade;
public SerializedProperty boxNegativeFaceFade;
public SerializedProperty sphereInfluenceRadius;
public SerializedProperty sphereInfluenceNormalRadius;
public SerializedProperty sphereInfluenceFade;
public SerializedProperty sphereInfluenceNormalFade;
public SerializedInfluenceVolume(SerializedProperty root)
{

boxInfluenceNegativeFade = root.Find((InfluenceVolume i) => i.boxInfluenceNegativeFade);
boxInfluenceNormalPositiveFade = root.Find((InfluenceVolume i) => i.boxInfluenceNormalPositiveFade);
boxInfluenceNormalNegativeFade = root.Find((InfluenceVolume i) => i.boxInfluenceNormalNegativeFade);
boxPositiveFaceFade = root.Find((InfluenceVolume i) => i.boxPositiveFaceFade);
boxNegativeFaceFade = root.Find((InfluenceVolume i) => i.boxNegativeFaceFade);
sphereInfluenceRadius = root.Find((InfluenceVolume i) => i.sphereInfluenceRadius);
sphereInfluenceNormalRadius = root.Find((InfluenceVolume i) => i.sphereInfluenceNormalRadius);
sphereInfluenceFade = root.Find((InfluenceVolume i) => i.sphereInfluenceFade);
sphereInfluenceNormalFade = root.Find((InfluenceVolume i) => i.sphereInfluenceNormalFade);
}
}
}

40
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/InfluenceVolume.cs


Vector3 m_BoxInfluenceNormalPositiveFade;
[SerializeField]
Vector3 m_BoxInfluenceNormalNegativeFade;
[SerializeField]
Vector3 m_BoxPositiveFaceFade;
[SerializeField]
Vector3 m_BoxNegativeFaceFade;
// Sphere
[SerializeField]

[SerializeField]
float m_SphereInfluenceRadius = 1;
float m_SphereInfluenceFade;
float m_SphereInfluenceNormalRadius = 1;
float m_SphereInfluenceNormalFade;
public Vector3 boxBaseSize { get { return m_BoxBaseSize; } }
public Vector3 boxBaseOffset { get { return m_BoxBaseOffset; } }
public Vector3 boxInfluencePositiveFade { get { return m_BoxInfluencePositiveFade; } }
public Vector3 boxInfluenceNegativeFade { get { return m_BoxInfluenceNegativeFade; } }
public Vector3 boxInfluenceNormalPositiveFade { get { return m_BoxInfluenceNormalPositiveFade; } }
public Vector3 boxInfluenceNormalNegativeFade { get { return m_BoxInfluenceNormalNegativeFade; } }
public Vector3 boxBaseSize { get { return m_BoxBaseSize; } set { m_BoxBaseSize = value; } }
public Vector3 boxBaseOffset { get { return m_BoxBaseOffset; } set { m_BoxBaseOffset = value; } }
public Vector3 boxInfluencePositiveFade { get { return m_BoxInfluencePositiveFade; } set { m_BoxInfluencePositiveFade = value; } }
public Vector3 boxInfluenceNegativeFade { get { return m_BoxInfluenceNegativeFade; } set { m_BoxInfluenceNegativeFade = value; } }
public Vector3 boxInfluenceNormalPositiveFade { get { return m_BoxInfluenceNormalPositiveFade; } set { m_BoxInfluenceNormalPositiveFade = value; } }
public Vector3 boxInfluenceNormalNegativeFade { get { return m_BoxInfluenceNormalNegativeFade; } set { m_BoxInfluenceNormalNegativeFade = value; } }
public Vector3 boxPositiveFaceFade { get { return m_BoxPositiveFaceFade; } set { m_BoxPositiveFaceFade = value; } }
public Vector3 boxNegativeFaceFade { get { return m_BoxNegativeFaceFade; } set { m_BoxNegativeFaceFade = value; } }
public float sphereBaseRadius { get { return m_SphereBaseRadius; } }
public Vector3 sphereBaseOffset { get { return m_SphereBaseOffset; } }
public float sphereInfluenceRadius { get { return m_SphereInfluenceRadius; } }
public float sphereInfluenceNormalRadius { get { return m_SphereInfluenceNormalRadius; } }
public Vector3 boxInfluenceOffset { get { return (boxInfluenceNegativeFade - boxInfluencePositiveFade) * 0.5f; } }
public Vector3 boxInfluenceSizeOffset { get { return -(boxInfluencePositiveFade + boxInfluenceNegativeFade); } }
public Vector3 boxInfluenceNormalOffset { get { return (boxInfluenceNormalNegativeFade - boxInfluenceNormalPositiveFade) * 0.5f; } }
public Vector3 boxInfluenceNormalSizeOffset { get { return -(boxInfluenceNormalPositiveFade + boxInfluenceNormalNegativeFade); } }
public float sphereBaseRadius { get { return m_SphereBaseRadius; } set { m_SphereBaseRadius = value; } }
public Vector3 sphereBaseOffset { get { return m_SphereBaseOffset; } set { m_SphereBaseOffset = value; } }
public float sphereInfluenceFade { get { return m_SphereInfluenceFade; } set { m_SphereInfluenceFade = value; } }
public float sphereInfluenceNormalFade { get { return m_SphereInfluenceNormalFade; } set { m_SphereInfluenceNormalFade = value; } }
public float sphereInfluenceRadiusOffset { get { return -sphereInfluenceFade; } }
public float sphereInfluenceNormalRadiusOffset { get { return -sphereInfluenceNormalFade; } }
}
}

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


using System;
using UnityEditorInternal;
using UnityEngine;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<PlanarReflectionProbeUI, SerializedPlanarReflectionProbe>;
partial class PlanarReflectionProbeUI
{
public static readonly CED.IDrawer Inspector = CED.Group(
CED.Action((s, d, o) => EditorGUILayout.LabelField(_.GetContent("Projection Volume"), EditorStyles.boldLabel)),
CED.Action(Drawer_FieldProjectionVolumeReference),
CED.space,
CED.Action((s, d, o) => EditorGUILayout.LabelField(_.GetContent("Influence Volume"), EditorStyles.boldLabel)),
CED.Action(Drawer_Toolbar),
CED.space,
CED.Select(
(s, d, o) => s.influenceVolume,
(s, d, o) => d.influenceVolume,
InfluenceVolumeUI.SectionShape
)
);
const EditMode.SceneViewEditMode EditBaseShape = EditMode.SceneViewEditMode.ReflectionProbeBox;
const EditMode.SceneViewEditMode EditInfluenceShape = EditMode.SceneViewEditMode.GridBox;
const EditMode.SceneViewEditMode EditInfluenceNormalShape = EditMode.SceneViewEditMode.Collider;
const EditMode.SceneViewEditMode EditCenter = EditMode.SceneViewEditMode.ReflectionProbeOrigin;
static void Drawer_FieldProjectionVolumeReference(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.projectionVolumeReference, _.GetContent("Reference"));
}
static readonly EditMode.SceneViewEditMode[] k_Toolbar_SceneViewEditModes =
{
EditBaseShape,
EditInfluenceShape,
EditInfluenceNormalShape,
EditCenter
};
static GUIContent[] s_Toolbar_Contents = null;
static GUIContent[] toolbar_Contents
{
get
{
return s_Toolbar_Contents ?? (s_Toolbar_Contents = new[]
{
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.")
});
}
}
static void Drawer_Toolbar(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.changed = false;
EditMode.DoInspectorToolbar(k_Toolbar_SceneViewEditModes, toolbar_Contents, GetBoundsGetter(o), o);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
static Func<Bounds> GetBoundsGetter(Editor o)
{
return () =>
{
var bounds = new Bounds();
foreach (Component targetObject in o.targets)
{
var rp = targetObject.transform;
var b = rp.position;
bounds.Encapsulate(b);
}
return bounds;
};
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Drawers.cs.meta


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

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


using UnityEditorInternal;
using UnityEngine.Experimental.Rendering;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
partial class PlanarReflectionProbeUI
{
public static void DrawHandles(PlanarReflectionProbeUI s, PlanarReflectionProbe d, Editor o)
{
var mat = d.transform.localToWorldMatrix;
switch (EditMode.editMode)
{
case EditBaseShape:
InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, d.influenceVolume, o, mat, d);
break;
case EditInfluenceShape:
InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, d.influenceVolume, o, mat, d);
break;
case EditInfluenceNormalShape:
InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, d.influenceVolume, o, mat, d);
break;
case EditCenter:
InfluenceVolumeUI.DrawHandles_EditCenter(s.influenceVolume, d.influenceVolume, o, mat, d);
break;
}
}
[DrawGizmo(GizmoType.Selected)]
public static void DrawGizmos(PlanarReflectionProbe d, GizmoType gizmoType)
{
PlanarReflectionProbeUI s;
if (!PlanarReflectionProbeEditor.TryGetUIStateFor(d, out s))
return;
var mat = d.transform.localToWorldMatrix;
switch (EditMode.editMode)
{
case EditBaseShape:
InfluenceVolumeUI.DrawGizmos_EditBase(s.influenceVolume, d.influenceVolume, mat);
break;
case EditInfluenceShape:
InfluenceVolumeUI.DrawGizmos_EditInfluence(s.influenceVolume, d.influenceVolume, mat);
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);
break;
}
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Handles.cs.meta


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

77
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.Drawers.cs


using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<InfluenceVolumeUI, SerializedInfluenceVolume>;
partial class InfluenceVolumeUI
{
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 InfluenceVolumeUI()
{
SectionShape = CED.Group(
CED.Action(Drawer_FieldShapeType),
CED.FadeGroup(
(s, d, o, i) => s.IsSectionExpanded_Shape((ShapeType)i),
true,
SectionShapeBox,
SectionShapeSphere
)
);
}
static void Drawer_FieldShapeType(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o)
{
EditorGUILayout.PropertyField(d.shapeType, _.GetContent("Shape Type"));
}
static void Drawer_SectionShapeBox(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o)
{
var maxFadeDistance = d.boxBaseSize.vector3Value * 0.5f;
var minFadeDistance = Vector3.zero;
EditorGUILayout.PropertyField(d.boxBaseSize, _.GetContent("Box Size"));
EditorGUILayout.PropertyField(d.boxBaseOffset, _.GetContent("Box Offset"));
EditorGUILayout.Space();
_.DrawVector6Slider(
_.GetContent("Influence Fade"),
d.boxInfluencePositiveFade, d.boxInfluenceNegativeFade,
minFadeDistance, maxFadeDistance);
EditorGUILayout.Space();
_.DrawVector6Slider(
_.GetContent("Influence Normal Fade"),
d.boxInfluenceNormalPositiveFade, d.boxInfluenceNormalNegativeFade,
minFadeDistance, maxFadeDistance);
EditorGUILayout.Space();
_.DrawVector6Slider(
_.GetContent("Influence Face Fade"),
d.boxPositiveFaceFade, d.boxNegativeFaceFade,
Vector3.zero, Vector3.one);
}
static void Drawer_SectionShapeSphere(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o)
{
var maxFaceDistance = d.sphereBaseRadius.floatValue;
EditorGUILayout.PropertyField(d.sphereBaseRadius, _.GetContent("Radius"));
EditorGUILayout.PropertyField(d.sphereBaseOffset, _.GetContent("Offset"));
EditorGUILayout.Space();
EditorGUILayout.Slider(d.sphereInfluenceFade, 0, maxFaceDistance, _.GetContent("Influence Fade"));
EditorGUILayout.Slider(d.sphereInfluenceNormalFade, 0, maxFaceDistance, _.GetContent("Influence Normal Fade"));
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.Drawers.cs.meta


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

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


using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
partial class InfluenceVolumeUI
{
public static void DrawGizmos_EditBase(InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix)
{
DrawGizmos_Generic(s, d, matrix, 0);
}
public static void DrawGizmos_EditInfluence(InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix)
{
DrawGizmos_Generic(s, d, matrix, 1);
}
public static void DrawGizmos_EditInfluenceNormal(InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix)
{
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)
{
DrawGizmos_Generic(s, d, matrix, -1);
}
static void DrawGizmos_Generic(InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix, int solidIndex)
{
DrawGizmos_BaseHandle(s, d, matrix, solidIndex == 0, k_GizmoThemeColorBase);
DrawGizmos_FadeHandle(
s, d, matrix,
d.boxInfluenceOffset, d.boxInfluenceSizeOffset,
d.sphereInfluenceRadiusOffset,
solidIndex == 1,
k_GizmoThemeColorInfluence);
DrawGizmos_FadeHandle(
s, d, matrix,
d.boxInfluenceNormalOffset, d.boxInfluenceNormalSizeOffset,
d.sphereInfluenceNormalRadiusOffset,
solidIndex == 2,
k_GizmoThemeColorInfluenceNormal);
}
static void DrawGizmos_BaseHandle(
InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix,
bool isSolid, Color color)
{
var mat = Gizmos.matrix;
var c = Gizmos.color;
Gizmos.matrix = matrix;
Gizmos.color = color;
switch (d.shapeType)
{
case ShapeType.Box:
{
if (isSolid)
Gizmos.DrawCube(d.boxBaseOffset, d.boxBaseSize);
else
Gizmos.DrawWireCube(d.boxBaseOffset, d.boxBaseSize);
break;
}
case ShapeType.Sphere:
{
if (isSolid)
Gizmos.DrawSphere(d.sphereBaseOffset, d.sphereBaseRadius);
else
Gizmos.DrawWireSphere(d.sphereBaseOffset, d.sphereBaseRadius);
break;
}
}
Gizmos.matrix = mat;
Gizmos.color = c;
}
static void DrawGizmos_FadeHandle(
InfluenceVolumeUI s, InfluenceVolume d, Matrix4x4 matrix,
Vector3 boxOffset, Vector3 boxSizeOffset,
float sphereOffset,
bool isSolid, Color color)
{
var mat = Gizmos.matrix;
var c = Gizmos.color;
Gizmos.matrix = matrix;
Gizmos.color = color;
switch (d.shapeType)
{
case ShapeType.Box:
{
if (isSolid)
Gizmos.DrawCube(d.boxBaseOffset + boxOffset, d.boxBaseSize + boxSizeOffset);
else
Gizmos.DrawWireCube(d.boxBaseOffset + boxOffset, d.boxBaseSize + boxSizeOffset);
break;
}
case ShapeType.Sphere:
{
if (isSolid)
Gizmos.DrawSphere(d.sphereBaseOffset, d.sphereBaseRadius + sphereOffset);
else
Gizmos.DrawWireSphere(d.sphereBaseOffset, d.sphereBaseRadius + sphereOffset);
break;
}
}
Gizmos.matrix = mat;
Gizmos.color = c;
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.Gizmos.cs.meta


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

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


using System;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using Object = UnityEngine.Object;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
partial class InfluenceVolumeUI
{
public static void DrawHandles_EditBase(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
{
var mat = Handles.matrix;
var c = Handles.color;
Handles.matrix = matrix;
Handles.color = k_GizmoThemeColorBase;
switch (d.shapeType)
{
case ShapeType.Box:
{
var center = d.boxBaseOffset;
var size = d.boxBaseSize;
DrawBoxHandle(
s, d, o, sourceAsset,
s1 => s1.boxBaseHandle,
ref center,
ref size);
d.boxBaseOffset = center;
d.boxBaseSize = size;
break;
}
case ShapeType.Sphere:
{
var center = d.sphereBaseOffset;
var radius = d.sphereBaseRadius;
DrawSphereHandle(
s, d, o, sourceAsset,
s1 => s1.sphereBaseHandle,
ref center,
ref radius);
d.sphereBaseOffset = center;
d.sphereBaseRadius = radius;
break;
}
}
Handles.matrix = mat;
Handles.color = c;
}
public static void DrawHandles_EditInfluence(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
{
var mat = Handles.matrix;
var c = Handles.color;
Handles.matrix = matrix;
Handles.color = k_GizmoThemeColorInfluence;
switch (d.shapeType)
{
case ShapeType.Box:
{
var positive = d.boxInfluencePositiveFade;
var negative = d.boxInfluenceNegativeFade;
DrawBoxFadeHandle(
s, d, o, sourceAsset,
s1 => s1.boxInfluenceHandle,
d.boxBaseOffset, d.boxBaseSize,
ref positive,
ref negative);
d.boxInfluencePositiveFade = positive;
d.boxInfluenceNegativeFade = negative;
break;
}
case ShapeType.Sphere:
{
var fade = d.sphereInfluenceFade;
DrawSphereFadeHandle(
s, d, o, sourceAsset,
s1 => s1.sphereInfluenceHandle,
d.sphereBaseOffset, d.sphereBaseRadius,
ref fade);
d.sphereInfluenceFade = fade;
break;
}
}
Handles.matrix = mat;
Handles.color = c;
}
public static void DrawHandles_EditInfluenceNormal(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
{
var mat = Handles.matrix;
var c = Handles.color;
Handles.matrix = matrix;
Handles.color = k_GizmoThemeColorInfluenceNormal;
switch (d.shapeType)
{
case ShapeType.Box:
{
var positive = d.boxInfluenceNormalPositiveFade;
var negative = d.boxInfluenceNormalNegativeFade;
DrawBoxFadeHandle(
s, d, o, sourceAsset,
s1 => s1.boxInfluenceNormalHandle,
d.boxBaseOffset, d.boxBaseSize,
ref positive,
ref negative);
d.boxInfluenceNormalPositiveFade = positive;
d.boxInfluenceNormalNegativeFade = negative;
break;
}
case ShapeType.Sphere:
{
var fade = d.sphereInfluenceNormalFade;
DrawSphereFadeHandle(
s, d, o, sourceAsset,
s1 => s1.sphereInfluenceNormalHandle,
d.sphereBaseOffset, d.sphereBaseRadius,
ref fade);
d.sphereInfluenceNormalFade = fade;
break;
}
}
Handles.matrix = mat;
Handles.color = c;
}
public static void DrawHandles_EditCenter(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
{
}
static void DrawBoxHandle(
InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
Func<InfluenceVolumeUI, BoxBoundsHandle> boundsGetter,
ref Vector3 center, ref Vector3 size)
{
var b = boundsGetter(s);
b.center = center;
b.size = size;
EditorGUI.BeginChangeCheck();
b.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sourceAsset, "Modified Base Volume AABB");
center = b.center;
size = b.size;
EditorUtility.SetDirty(sourceAsset);
}
}
static void DrawBoxFadeHandle(
InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
Func<InfluenceVolumeUI, BoxBoundsHandle> boundsGetter,
Vector3 baseOffset, Vector3 baseSize,
ref Vector3 positive, ref Vector3 negative)
{
var b = boundsGetter(s);
b.center = baseOffset - (positive - negative) * 0.5f;
b.size = baseSize - positive - negative;
EditorGUI.BeginChangeCheck();
b.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sourceAsset, "Modified Influence Volume");
var center = baseOffset;
var influenceSize = baseSize;
var diff = 2 * (b.center - center);
var sum = influenceSize - b.size;
var positiveNew = (sum - diff) * 0.5f;
var negativeNew = (sum + diff) * 0.5f;
var blendDistancePositive = Vector3.Max(Vector3.zero, Vector3.Min(positiveNew, influenceSize));
var blendDistanceNegative = Vector3.Max(Vector3.zero, Vector3.Min(negativeNew, influenceSize));
positive = blendDistancePositive;
negative = blendDistanceNegative;
EditorUtility.SetDirty(sourceAsset);
}
}
static void DrawSphereHandle(
InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
Func<InfluenceVolumeUI, SphereBoundsHandle> boundsGetter,
ref Vector3 center, ref float radius)
{
var b = boundsGetter(s);
b.center = center;
b.radius = radius;
EditorGUI.BeginChangeCheck();
b.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sourceAsset, "Modified Base Volume AABB");
center = b.center;
radius = b.radius;
EditorUtility.SetDirty(sourceAsset);
}
}
static void DrawSphereFadeHandle(
InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
Func<InfluenceVolumeUI, SphereBoundsHandle> boundsGetter,
Vector3 baseOffset, float baseRadius,
ref float radius)
{
var b = boundsGetter(s);
b.center = baseOffset;
b.radius = Mathf.Clamp(baseRadius - radius, 0, baseRadius);
EditorGUI.BeginChangeCheck();
b.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sourceAsset, "Modified Influence volume");
radius = Mathf.Clamp(baseRadius - b.radius, 0, baseRadius);
EditorUtility.SetDirty(sourceAsset);
}
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.Handles.cs.meta


fileFormatVersion: 2
guid: b7ed46e20ca504d4cae3c0a0c0ad3e79
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存