浏览代码

[PlanarReflection] (wip) Palanr Reflection Editor

/main
Frédéric Vauchelles 7 年前
当前提交
3376b15f
共有 13 个文件被更改,包括 377 次插入9 次删除
  1. 14
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/PlanarReflectionProbe.cs
  2. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/InfluenceVolume.cs
  3. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumes/ProjectionVolume.cs
  4. 53
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeEditor.cs
  5. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeEditor.cs.meta
  6. 44
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.cs
  7. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.cs.meta
  8. 31
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedPlanarReflectionProbe.cs
  9. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedPlanarReflectionProbe.cs.meta
  10. 139
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.cs
  11. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/InfluenceVolumeUI.cs.meta
  12. 38
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedInfluenceVolume.cs
  13. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedInfluenceVolume.cs.meta

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


namespace UnityEngine.Experimental.Rendering
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEngine.Experimental.Rendering
class PlanarReflectionProbe
public class PlanarReflectionProbe : MonoBehaviour
[SerializeField]
ProjectionVolumeComponent m_ProjectionVolumeReference;
[SerializeField]
InfluenceVolume m_InfluenceVolume;
public ProjectionVolumeComponent projectionVolumeReference { get { return m_ProjectionVolumeReference; } }
public InfluenceVolume influenceVolume { get { return m_InfluenceVolume; } }
}
}

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


// Box
[SerializeField]
Vector3 m_BoxBaseSize;
Vector3 m_BoxBaseSize = Vector3.one;
[SerializeField]
Vector3 m_BoxBaseOffset;
[SerializeField]

// Sphere
[SerializeField]
float m_SphereBaseRadius;
float m_SphereBaseRadius = 1;
float m_SphereInfluenceRadius;
float m_SphereInfluenceRadius = 1;
float m_SphereInfluenceNormalRadius;
float m_SphereInfluenceNormalRadius = 1;
public ShapeType shapeType { get { return m_ShapeType; } }

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


// Box
[SerializeField]
Vector3 m_BoxSize;
Vector3 m_BoxSize = Vector3.one;
[SerializeField]
Vector3 m_BoxOffset;
[SerializeField]

[SerializeField]
float m_SphereRadius;
float m_SphereRadius = 1;
[SerializeField]
Vector3 m_SphereOffset;
[SerializeField]

53
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.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
[CustomEditorForRenderPipeline(typeof(PlanarReflectionProbe), typeof(HDRenderPipelineAsset))]
[CanEditMultipleObjects]
class PlanarReflectionProbeEditor : Editor
{
SerializedPlanarReflectionProbe m_SerializedAsset;
PlanarReflectionProbeUI m_UIState = new PlanarReflectionProbeUI();
PlanarReflectionProbeUI[] m_UIHandleState;
PlanarReflectionProbe[] m_TypedTargets;
void OnEnable()
{
m_SerializedAsset = new SerializedPlanarReflectionProbe(serializedObject);
m_UIState.Reset(m_SerializedAsset, Repaint);
m_TypedTargets = new PlanarReflectionProbe[targets.Length];
m_UIHandleState = new PlanarReflectionProbeUI[m_TypedTargets.Length];
for (var i = 0; i < m_TypedTargets.Length; i++)
{
m_TypedTargets[i] = (PlanarReflectionProbe)targets[i];
m_UIHandleState[i] = new PlanarReflectionProbeUI();
m_UIHandleState[i].Reset(m_SerializedAsset, Repaint);
}
}
public override void OnInspectorGUI()
{
var s = m_UIState;
var d = m_SerializedAsset;
var o = this;
s.Update();
d.Update();
PlanarReflectionProbeUI.Inspector.Draw(s, d, o);
d.Apply();
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeEditor.cs.meta


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

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


using UnityEngine.Events;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<PlanarReflectionProbeUI, SerializedPlanarReflectionProbe>;
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()
: base(0)
{
}
public override void Reset(SerializedPlanarReflectionProbe data, UnityAction repaint)
{
influenceVolume.Reset(data.influenceVolume, repaint);
base.Reset(data, repaint);
}
public override void Update()
{
influenceVolume.Update();
base.Update();
}
static void Drawer_FieldProjectionVolumeReference(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.projectionVolumeReference, _.GetContent("Projection Volume Reference"));
}
}
}

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


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

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


using UnityEditor.Experimental.Rendering.HDPipeline;
using UnityEngine.Experimental.Rendering;
namespace UnityEditor.Experimental.Rendering
{
public class SerializedPlanarReflectionProbe
{
public SerializedObject serializedObject;
public SerializedProperty projectionVolumeReference;
public SerializedInfluenceVolume influenceVolume;
public SerializedPlanarReflectionProbe(SerializedObject serializedObject)
{
this.serializedObject = serializedObject;
projectionVolumeReference = serializedObject.Find((PlanarReflectionProbe p) => p.projectionVolumeReference);
influenceVolume = new SerializedInfluenceVolume(serializedObject.Find((PlanarReflectionProbe p) => p.influenceVolume));
}
public void Update()
{
serializedObject.Update();
}
public void Apply()
{
serializedObject.ApplyModifiedProperties();
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedPlanarReflectionProbe.cs.meta


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

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


using System;
using UnityEditor.AnimatedValues;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using Object = UnityEngine.Object;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<InfluenceVolumeUI, SerializedInfluenceVolume>;
class InfluenceVolumeUI : BaseUI<SerializedInfluenceVolume>
{
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 InfluenceVolumeUI()
{
SectionShape = CED.Group(
CED.Action(Drawer_FieldShapeType),
CED.FadeGroup(
(s, d, o, i) => s.IsSectionExpanded_Shape((ShapeType)i),
true,
SectionShapeBox,
SectionShapeSphere
)
);
}
public InfluenceVolumeUI()
: 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(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;
}
}
}

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


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

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


using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
public class SerializedInfluenceVolume
{
public SerializedProperty root;
public SerializedProperty shapeType;
public SerializedProperty boxBaseSize;
public SerializedProperty boxBaseOffset;
public SerializedProperty boxInfluencePositiveFade;
public SerializedProperty boxInfluenceNegativeFade;
public SerializedProperty boxInfluenceNormalPositiveFade;
public SerializedProperty boxInfluenceNormalNegativeFade;
public SerializedProperty sphereBaseRadius;
public SerializedProperty sphereBaseOffset;
public SerializedProperty sphereInfluenceRadius;
public SerializedProperty sphereInfluenceNormalRadius;
public SerializedInfluenceVolume(SerializedProperty root)
{
this.root = root;
shapeType = root.Find((InfluenceVolume i) => i.shapeType);
boxBaseSize = root.Find((InfluenceVolume i) => i.boxBaseSize);
boxBaseOffset = root.Find((InfluenceVolume i) => i.boxBaseOffset);
boxInfluencePositiveFade = root.Find((InfluenceVolume i) => i.boxInfluencePositiveFade);
boxInfluenceNegativeFade = root.Find((InfluenceVolume i) => i.boxInfluenceNegativeFade);
boxInfluenceNormalPositiveFade = root.Find((InfluenceVolume i) => i.boxInfluenceNormalPositiveFade);
boxInfluenceNormalNegativeFade = root.Find((InfluenceVolume i) => i.boxInfluenceNormalNegativeFade);
sphereBaseRadius = root.Find((InfluenceVolume i) => i.sphereBaseRadius);
sphereBaseOffset = root.Find((InfluenceVolume i) => i.sphereBaseOffset);
sphereInfluenceRadius = root.Find((InfluenceVolume i) => i.sphereInfluenceRadius);
sphereInfluenceNormalRadius = root.Find((InfluenceVolume i) => i.sphereInfluenceNormalRadius);
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volume/SerializedInfluenceVolume.cs.meta


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