浏览代码

Merge pull request #1868 from Unity-Technologies/revert-1813-HDRP/refactor-reflectionProbe/merge-probe-editors

Revert "Hdrp/refactor reflection probe/merge probe editors"
/main
GitHub 6 年前
当前提交
0eeccd2c
共有 53 个文件被更改,包括 1918 次插入1772 次删除
  1. 29
      com.unity.render-pipelines.core/CoreRP/Editor/CoreEditorUtils.cs
  2. 3
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/EditorReflectionSystem.cs
  3. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Gizmos.cs
  4. 34
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Preview.cs
  5. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.ProbeUtility.cs
  6. 133
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.cs
  7. 532
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.Drawers.cs
  8. 102
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.cs
  9. 89
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs
  10. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs.meta
  11. 212
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs
  12. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs.meta
  13. 121
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.cs
  14. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.cs.meta
  15. 109
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDReflectionProbe.cs
  16. 81
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedPlanarReflectionProbe.cs
  17. 163
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Drawers.cs
  18. 311
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs
  19. 20
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.cs
  20. 135
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/ProxyVolumeUI.cs
  21. 9
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/ReflectionProxyVolumeComponentUI.cs
  22. 29
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/SerializedInfluenceVolume.cs
  23. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/ReflectionMenuItem.cs
  24. 4
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.cs
  25. 10
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
  26. 69
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs
  27. 25
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDProbe.cs
  28. 19
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/PlanarReflectionProbe.cs
  29. 29
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ProbeWrapper.cs
  30. 10
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystem.cs
  31. 166
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystemInternal.cs
  32. 14
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystemParameters.cs
  33. 16
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/InfluenceVolume.cs
  34. 8
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs
  35. 4
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipelineAsset.cs
  36. 89
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Handles.cs
  37. 312
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Drawers.cs
  38. 34
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Skin.cs
  39. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Skin.cs.meta
  40. 80
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeEditor.cs
  41. 297
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs
  42. 101
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Handles.cs
  43. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Handles.cs.meta
  44. 77
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Skin.cs
  45. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Skin.cs.meta
  46. 90
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.cs
  47. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.cs.meta
  48. 57
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs
  49. 11
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs.meta
  50. 0
      /com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/ReflectionMenuItem.cs.meta
  51. 0
      /com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/ReflectionMenuItem.cs
  52. 0
      /com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Drawers.cs.meta
  53. 0
      /com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Handles.cs.meta

29
com.unity.render-pipelines.core/CoreRP/Editor/CoreEditorUtils.cs


throw new System.ArgumentException("Colors must be a 2x3 array.");
GUILayout.BeginVertical();
Rect rect = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(0, float.MaxValue, EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight));
if (label != GUIContent.none)
{
var labelRect = rect;
labelRect.x -= 12f;
labelRect.width = EditorGUIUtility.labelWidth;
EditorGUI.LabelField(labelRect, label);
rect.x += EditorGUIUtility.labelWidth - 12f;
rect.width -= EditorGUIUtility.labelWidth - 12f;
}
if(label != GUIContent.none)
EditorGUILayout.LabelField(label);
++EditorGUI.indentLevel;
var rect = GUILayoutUtility.GetRect(0, float.MaxValue, EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight);
var v = positive.vector3Value;
EditorGUI.BeginChangeCheck();
v = DrawVector3(rect, k_DrawVector6_Label, v, min, max, false, colors == null ? null : colors[0]);

GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
rect = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(0, float.MaxValue, EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight));
rect.x += EditorGUIUtility.labelWidth - 12f;
rect.width -= EditorGUIUtility.labelWidth - 12f;
rect = GUILayoutUtility.GetRect(0, float.MaxValue, EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight);
--EditorGUI.indentLevel;
GUILayout.EndVertical();
}

//rect = EditorGUI.IndentedRect(rect);
rect = EditorGUI.IndentedRect(rect);
float fieldWidth = rect.width / 3f;
EditorGUI.BeginChangeCheck();
EditorGUI.MultiFloatField(rect, labels, multifloat);

//Suffix is a hack as sublabel only work with 1 character
if(addMinusPrefix)
{
Rect suffixRect = new Rect(rect.x-19, rect.y, 100, rect.height);
Rect suffixRect = new Rect(rect.x-33, rect.y, 100, rect.height);
suffixRect.x += fieldWidth + .66f;
suffixRect.x += fieldWidth + .5f;
}
}

if (colors.Length != 3)
throw new System.ArgumentException("colors must have 3 elements.");
Rect suffixRect = new Rect(rect.x - 8, rect.y, 100, rect.height);
Rect suffixRect = new Rect(rect.x - 23, rect.y, 100, rect.height);
GUIStyle colorMark = new GUIStyle(EditorStyles.label);
colorMark.normal.textColor = colors[0];
EditorGUI.LabelField(suffixRect, "|", colorMark);

3
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/EditorReflectionSystem.cs


AssetDatabase.ImportAsset(path);
probe.customTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
EditorUtility.SetDirty(probe);
}
public static void BakeAllPlanarReflectionProbes()

{
bakedTexture = new Texture2D(rt.width, rt.height, TextureFormat.RGBAHalf, true, false);
probe.bakedTexture = bakedTexture;
EditorUtility.SetDirty(probe);
}
ReflectionSystem.Render(probe, rt);

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Gizmos.cs


{
material = new Material(Shader.Find("Debug/ReflectionProbePreview"));
}
material.SetTexture("_Cubemap", e.GetTexture());
material.SetTexture("_Cubemap", p.texture);
material.SetPass(0);
Graphics.DrawMeshNow(sphere, Matrix4x4.TRS(p.transform.position, Quaternion.identity, Vector3.one));
}

34
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Preview.cs


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

return false; // We only handle one preview for reflection probes
// Ensure valid cube map editor (if possible)
Texture texture = GetTexture();
if (m_CubemapEditor != null && m_CubemapEditor.target as Texture != texture)
{
DestroyImmediate(m_CubemapEditor);
m_CubemapEditor = null;
}
CreateCachedEditor(GetTexture(), typeof(HDCubemapInspector), ref editor);
CreateCachedEditor(((ReflectionProbe)target).texture, typeof(HDCubemapInspector), ref editor);
m_CubemapEditor = editor as HDCubemapInspector;
}

GUILayout.EndHorizontal();
return;
}
Texture tex = GetTexture();
if (tex != null && targets.Length == 1)
var p = target as ReflectionProbe;
if (p != null && p.texture != null && targets.Length == 1)
return GetTexture() != null;
}
Texture GetTexture()
{
HDProbe additional = GetTarget(target);
if (additional != null && additional.mode == UnityEngine.Rendering.ReflectionProbeMode.Realtime)
{
return additional.realtimeTexture;
}
else
{
var p = target as ReflectionProbe;
if (p != null)
return p.texture;
}
return null;
var p = target as ReflectionProbe;
return p != null && p.texture != null;
}
private void OnDestroy()

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.ProbeUtility.cs


{
partial class HDReflectionProbeEditor
{
void InitializeTargetProbe()
void InitializeAllTargetProbes()
{
// For an unknown reason, newly created probes sometype have the type "Quad" (value = 1)
// This type of probe is not supported by Unity since 5.4

133
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.cs


{
[CustomEditorForRenderPipeline(typeof(ReflectionProbe), typeof(HDRenderPipelineAsset))]
[CanEditMultipleObjects]
partial class HDReflectionProbeEditor : HDProbeEditor
partial class HDReflectionProbeEditor : Editor
{
[MenuItem("CONTEXT/ReflectionProbe/Remove Component", false, 0)]
static void RemoveReflectionProbe(MenuCommand menuCommand)

static Dictionary<ReflectionProbe, HDReflectionProbeEditor> s_ReflectionProbeEditors = new Dictionary<ReflectionProbe, HDReflectionProbeEditor>();
internal override HDProbe GetTarget(Object editorTarget)
{
return (HDProbe)s_ReflectionProbeEditors[(ReflectionProbe)editorTarget].m_AdditionalDataSerializedObject.targetObject;
}
protected override void Draw(HDProbeUI s, SerializedHDProbe serialized, Editor owner)
{
HDReflectionProbeUI.Inspector.Draw(s, serialized, owner);
}
static HDReflectionProbeEditor GetEditorFor(ReflectionProbe p)
{
HDReflectionProbeEditor e;

return null;
}
SerializedHDReflectionProbe m_SerializedHdReflectionProbe;
internal HDReflectionProbeUI m_UIState = new HDReflectionProbeUI();
HDReflectionProbeUI m_UIState = new HDReflectionProbeUI();
int m_PositionHash = 0;
get { return HDProbeUI.IsProbeEditMode(EditMode.editMode) && EditMode.IsOwner(this); }
get { return IsReflectionProbeEditMode(EditMode.editMode) && EditMode.IsOwner(this); }
protected override void OnEnable()
void OnEnable()
m_SerializedHDProbe = new SerializedHDReflectionProbe(serializedObject, m_AdditionalDataSerializedObject);
m_SerializedHdReflectionProbe = new SerializedHDReflectionProbe(serializedObject, m_AdditionalDataSerializedObject);
m_UIState.owner = this;
m_UIState.Reset(m_SerializedHdReflectionProbe, Repaint);
foreach (var t in targets)
{

base.OnEnable();
m_UIState.owner = this;
m_UIState.Reset(m_SerializedHDProbe, Repaint);
InitializeTargetProbe();
InitializeAllTargetProbes();
}
//unhide previously hidden components
probe.hideFlags = HideFlags.None;
public override void OnInspectorGUI()
{
//InspectColorsGUI();
var s = m_UIState;
var p = m_SerializedHdReflectionProbe;
s.Update();
p.Update();
HDReflectionProbeUI.Inspector.Draw(s, p, this);
PerformOperations(s, p, this);
p.Apply();
//HideAdditionalComponents(false);
HDReflectionProbeUI.DoShortcutKey(p, this);
}
public static bool IsReflectionProbeEditMode(EditMode.SceneViewEditMode editMode)
{
return editMode == EditMode.SceneViewEditMode.ReflectionProbeBox || editMode == EditMode.SceneViewEditMode.Collider || editMode == EditMode.SceneViewEditMode.GridBox ||
editMode == EditMode.SceneViewEditMode.ReflectionProbeOrigin;
}
static void PerformOperations(HDReflectionProbeUI s, SerializedHDReflectionProbe p, HDReflectionProbeEditor o)
{
}
void HideAdditionalComponents(bool visible)
{
var adds = CoreEditorUtils.GetAdditionalData<HDAdditionalReflectionData>(targets);
var flags = visible ? HideFlags.None : HideFlags.HideInInspector;
for (var i = 0; i < targets.Length; ++i)
{
var addData = adds[i];
addData.hideFlags = flags;
}
}
void BakeRealtimeProbeIfPositionChanged(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o)
{
if (Application.isPlaying
|| ((ReflectionProbeMode)sp.mode.intValue) != ReflectionProbeMode.Realtime)
{
m_PositionHash = 0;
return;
}
var hash = 0;
for (var i = 0; i < sp.so.targetObjects.Length; i++)
{
var p = (ReflectionProbe)sp.so.targetObjects[i];
var tr = p.GetComponent<Transform>();
hash ^= tr.position.GetHashCode();
}
if (hash != m_PositionHash)
{
m_PositionHash = hash;
for (var i = 0; i < sp.so.targetObjects.Length; i++)
{
var p = (ReflectionProbe)sp.so.targetObjects[i];
p.RenderProbe();
}
}
}
static void ApplyConstraintsOnTargets(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o)
{
switch ((InfluenceShape)sp.influenceVolume.shape.enumValueIndex)
{
case InfluenceShape.Box:
{
var maxBlendDistance = sp.influenceVolume.boxSize.vector3Value;
sp.targetData.influenceVolume.boxBlendDistancePositive = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistancePositive, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendDistanceNegative = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistanceNegative, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendNormalDistancePositive = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistancePositive, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendNormalDistanceNegative = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistanceNegative, maxBlendDistance);
break;
}
case InfluenceShape.Sphere:
{
var maxBlendDistance = Vector3.one * sp.influenceVolume.sphereRadius.floatValue;
sp.targetData.influenceVolume.boxBlendDistancePositive = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistancePositive, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendDistanceNegative = Vector3.Min(sp.targetData.influenceVolume.boxBlendDistanceNegative, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendNormalDistancePositive = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistancePositive, maxBlendDistance);
sp.targetData.influenceVolume.boxBlendNormalDistanceNegative = Vector3.Min(sp.targetData.influenceVolume.boxBlendNormalDistanceNegative, maxBlendDistance);
break;
}
}
}
}
}

532
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.Drawers.cs


using System;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;

using CED = CoreEditorDrawer<HDProbeUI, SerializedHDProbe>;
using CED = CoreEditorDrawer<HDReflectionProbeUI, SerializedHDReflectionProbe>;
using _ = CoreEditorUtils;
public static readonly CED.IDrawer[] Inspector;
ProxyVolumeSettings,
SectionProxyVolumeSettings,
CED.Action((s, d, o) => Drawer_DifferentShapeError(s, d, o)),
SectionInfluenceProxyMismatch,
SectionFoldoutAdditionalSettings,
CED.Action((s, d, o) => Drawer_SectionBakeButton(s, d, o))
SectionAdditionalSettings,
ButtonBake
static readonly CED.IDrawer SectionPrimarySettings = CED.Group(
CED.Action((s, d, o) => Drawer_Toolbars(s, d, o)),
public static readonly CED.IDrawer[] Inspector;
public static readonly CED.IDrawer SectionPrimarySettings = CED.Group(
CED.Action(Drawer_Toolbar),
CED.FadeGroup((s, p, o, i) => s.IsSectionExpandedReflectionProbeMode((ReflectionProbeMode)i),
CED.FadeGroup((s, p, o, i) => s.IsSectionExpandedMode((ReflectionProbeMode)i),
CED.noop, // Baked
CED.Action((s, d, o) => Drawer_ModeSettingsRealtime(s, d, o)), // Realtime
CED.Action((s, d, o) => Drawer_ModeSettingsCustom(s, d, o)) // Custom
CED.noop, // Baked
CED.Action(Drawer_ModeSettingsRealtime), // Realtime
CED.Action(Drawer_ModeSettingsCustom) // Custom
static readonly CED.IDrawer SectionCaptureSettings = CED.FoldoutGroup(
captureSettingsHeader,
public static readonly CED.IDrawer SectionProxyVolumeSettings = CED.FoldoutGroup(
"Proxy Volume",
(s, p, o) => s.isSectionExpandedProxyVolume,
FoldoutOption.Indent,
CED.Action(Drawer_ProxyVolume),
CED.space,
CED.Action(Drawer_ProjectionSettings)
);
public static readonly CED.IDrawer SectionInfluenceVolumeSettings = CED.FoldoutGroup(
"Influence Volume",
(s, p, o) => s.isSectionExpandedInfluenceVolume,
FoldoutOption.Indent,
CED.Action(Drawer_InfluenceAdvancedSwitch),
CED.space,
CED.Action(Drawer_InfluenceShape),
CED.space,
CED.Action(Drawer_InfluenceAreas)
);
public static readonly CED.IDrawer SectionInfluenceProxyMismatch = CED.Action(Drawer_InfluenceProxyMissmatch);
public static readonly CED.IDrawer SectionCaptureSettings = CED.FoldoutGroup(
"Capture Settings",
static void Drawer_CaptureSettings(HDProbeUI s, SerializedHDProbe p, Editor owner)
public static readonly CED.IDrawer SectionAdditionalSettings = CED.FoldoutGroup(
"Artistic Settings",
(s, p, o) => s.isSectionExpandedAdditional,
FoldoutOption.Indent,
CED.Action(Drawer_AdditionalSettings)
);
public static readonly CED.IDrawer ButtonBake = CED.Action(Drawer_BakeActions);
static void Drawer_CaptureSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
EditorGUILayout.LabelField(resolutionContent, CoreEditorUtils.GetContent(p.resolution.intValue.ToString()));
EditorGUILayout.LabelField(CoreEditorUtils.GetContent("Resolution"), CoreEditorUtils.GetContent(p.resolution.intValue.ToString()));
EditorGUILayout.PropertyField(p.shadowDistance, shadowDistanceContent);
EditorGUILayout.PropertyField(p.cullingMask, cullingMaskContent);
EditorGUILayout.PropertyField(p.useOcclusionCulling, useOcclusionCullingContent);
EditorGUILayout.PropertyField(p.nearClip, nearClipCullingContent);
EditorGUILayout.PropertyField(p.farClip, farClipCullingContent);
EditorGUILayout.PropertyField(p.shadowDistance, CoreEditorUtils.GetContent("Shadow Distance"));
EditorGUILayout.PropertyField(p.cullingMask, CoreEditorUtils.GetContent("Culling Mask"));
EditorGUILayout.PropertyField(p.useOcclusionCulling, CoreEditorUtils.GetContent("Use Occlusion Culling"));
EditorGUILayout.PropertyField(p.nearClip, CoreEditorUtils.GetContent("Near Clip"));
EditorGUILayout.PropertyField(p.farClip, CoreEditorUtils.GetContent("Far Clip"));
static void Drawer_AdditionalSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.weight, CoreEditorUtils.GetContent("Influence Volume Weight|Blending weight to use while interpolating between influence volume. (Reminder: Sky is an Influence Volume too)."));
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(p.multiplier, CoreEditorUtils.GetContent("Multiplier|Tweeking option to enhance reflection."));
if (EditorGUI.EndChangeCheck())
p.multiplier.floatValue = Mathf.Max(0.0f, p.multiplier.floatValue);
if (p.so.targetObjects.Length == 1)
{
var probe = p.target;
if (probe.mode == ReflectionProbeMode.Custom && probe.customBakedTexture != null)
{
var cubemap = probe.customBakedTexture as Cubemap;
if (cubemap && cubemap.mipmapCount == 1)
EditorGUILayout.HelpBox("No mipmaps in the cubemap, Smoothness value in Standard shader will be ignored.", MessageType.Warning);
}
}
}
static void Drawer_BakeActions(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)p.mode.intValue, p.target);
}
static void Drawer_ProxyVolume(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.proxyVolumeComponent, _.GetContent("Proxy Volume"));
if (p.proxyVolumeComponent.objectReferenceValue == null)
{
EditorGUILayout.HelpBox(
"When no Proxy setted, Influence shape will be used as Proxy shape too.",
MessageType.Info,
true
);
}
}
#region Influence Volume
static void Drawer_InfluenceProxyMissmatch(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
if (p.proxyVolumeComponent.objectReferenceValue != null)
{
var proxy = (ReflectionProxyVolumeComponent)p.proxyVolumeComponent.objectReferenceValue;
if ((int)proxy.proxyVolume.shape != p.influenceVolume.shape.enumValueIndex)
EditorGUILayout.HelpBox(
"Proxy volume and influence volume have different shape types, this is not supported.",
MessageType.Error,
true
);
}
}
static void Drawer_InfluenceBoxSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
bool advanced = p.influenceVolume.editorAdvancedModeEnabled.boolValue;
var maxBlendDistance = p.boxSize.vector3Value * 0.5f;
EditorGUILayout.BeginHorizontal();
Drawer_AdvancedBlendDistance(
p,
false,
maxBlendDistance,
CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes.")
);
if (GUILayout.Button(toolbar_Contents[1], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3))))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[1], GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
Drawer_AdvancedBlendDistance(
p,
true,
maxBlendDistance,
CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes.")
);
if (GUILayout.Button(toolbar_Contents[2], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3))))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[2], GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
if (advanced)
{
CoreEditorUtils.DrawVector6(
CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap."),
p.influenceVolume.boxSideFadePositive, p.influenceVolume.boxSideFadeNegative, Vector3.zero, Vector3.one, HDReflectionProbeEditor.k_handlesColor);
}
}
static void Drawer_AdvancedBlendDistance(SerializedHDReflectionProbe p, bool isNormal, Vector3 maxBlendDistance, GUIContent content)
{
SerializedProperty blendDistancePositive = isNormal ? p.influenceVolume.boxBlendNormalDistancePositive : p.influenceVolume.boxBlendDistancePositive;
SerializedProperty blendDistanceNegative = isNormal ? p.influenceVolume.boxBlendNormalDistanceNegative : p.influenceVolume.boxBlendDistanceNegative;
SerializedProperty editorAdvancedModeBlendDistancePositive = isNormal ? p.influenceVolume.editorAdvancedModeBlendNormalDistancePositive : p.influenceVolume.editorAdvancedModeBlendDistancePositive;
SerializedProperty editorAdvancedModeBlendDistanceNegative = isNormal ? p.influenceVolume.editorAdvancedModeBlendNormalDistanceNegative : p.influenceVolume.editorAdvancedModeBlendDistanceNegative;
SerializedProperty editorSimplifiedModeBlendDistance = isNormal ? p.influenceVolume.editorSimplifiedModeBlendNormalDistance : p.influenceVolume.editorSimplifiedModeBlendDistance;
Vector3 bdp = blendDistancePositive.vector3Value;
Vector3 bdn = blendDistanceNegative.vector3Value;
EditorGUILayout.BeginVertical();
if (p.influenceVolume.editorAdvancedModeEnabled.boolValue)
{
EditorGUI.BeginChangeCheck();
CoreEditorUtils.DrawVector6(
content,
editorAdvancedModeBlendDistancePositive, editorAdvancedModeBlendDistanceNegative, Vector3.zero, maxBlendDistance, HDReflectionProbeEditor.k_handlesColor);
if(EditorGUI.EndChangeCheck())
{
blendDistancePositive.vector3Value = editorAdvancedModeBlendDistancePositive.vector3Value;
blendDistanceNegative.vector3Value = editorAdvancedModeBlendDistanceNegative.vector3Value;
p.Apply();
}
}
else
{
float distance = editorSimplifiedModeBlendDistance.floatValue;
EditorGUI.BeginChangeCheck();
distance = EditorGUILayout.FloatField(content, distance);
if (EditorGUI.EndChangeCheck())
{
Vector3 decal = Vector3.one * distance;
bdp.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
bdp.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);
bdp.z = Mathf.Clamp(decal.z, 0f, maxBlendDistance.z);
bdn.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
bdn.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);
bdn.z = Mathf.Clamp(decal.z, 0f, maxBlendDistance.z);
blendDistancePositive.vector3Value = bdp;
blendDistanceNegative.vector3Value = bdn;
editorSimplifiedModeBlendDistance.floatValue = distance;
p.Apply();
}
}
GUILayout.EndVertical();
}
static void Drawer_InfluenceSphereSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
var maxBlendDistance = p.influenceVolume.sphereRadius.floatValue;
var blendDistance = p.influenceVolume.boxBlendDistancePositive.vector3Value.x;
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = p.influenceVolume.boxBlendDistancePositive.hasMultipleDifferentValues;
blendDistance = EditorGUILayout.Slider(CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."), blendDistance, 0, maxBlendDistance);
if (EditorGUI.EndChangeCheck())
{
p.influenceVolume.boxBlendDistancePositive.vector3Value = Vector3.one * blendDistance;
p.influenceVolume.boxBlendDistanceNegative.vector3Value = Vector3.one * blendDistance;
}
if (GUILayout.Button(toolbar_Contents[1], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[1], GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
var blendNormalDistance = p.influenceVolume.boxBlendNormalDistancePositive.vector3Value.x;
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = p.influenceVolume.boxBlendNormalDistancePositive.hasMultipleDifferentValues;
blendNormalDistance = EditorGUILayout.Slider(CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes."), blendNormalDistance, 0, maxBlendDistance);
if (EditorGUI.EndChangeCheck())
{
p.influenceVolume.boxBlendNormalDistancePositive.vector3Value = Vector3.one * blendNormalDistance;
p.influenceVolume.boxBlendNormalDistanceNegative.vector3Value = Vector3.one * blendNormalDistance;
}
if (GUILayout.Button(toolbar_Contents[2], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[2], GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
EditorGUI.showMixedValue = false;
}
#endregion
#region Field Drawers
static void Drawer_ReflectionProbeMode(HDProbeUI s, SerializedHDProbe p, Editor owner)
static void Drawer_ReflectionProbeMode(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
HDReflectionProbeUI ui = ((HDReflectionProbeEditor)owner).m_UIState;
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = p.mode.hasMultipleDifferentValues;
EditorGUILayout.IntPopup(p.mode, k_Content_ReflectionProbeMode, k_Content_ReflectionProbeModeValues, CoreEditorUtils.GetContent("Type|'Baked Cubemap' uses the 'Auto Baking' mode from the Lighting window. If it is enabled then baking is automatic otherwise manual bake is needed (use the bake button below). \n'Custom' can be used if a custom cubemap is wanted. \n'Realtime' can be used to dynamically re-render the cubemap during runtime (via scripting)."));

ui.SetModeTarget(p.mode.intValue);
p.Apply();
s.SetModeTarget(p.mode.intValue);
}
}
static void Drawer_InfluenceAdvancedSwitch(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
bool advanced = p.influenceVolume.editorAdvancedModeEnabled.boolValue;
advanced = !GUILayout.Toggle(!advanced, CoreEditorUtils.GetContent("Normal|Normal parameters mode (only change for box shape)."), EditorStyles.miniButtonLeft, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
advanced = GUILayout.Toggle(advanced, CoreEditorUtils.GetContent("Advanced|Advanced parameters mode (only change for box shape)."), EditorStyles.miniButtonRight, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
s.alternativeBoxBlendHandle.allHandleControledByOne = s.alternativeBoxBlendNormalHandle.allHandleControledByOne = !advanced;
if (p.influenceVolume.editorAdvancedModeEnabled.boolValue ^ advanced)
{
p.influenceVolume.editorAdvancedModeEnabled.boolValue = advanced;
if (advanced)
{
p.influenceVolume.boxBlendDistancePositive.vector3Value = p.influenceVolume.editorAdvancedModeBlendDistancePositive.vector3Value;
p.influenceVolume.boxBlendDistanceNegative.vector3Value = p.influenceVolume.editorAdvancedModeBlendDistanceNegative.vector3Value;
p.influenceVolume.boxBlendNormalDistancePositive.vector3Value = p.influenceVolume.editorAdvancedModeBlendNormalDistancePositive.vector3Value;
p.influenceVolume.boxBlendNormalDistanceNegative.vector3Value = p.influenceVolume.editorAdvancedModeBlendNormalDistanceNegative.vector3Value;
}
else
{
p.influenceVolume.boxBlendDistanceNegative.vector3Value = p.influenceVolume.boxBlendDistancePositive.vector3Value = Vector3.one * p.influenceVolume.editorSimplifiedModeBlendDistance.floatValue;
p.influenceVolume.boxBlendNormalDistanceNegative.vector3Value = p.influenceVolume.boxBlendNormalDistancePositive.vector3Value = Vector3.one * p.influenceVolume.editorSimplifiedModeBlendNormalDistance.floatValue;
}
p.Apply();
}
}
}
static void Drawer_InfluenceShape(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = p.influenceVolume.shape.hasMultipleDifferentValues;
EditorGUILayout.PropertyField(p.influenceVolume.shape, CoreEditorUtils.GetContent("Shape"));
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck())
s.SetShapeTarget(p.influenceVolume.shape.intValue);
switch ((InfluenceShape)p.influenceVolume.shape.enumValueIndex)
{
case InfluenceShape.Box:
Drawer_InfluenceShapeBoxSettings(s, p, owner);
break;
case InfluenceShape.Sphere:
Drawer_InfluenceShapeSphereSettings(s, p, owner);
break;
}
}
static void Drawer_InfluenceShapeBoxSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(p.boxSize, CoreEditorUtils.GetContent("Box Size|The size of the box in which the reflections will be applied to objects. The value is not affected by the Transform of the Game Object."));
if (GUILayout.Button(toolbar_Contents[0], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeBox, GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
EditorGUI.BeginChangeCheck();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(p.boxOffset, CoreEditorUtils.GetContent("Box Offset|The center of the box in which the reflections will be applied to objects. The value is relative to the position of the Game Object."));
if (GUILayout.Button(toolbar_Contents[3], GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeOrigin, GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
if (EditorGUI.EndChangeCheck())
{
var center = p.boxOffset.vector3Value;
var size = p.boxSize.vector3Value;
if (HDReflectionProbeEditorUtility.ValidateAABB(p.target, ref center, ref size))
{
//clamp to contains object center instead of resizing
Vector3 projector = (center - p.boxOffset.vector3Value).normalized;
p.boxOffset.vector3Value = center + Mathf.Abs(Vector3.Dot((p.boxSize.vector3Value - size) * .5f, projector)) * projector;
}
static void Drawer_InfluenceShapeSphereSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(p.influenceVolume.sphereRadius, CoreEditorUtils.GetContent("Radius"));
if (GUILayout.Button(toolbar_Contents[0], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeBox, GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(p.boxOffset, CoreEditorUtils.GetContent("Sphere Offset|The center of the sphere in which the reflections will be applied to objects. The value is relative to the position of the Game Object."));
if (GUILayout.Button(toolbar_Contents[3], GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.Height(EditorGUIUtility.singleLineHeight + 3)))
{
EditMode.ChangeEditMode(EditMode.SceneViewEditMode.ReflectionProbeOrigin, GetBoundsGetter(p)(), owner);
}
EditorGUILayout.EndHorizontal();
}
static void Drawer_InfluenceAreas(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
if (s.IsSectionExpandedShape(InfluenceShape.Box).value)
{
Drawer_InfluenceBoxSettings(s, p, owner);
}
if (s.IsSectionExpandedShape(InfluenceShape.Sphere).value)
{
Drawer_InfluenceSphereSettings(s, p, owner);
}
}
static void Drawer_ProjectionSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.boxProjection, CoreEditorUtils.GetContent("Parallax Correction|Parallax Correction causes reflections to appear to change based on the object's position within the probe's box, while still using a single probe as the source of the reflection. This works well for reflections on objects that are moving through enclosed spaces such as corridors and rooms. Setting Parallax Correction to False and the cubemap reflection will be treated as coming from infinitely far away. Note that this feature can be globally disabled from Graphics Settings -> Tier Settings"));
}
static void Drawer_IntensityMultiplier(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
EditorGUILayout.PropertyField(p.intensityMultiplier, CoreEditorUtils.GetContent("Intensity"));
}
#endregion
#region Toolbar
static readonly EditMode.SceneViewEditMode[] k_Toolbar_SceneViewEditModes =
{
EditMode.SceneViewEditMode.ReflectionProbeBox,
EditMode.SceneViewEditMode.GridBox,
EditMode.SceneViewEditMode.Collider,
EditMode.SceneViewEditMode.ReflectionProbeOrigin
};
static GUIContent[] s_Toolbar_Contents = null;
static GUIContent[] toolbar_Contents
{
get
{
return s_Toolbar_Contents ?? (s_Toolbar_Contents = new[]
{
EditorGUIUtility.IconContent("EditCollider", "|Modify the extents of the reflection probe. (SHIFT+1)"),
EditorGUIUtility.IconContent("PreMatCube", "|Modify the influence volume of the reflection probe. (SHIFT+2)"),
EditorGUIUtility.IconContent("SceneViewOrtho", "|Modify the influence normal volume of the reflection probe. (SHIFT+3)"),
EditorGUIUtility.IconContent("MoveTool", "|Move the selected objects.")
});
}
}
static void Drawer_Toolbar(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
{
if (p.so.targetObjects.Length > 1)
return;
// Show the master tool selector
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.changed = false;
var oldEditMode = EditMode.editMode;
EditMode.DoInspectorToolbar(k_Toolbar_SceneViewEditModes, toolbar_Contents, GetBoundsGetter(p), owner);
//if (GUILayout.Button(EditorGUIUtility.IconContent("Navigation", "|Fit the reflection probe volume to the surrounding colliders.")))
// s.AddOperation(Operation.FitVolumeToSurroundings);
if (oldEditMode != EditMode.editMode)
{
switch (EditMode.editMode)
{
case EditMode.SceneViewEditMode.ReflectionProbeOrigin:
s.UpdateOldLocalSpace(p.target);
break;
}
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
static public void Drawer_ToolBarButton(int buttonIndex, Editor owner, params GUILayoutOption[] styles)
{
if (GUILayout.Button(toolbar_Contents[buttonIndex], styles))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[buttonIndex], GetBoundsGetter(owner)(), owner);
}
}
static Func<Bounds> GetBoundsGetter(SerializedHDReflectionProbe p)
{
return () =>
{
var bounds = new Bounds();
foreach (var targetObject in p.so.targetObjects)
{
var rp = (ReflectionProbe)targetObject;
var b = rp.bounds;
bounds.Encapsulate(b);
}
return bounds;
};
}
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;
};
}
static readonly KeyCode[] k_ShortCutKeys =
{
KeyCode.Alpha1,
KeyCode.Alpha2,
KeyCode.Alpha3,
};
public static void DoShortcutKey(SerializedHDReflectionProbe p, Editor o)
{
var evt = Event.current;
if (evt.type != EventType.KeyDown || !evt.shift)
return;
for (var i = 0; i < k_ShortCutKeys.Length; ++i)
{
if (evt.keyCode == k_ShortCutKeys[i])
{
var mode = EditMode.editMode == k_Toolbar_SceneViewEditModes[i]
? EditMode.SceneViewEditMode.None
: k_Toolbar_SceneViewEditModes[i];
EditMode.ChangeEditMode(mode, GetBoundsGetter(p)(), o);
evt.Use();
break;
}
}
}
#endregion
static void Drawer_ModeSettingsCustom(HDProbeUI s, SerializedHDProbe p, Editor owner)
static void Drawer_ModeSettingsCustom(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
SerializedHDReflectionProbe probe = (SerializedHDReflectionProbe)p;
EditorGUILayout.PropertyField(probe.renderDynamicObjects, CoreEditorUtils.GetContent("Dynamic Objects|If enabled dynamic objects are also rendered into the cubemap"));
EditorGUILayout.PropertyField(p.renderDynamicObjects, CoreEditorUtils.GetContent("Dynamic Objects|If enabled dynamic objects are also rendered into the cubemap"));
EditorGUI.showMixedValue = probe.customBakedTexture.hasMultipleDifferentValues;
EditorGUI.showMixedValue = p.customBakedTexture.hasMultipleDifferentValues;
var customBakedTexture = EditorGUILayout.ObjectField(CoreEditorUtils.GetContent("Cubemap"), probe.customBakedTexture.objectReferenceValue, typeof(Cubemap), false);
var customBakedTexture = EditorGUILayout.ObjectField(CoreEditorUtils.GetContent("Cubemap"), p.customBakedTexture.objectReferenceValue, typeof(Cubemap), false);
probe.customBakedTexture.objectReferenceValue = customBakedTexture;
p.customBakedTexture.objectReferenceValue = customBakedTexture;
static void Drawer_ModeSettingsRealtime(HDProbeUI s, SerializedHDProbe p, Editor owner)
static void Drawer_ModeSettingsRealtime(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner)
SerializedHDReflectionProbe probe = (SerializedHDReflectionProbe)p;
//EditorGUILayout.PropertyField(p.refreshMode, CoreEditorUtils.GetContent("Refresh Mode|Controls how this probe refreshes in the Player"));
//EditorGUILayout.PropertyField(probe.timeSlicingMode, CoreEditorUtils.GetContent("Time Slicing|If enabled this probe will update over several frames, to help reduce the impact on the frame rate"));
EditorGUILayout.PropertyField(p.refreshMode, CoreEditorUtils.GetContent("Refresh Mode|Controls how this probe refreshes in the Player"));
EditorGUILayout.PropertyField(p.timeSlicingMode, CoreEditorUtils.GetContent("Time Slicing|If enabled this probe will update over several frames, to help reduce the impact on the frame rate"));
}
#endregion

102
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeUI.cs


namespace UnityEditor.Experimental.Rendering.HDPipeline
{
internal partial class HDReflectionProbeUI : HDProbeUI
internal partial class HDReflectionProbeUI : BaseUI<SerializedHDReflectionProbe>
internal HDReflectionProbeUI()
{
toolBars = new[] { ToolBar.InfluenceShape | ToolBar.Blend | ToolBar.NormalBlend, ToolBar.CapturePosition };
}
const int k_AnimBoolSingleFieldCount = 4;
static readonly int k_ReflectionProbeModeCount = Enum.GetValues(typeof(ReflectionProbeMode)).Length;
static readonly int k_ReflectionInfluenceShapeCount = Enum.GetValues(typeof(InfluenceShape)).Length;
static readonly int k_AnimBoolsCount = k_ReflectionProbeModeCount + k_ReflectionInfluenceShapeCount + k_AnimBoolSingleFieldCount;
public InfluenceVolumeUI influenceVolume = new InfluenceVolumeUI();
[Flags]
public enum Operation

public void ClearOperation(Operation op) { operations &= ~op; }
public void AddOperation(Operation op) { operations |= op; }
public Gizmo6FacesBox alternativeBoxInfluenceHandle;
public Gizmo6FacesBoxContained alternativeBoxBlendHandle;
public Gizmo6FacesBoxContained alternativeBoxBlendNormalHandle;
public SphereBoundsHandle sphereInfluenceHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereBlendHandle = new SphereBoundsHandle();
public SphereBoundsHandle sphereBlendNormalHandle = new SphereBoundsHandle();
public AnimBool isSectionExpandedProxyVolume { get { return m_AnimBools[0]; } }
public AnimBool isSectionExpandedInfluenceVolume { get { return m_AnimBools[1]; } }
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[2]; } }
public AnimBool isSectionExpandedAdditional { get { return m_AnimBools[3]; } }
public bool HasAndClearOperation(Operation op)
{
var has = HasOperation(op);

public bool sceneViewEditing
{
get { return HDProbeUI.IsProbeEditMode(EditMode.editMode) && EditMode.IsOwner(owner); }
get { return HDReflectionProbeEditor.IsReflectionProbeEditMode(EditMode.editMode) && EditMode.IsOwner(owner); }
}
public HDReflectionProbeUI()
: base(k_AnimBoolsCount)
{
isSectionExpandedProxyVolume.value = true;
isSectionExpandedCaptureSettings.value = true;
isSectionExpandedInfluenceVolume.value = true;
isSectionExpandedAdditional.value = false;
alternativeBoxInfluenceHandle = new Gizmo6FacesBox(monochromeFace:true, monochromeSelectedFace:true);
alternativeBoxBlendHandle = new Gizmo6FacesBoxContained(alternativeBoxInfluenceHandle, monochromeFace:true, monochromeSelectedFace:true);
alternativeBoxBlendNormalHandle = new Gizmo6FacesBoxContained(alternativeBoxInfluenceHandle, monochromeFace:true, monochromeSelectedFace:true);
Color[] handleColors = new Color[]
{
HDReflectionProbeEditor.k_handlesColor[0][0],
HDReflectionProbeEditor.k_handlesColor[0][1],
HDReflectionProbeEditor.k_handlesColor[0][2],
HDReflectionProbeEditor.k_handlesColor[1][0],
HDReflectionProbeEditor.k_handlesColor[1][1],
HDReflectionProbeEditor.k_handlesColor[1][2]
};
alternativeBoxInfluenceHandle.handleColors = handleColors;
alternativeBoxBlendHandle.handleColors = handleColors;
alternativeBoxBlendNormalHandle.handleColors = handleColors;
alternativeBoxInfluenceHandle.faceColors = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorExtent };
alternativeBoxInfluenceHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorExtentFace };
alternativeBoxBlendHandle.faceColors = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceBlend };
alternativeBoxBlendHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceBlendFace };
alternativeBoxBlendNormalHandle.faceColors = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceNormalBlend };
alternativeBoxBlendNormalHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceNormalBlendFace };
SetModeTarget(data.mode.hasMultipleDifferentValues ? -1 : data.mode.intValue);
SetShapeTarget(data.influenceVolume.shape.hasMultipleDifferentValues ? -1 : data.influenceVolume.shape.intValue);
influenceVolume.Update();
public AnimBool IsSectionExpandedMode(ReflectionProbeMode mode)
{
return m_AnimBools[k_AnimBoolSingleFieldCount + (int)mode];
}
public void SetModeTarget(int value)
{
for (var i = 0; i < k_ReflectionProbeModeCount; i++)
GetReflectionProbeModeBool(i).target = i == value;
}
public AnimBool IsSectionExpandedShape(InfluenceShape value)
{
return m_AnimBools[k_AnimBoolSingleFieldCount + k_ReflectionProbeModeCount + (int)value];
}
public void SetShapeTarget(int value)
{
for (var i = 0; i < k_ReflectionInfluenceShapeCount; i++)
GetReflectionInfluenceShapeBool(i).target = i == value;
}
}
AnimBool GetReflectionProbeModeBool(int i)
{
return m_AnimBools[k_AnimBoolSingleFieldCount + i];
}
AnimBool GetReflectionInfluenceShapeBool(int i)
{
return m_AnimBools[k_AnimBoolSingleFieldCount + k_ReflectionProbeModeCount + i];
}
public override void Reset(SerializedHDReflectionProbe data, UnityAction repaint)
{
influenceVolume.Reset(data.influenceVolume, repaint);
base.Reset(data, repaint);
}
}
}

89
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs


using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
using Object = UnityEngine.Object;
using System.Linq;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{

[CanEditMultipleObjects]
class PlanarReflectionProbeEditor : HDProbeEditor
class PlanarReflectionProbeEditor : Editor
static Dictionary<PlanarReflectionProbe, PlanarReflectionProbeUI> s_StateMap = new Dictionary<PlanarReflectionProbe, PlanarReflectionProbeUI>();
const float k_PreviewHeight = 128;
public static bool TryGetUIStateFor(PlanarReflectionProbe p, out PlanarReflectionProbeUI r)
{
return s_StateMap.TryGetValue(p, out r);
}
[DidReloadScripts]
static void DidReloadScripts()
{

}
}
internal override HDProbe GetTarget(Object editorTarget)
SerializedPlanarReflectionProbe m_SerializedAsset;
PlanarReflectionProbeUI m_UIState = new PlanarReflectionProbeUI();
PlanarReflectionProbeUI[] m_UIHandleState;
PlanarReflectionProbe[] m_TypedTargets;
List<Texture> m_PreviewedTextures = new List<Texture>();
void OnEnable()
return editorTarget as HDProbe;
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, null);
s_StateMap[m_TypedTargets[i]] = m_UIHandleState[i];
}
PlanarReflectionProbe probe = (PlanarReflectionProbe)target;
probe.influenceVolume.Init(probe);
protected override void Draw(HDProbeUI s, SerializedHDProbe serialized, Editor owner)
void OnDisable()
PlanarReflectionProbeUI.Inspector.Draw(s, serialized, owner);
for (var i = 0; i < m_TypedTargets.Length; i++)
s_StateMap.Remove(m_TypedTargets[i]);
protected override void OnEnable()
public override void OnInspectorGUI()
m_SerializedHDProbe = new SerializedPlanarReflectionProbe(serializedObject);
base.OnEnable();
var s = m_UIState;
var d = m_SerializedAsset;
var o = this;
s.Update();
d.Update();
PlanarReflectionProbeUI.Inspector.Draw(s, d, o);
PlanarReflectionProbe probe = (PlanarReflectionProbe)target;
probe.influenceVolume.Init(probe);
d.Apply();
protected override void OnSceneGUI()
void OnSceneGUI()
base.OnSceneGUI();
for (var i = 0; i < m_TypedTargets.Length; i++)
{
m_UIHandleState[i].Update();
m_UIHandleState[i].influenceVolume.showInfluenceHandles = m_UIState.influenceVolume.isSectionExpandedShape.target;
m_UIHandleState[i].showCaptureHandles = m_UIState.isSectionExpandedCaptureSettings.target;
PlanarReflectionProbeUI.DrawHandles(m_UIHandleState[i], m_TypedTargets[i], this);
}
const float k_PreviewHeight = 128;
List<Texture> m_PreviewedTextures = new List<Texture>();
foreach(PlanarReflectionProbe p in m_TypedTargets)
for (var i = 0; i < m_TypedTargets.Length; i++)
var p = m_TypedTargets[i];
if (p.texture == null)
continue;

if (Event.current.type == EventType.Repaint)
{
var c = new Rect(cameraRect);
foreach(PlanarReflectionProbe p in m_TypedTargets)
for (var i = 0; i < m_TypedTargets.Length; i++)
var p = m_TypedTargets[i];
if (p.texture == null)
continue;

public override bool HasPreviewGUI()
{
foreach(PlanarReflectionProbe p in m_TypedTargets)
for (var i = 0; i < m_TypedTargets.Length; i++)
if (p.texture != null)
if (m_TypedTargets[i].texture != null)
return true;
}
return false;

public override void OnPreviewGUI(Rect r, GUIStyle background)
{
m_PreviewedTextures.Clear();
foreach (PlanarReflectionProbe p in m_TypedTargets)
{
m_PreviewedTextures.Add(p.texture);
}
for (var i = 0; i < m_TypedTargets.Length; i++)
m_PreviewedTextures.Add(m_TypedTargets[i].texture);
for (var i = 0; i < m_PreviewedTextures.Count; i++)
for (var i = 0; i < m_TypedTargets.Length; i++)
{
var row = i / rowSize;
var col = i % rowSize;

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs.meta


fileFormatVersion: 2
guid: 01721b4a922692f4d80ef10751baa70c
guid: 7f189b572cf7bf04d9f1976dcc75c942
MonoImporter:
externalObjects: {}
serializedVersion: 2

212
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs


using System;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
#if false
static readonly Color k_GizmoCamera = new Color(233f / 255f, 233f / 255f, 233f / 255f, 128f / 255f);
#endif
internal static void DrawHandles(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
public static void DrawHandles(PlanarReflectionProbeUI s, PlanarReflectionProbe d, Editor o)
PlanarReflectionProbe probe = d.target;
HDProbeUI.DrawHandles(s, d, o);
var mat = Matrix4x4.TRS(d.transform.position, d.transform.rotation, Vector3.one);
if (probe.useMirrorPlane)
switch (EditMode.editMode)
var m = Handles.matrix;
var mat = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one*1.5f);
using (new Handles.DrawingScope(k_GizmoMirrorPlaneCamera, mat))
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 EditMirrorPosition:
Handles.ArrowHandleCap(
0,
probe.captureMirrorPlaneLocalPosition,
Quaternion.LookRotation(probe.captureMirrorPlaneLocalNormal),
HandleUtility.GetHandleSize(probe.captureMirrorPlaneLocalPosition),
Event.current.type
);
EditorGUI.BeginChangeCheck();
var m = Handles.matrix;
Handles.matrix = mat;
var p = Handles.PositionHandle(d.captureMirrorPlaneLocalPosition, d.transform.rotation);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(d, "Translate Mirror Plane");
d.captureMirrorPlaneLocalPosition = p;
EditorUtility.SetDirty(d);
}
Handles.matrix = m;
break;
}
case EditMirrorRotation:
{
EditorGUI.BeginChangeCheck();
var m = Handles.matrix;
Handles.matrix = mat;
var q = Quaternion.LookRotation(d.captureMirrorPlaneLocalNormal, Vector3.up);
q = Handles.RotationHandle(q, d.captureMirrorPlaneLocalPosition);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(d, "Rotate Mirror Plane");
d.captureMirrorPlaneLocalNormal = q * Vector3.forward;
EditorUtility.SetDirty(d);
}
Handles.matrix = m;
break;
}
case EditCenter:
{
EditorGUI.BeginChangeCheck();
var m = Handles.matrix;
Handles.matrix = mat;
var p = Handles.PositionHandle(d.captureLocalPosition, d.transform.rotation);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(d, "Translate Capture Position");
d.captureLocalPosition = p;
EditorUtility.SetDirty(d);
}
Handles.matrix = m;
break;
if (d.useMirrorPlane)
{
var m = Handles.matrix;
Handles.matrix = mat;
Handles.color = k_GizmoMirrorPlaneCamera;
Handles.ArrowHandleCap(
0,
d.captureMirrorPlaneLocalPosition,
Quaternion.LookRotation(d.captureMirrorPlaneLocalNormal),
HandleUtility.GetHandleSize(d.captureMirrorPlaneLocalPosition),
Event.current.type
);
Handles.matrix = m;
}
if (d.proxyVolume != null)
ReflectionProxyVolumeComponentUI.DrawHandles_EditNone(s.reflectionProxyVolume, d.proxyVolume);
internal static void DrawGizmos(PlanarReflectionProbe d, GizmoType gizmoType)
public static void DrawGizmos(PlanarReflectionProbe d, GizmoType gizmoType)
HDProbeUI.DrawGizmos(d, gizmoType);
HDProbeUI s;
if (!HDProbeEditor.TryGetUIStateFor(d, out s))
PlanarReflectionProbeUI s;
if (!PlanarReflectionProbeEditor.TryGetUIStateFor(d, out s))
if (s.showCaptureHandles || EditMode.editMode == EditCenter)
DrawGizmos_CaptureFrustrum(d);
var mat = Matrix4x4.TRS(d.transform.position, d.transform.rotation, Vector3.one);
if (d.useMirrorPlane)
DrawGizmos_CaptureMirror(d);
switch (EditMode.editMode)
{
case EditBaseShape:
InfluenceVolumeUI.DrawGizmos(
s.influenceVolume,
d.influenceVolume,
mat,
InfluenceVolumeUI.HandleType.Base,
InfluenceVolumeUI.HandleType.All);
break;
case EditInfluenceShape:
InfluenceVolumeUI.DrawGizmos(
s.influenceVolume,
d.influenceVolume,
mat,
InfluenceVolumeUI.HandleType.Influence,
InfluenceVolumeUI.HandleType.All);
break;
case EditInfluenceNormalShape:
InfluenceVolumeUI.DrawGizmos(
s.influenceVolume,
d.influenceVolume,
mat,
InfluenceVolumeUI.HandleType.InfluenceNormal,
InfluenceVolumeUI.HandleType.All);
break;
default:
{
var showedHandles = s.influenceVolume.showInfluenceHandles
? InfluenceVolumeUI.HandleType.All
: InfluenceVolumeUI.HandleType.Base;
InfluenceVolumeUI.DrawGizmos(
s.influenceVolume,
d.influenceVolume,
mat,
InfluenceVolumeUI.HandleType.None,
showedHandles);
break;
}
}
if (d.proxyVolume != null)
ReflectionProxyVolumeComponentUI.DrawGizmos_EditNone(s.reflectionProxyVolume, d.proxyVolume);
var showFrustrum = s.showCaptureHandles
|| EditMode.editMode == EditCenter;
var showCaptureMirror = d.useMirrorPlane
|| EditMode.editMode == EditMirrorPosition
|| EditMode.editMode == EditMirrorRotation;
if (showFrustrum)
DrawGizmos_CaptureFrustrum(s, d);
if (showCaptureMirror)
DrawGizmos_CaptureMirror(s, d);
static void DrawGizmos_CaptureMirror(PlanarReflectionProbe d)
static void DrawGizmos_CaptureMirror(PlanarReflectionProbeUI s, PlanarReflectionProbe d)
{
var c = Gizmos.color;
var m = Gizmos.matrix;

Gizmos.color = c;
}
static void DrawGizmos_CaptureFrustrum(PlanarReflectionProbe d)
static void DrawGizmos_CaptureFrustrum(PlanarReflectionProbeUI s, PlanarReflectionProbe d)
{
var viewerCamera = Camera.current;
var c = Gizmos.color;

out aspect, out fov, out clearFlags, out backgroundColor,
out worldToCameraRHS, out projection,
out capturePosition, out captureRotation, viewerCamera);
#if false
// TODO: fix frustrum drawing
var viewProj = projection * worldToCameraRHS;
var invViewProj = viewProj.inverse;
var near = new[]
{
new Vector3(-1, -1, -1),
new Vector3(-1, 1, -1),
new Vector3(1, 1, -1),
new Vector3(1, -1, -1),
};
var far = new[]
{
new Vector3(-1, -1, 1),
new Vector3(-1, 1, 1),
new Vector3(1, 1, 1),
new Vector3(1, -1, 1),
};
for (var i = 0; i < near.Length; ++i)
{
var p = invViewProj * new Vector4(near[i].x, near[i].y, near[i].z, 1);
var w = Mathf.Abs(p.w);
near[i].Set(p.x / w, p.y / w, p.z / w);
}
for (var i = 0; i < far.Length; ++i)
{
var p = invViewProj * new Vector4(far[i].x, far[i].y, far[i].z, 1);
var w = Mathf.Abs(p.w);
far[i].Set(p.x / w, p.y / w, p.z / w);
}
Gizmos.color = k_GizmoCamera;
for (var i = 0; i < 4; ++i)
{
Gizmos.DrawLine(near[i], near[(i + 1) % 4]);
Gizmos.DrawLine(far[i], far[(i + 1) % 4]);
Gizmos.DrawLine(near[i], far[i]);
}
Gizmos.matrix = m;
#endif
Gizmos.DrawSphere(capturePosition, HandleUtility.GetHandleSize(capturePosition) * 0.2f);
Gizmos.color = c;

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Handles.cs.meta


fileFormatVersion: 2
guid: a5aea6d1bf1e73b4ab7307bcab55151d
guid: 8ee668677cd59784d8fb06a531b49a77
MonoImporter:
externalObjects: {}
serializedVersion: 2

121
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.cs


using System;
using UnityEditor.AnimatedValues;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
using CED = CoreEditorDrawer<HDProbeUI, SerializedHDProbe>;
partial class PlanarReflectionProbeUI : BaseUI<SerializedPlanarReflectionProbe>
{
const int k_AnimBoolFields = 6;
static readonly int k_ReflectionProbeModeModeCount = Enum.GetValues(typeof(ReflectionProbeMode)).Length;
static readonly int k_AnimBoolTotal = k_AnimBoolFields + k_ReflectionProbeModeModeCount;
public InfluenceVolumeUI influenceVolume = new InfluenceVolumeUI();
public FrameSettingsUI frameSettings = new FrameSettingsUI();
public ReflectionProxyVolumeComponentUI reflectionProxyVolume = new ReflectionProxyVolumeComponentUI();
public AnimBool isSectionExpandedInfluenceSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount]; } }
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 1]; } }
partial class PlanarReflectionProbeUI : HDProbeUI
{
static readonly GUIContent overrideFieldOfViewContent = CoreEditorUtils.GetContent("Override Field Of View");
static readonly GUIContent fieldOfViewSolidAngleContent = CoreEditorUtils.GetContent("Field Of View");
public AnimBool isSectionExpandedCaptureMirrorSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 2]; } }
public AnimBool isSectionExpandedCaptureStaticSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 3]; } }
public AnimBool isSectionExpendedProxyVolume { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 4]; } }
public AnimBool isSectionExpendedAdditionalSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 5]; } }
public static CED.IDrawer Inspector;
public static readonly CED.IDrawer SectionFoldoutCaptureSettings = CED.FoldoutGroup(
"Capture Settings",
(s, d, o) => s.isSectionExpandedCaptureSettings,
FoldoutOption.Indent,
CED.Action(Drawer_SectionCaptureSettings)
);
public bool showCaptureHandles { get; set; }
static PlanarReflectionProbeUI()
public PlanarReflectionProbeUI()
: base(k_AnimBoolTotal)
Inspector = CED.Group(
CED.Action(Drawer_Toolbars),
CED.space,
ProxyVolumeSettings,
CED.Select(
(s, d, o) => s.influenceVolume,
(s, d, o) => d.influenceVolume,
InfluenceVolumeUI.SectionFoldoutShapePlanar
),
CED.Action(Drawer_DifferentShapeError),
SectionFoldoutCaptureSettings,
SectionFoldoutAdditionalSettings,
CED.Select(
(s, d, o) => s.frameSettings,
(s, d, o) => d.frameSettings,
FrameSettingsUI.Inspector
),
CED.space,
CED.Action(Drawer_SectionBakeButton)
);
isSectionExpandedInfluenceSettings.value = true;
isSectionExpandedCaptureSettings.value = true;
isSectionExpendedProxyVolume.value = true;
isSectionExpendedAdditionalSettings.value = false;
protected static void Drawer_SectionCaptureSettings(HDProbeUI s, SerializedHDProbe d, Editor o)
public AnimBool IsSectionExpandedReflectionProbeMode(ReflectionProbeMode mode)
SerializedPlanarReflectionProbe serialized = (SerializedPlanarReflectionProbe)d;
var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
GUI.enabled = false;
EditorGUILayout.LabelField(
CoreEditorUtils.GetContent("Probe Texture Size (Set By HDRP)"),
CoreEditorUtils.GetContent(hdrp.renderPipelineSettings.lightLoopSettings.planarReflectionTextureSize.ToString()),
EditorStyles.label);
EditorGUILayout.Toggle(
CoreEditorUtils.GetContent("Probe Compression (Set By HDRP)"),
hdrp.renderPipelineSettings.lightLoopSettings.planarReflectionCacheCompressed);
GUI.enabled = true;
bool on = serialized.overrideFieldOfView.boolValue;
EditorGUI.BeginChangeCheck();
on = EditorGUILayout.Toggle(overrideFieldOfViewContent, on);
if (on)
{
serialized.fieldOfViewOverride.floatValue = EditorGUILayout.FloatField(fieldOfViewSolidAngleContent, serialized.fieldOfViewOverride.floatValue);
}
if (EditorGUI.EndChangeCheck())
{
serialized.overrideFieldOfView.boolValue = on;
serialized.Apply();
}
//GUI.enabled = false;
//EditorGUILayout.LabelField(resolutionContent, CoreEditorUtils.GetContent(((int)hdrp.GetRenderPipelineSettings().lightLoopSettings.reflectionCubemapSize).ToString()));
//EditorGUILayout.LabelField(shadowDistanceContent, EditorStyles.label);
//EditorGUILayout.LabelField(cullingMaskContent, EditorStyles.label);
//EditorGUILayout.LabelField(useOcclusionCullingContent, EditorStyles.label);
//EditorGUILayout.LabelField(nearClipCullingContent, EditorStyles.label);
//EditorGUILayout.LabelField(farClipCullingContent, EditorStyles.label);
//GUI.enabled = true;
return m_AnimBools[(int)mode];
internal PlanarReflectionProbeUI()
public override void Reset(SerializedPlanarReflectionProbe data, UnityAction repaint)
toolBars = new[] { ToolBar.InfluenceShape | ToolBar.Blend };
reflectionProxyVolume.Reset(data.reflectionProxyVolume, repaint);
frameSettings.Reset(data.frameSettings, repaint);
influenceVolume.Reset(data.influenceVolume, repaint);
base.Reset(data, repaint);
SerializedPlanarReflectionProbe serialized = data as SerializedPlanarReflectionProbe;
isSectionExpandedCaptureMirrorSettings.target = serialized.isMirrored;
isSectionExpandedCaptureStaticSettings.target = !serialized.isMirrored;
for (var i = 0; i < k_ReflectionProbeModeModeCount; i++)
m_AnimBools[i].target = i == data.mode.intValue;
isSectionExpandedCaptureMirrorSettings.target = data.isMirrored;
isSectionExpandedCaptureStaticSettings.target = !data.isMirrored;
reflectionProxyVolume.Update();
frameSettings.Update();
influenceVolume.Update();
base.Update();
}
}

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.cs.meta


fileFormatVersion: 2
guid: d6d4b9e119caf434784239e203f89e05
guid: f23cf1efede7335468bfa23bd1838cd2
MonoImporter:
externalObjects: {}
serializedVersion: 2

109
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDReflectionProbe.cs


namespace UnityEditor.Experimental.Rendering.HDPipeline
{
internal class SerializedHDReflectionProbe : SerializedHDProbe
internal class SerializedHDReflectionProbe
internal SerializedObject serializedLegacyObject;
internal ReflectionProbe target;
internal HDAdditionalReflectionData targetData;
internal SerializedObject so;
internal SerializedObject addso;
internal SerializedProperty mode;
internal SerializedProperty refreshMode;
internal SerializedProperty intensityMultiplier;
internal SerializedProperty legacyBlendDistance;
internal SerializedProperty boxSize;
internal SerializedProperty boxOffset;
internal SerializedProperty resolution;
internal SerializedProperty shadowDistance;
internal SerializedProperty cullingMask;
internal SerializedProperty useOcclusionCulling;
internal SerializedProperty nearClip;
internal SerializedProperty farClip;
internal SerializedProperty boxProjection;
internal SerializedProperty weight;
internal SerializedProperty multiplier;
SerializedProperty legacyBlendDistance;
SerializedProperty legacySize;
SerializedProperty legacyOffset;
SerializedProperty legacyMode;
internal SerializedProperty proxyVolumeComponent;
internal new HDAdditionalReflectionData target { get { return serializedObject.targetObject as HDAdditionalReflectionData; } }
internal ReflectionProbe targetLegacy { get { return serializedLegacyObject.targetObject as ReflectionProbe; } }
internal SerializedInfluenceVolume influenceVolume;
public SerializedHDReflectionProbe(SerializedObject legacyProbe, SerializedObject additionalData) : base(additionalData)
public SerializedHDReflectionProbe(SerializedObject so, SerializedObject addso)
serializedLegacyObject = legacyProbe;
this.so = so;
this.addso = addso;
proxyVolumeComponent = addso.Find((HDAdditionalReflectionData d) => d.proxyVolume);
influenceVolume = new SerializedInfluenceVolume(addso.Find((HDAdditionalReflectionData d) => d.influenceVolume));
target = (ReflectionProbe)so.targetObject;
targetData = target.GetComponent<HDAdditionalReflectionData>();
mode = so.FindProperty("m_Mode");
customBakedTexture = so.FindProperty("m_CustomBakedTexture");
renderDynamicObjects = so.FindProperty("m_RenderDynamicObjects");
refreshMode = so.FindProperty("m_RefreshMode");
timeSlicingMode = so.FindProperty("m_TimeSlicingMode");
intensityMultiplier = so.FindProperty("m_IntensityMultiplier");
boxSize = so.FindProperty("m_BoxSize");
boxOffset = so.FindProperty("m_BoxOffset");
resolution = so.FindProperty("m_Resolution");
shadowDistance = so.FindProperty("m_ShadowDistance");
cullingMask = so.FindProperty("m_CullingMask");
useOcclusionCulling = so.FindProperty("m_UseOcclusionCulling");
nearClip = so.FindProperty("m_NearClip");
farClip = so.FindProperty("m_FarClip");
boxProjection = so.FindProperty("m_BoxProjection");
legacyBlendDistance = so.FindProperty("m_BlendDistance");
customBakedTexture = legacyProbe.FindProperty("m_CustomBakedTexture");
renderDynamicObjects = legacyProbe.FindProperty("m_RenderDynamicObjects");
timeSlicingMode = legacyProbe.FindProperty("m_TimeSlicingMode");
legacySize = legacyProbe.FindProperty("m_BoxSize");
legacyOffset = legacyProbe.FindProperty("m_BoxOffset");
resolution = legacyProbe.FindProperty("m_Resolution");
shadowDistance = legacyProbe.FindProperty("m_ShadowDistance");
cullingMask = legacyProbe.FindProperty("m_CullingMask");
useOcclusionCulling = legacyProbe.FindProperty("m_UseOcclusionCulling");
nearClip = legacyProbe.FindProperty("m_NearClip");
farClip = legacyProbe.FindProperty("m_FarClip");
legacyBlendDistance = legacyProbe.FindProperty("m_BlendDistance");
legacyMode = legacyProbe.FindProperty("m_Mode");
weight = addso.Find((HDAdditionalReflectionData d) => d.weight);
multiplier = addso.Find((HDAdditionalReflectionData d) => d.multiplier);
internal override void Update()
public void Update()
serializedLegacyObject.Update();
base.Update();
//check if the transform have been rotated
if (legacyOffset.vector3Value != ((Component)serializedLegacyObject.targetObject).transform.rotation * influenceVolume.offset.vector3Value)
{
//call the offset setter as it will update legacy reflection probe
((HDAdditionalReflectionData)serializedObject.targetObject).influenceVolume.offset = influenceVolume.offset.vector3Value;
}
so.Update();
addso.Update();
//InfluenceVolume does not have Update. Add it here if it have in the futur.
internal override void Apply()
public void Apply()
//sync size with legacy reflection probe
switch(target.influenceVolume.shape)
{
case InfluenceShape.Box:
legacySize.vector3Value = influenceVolume.boxSize.vector3Value;
break;
case InfluenceShape.Sphere:
legacySize.vector3Value = Vector3.one * influenceVolume.sphereRadius.floatValue;
break;
}
// Sync mode with legacy reflection probe
legacyMode.intValue = mode.intValue;
serializedLegacyObject.ApplyModifiedProperties();
base.Apply();
//serializedObject.ApplyModifiedProperties(); //done in base methode
so.ApplyModifiedProperties();
addso.ApplyModifiedProperties();
}
}
}

81
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedPlanarReflectionProbe.cs


namespace UnityEditor.Experimental.Rendering.HDPipeline
{
internal class SerializedPlanarReflectionProbe : SerializedHDProbe
internal class SerializedPlanarReflectionProbe
internal SerializedObject serializedObject;
internal SerializedProperty proxyVolumeReference;
internal SerializedReflectionProxyVolumeComponent reflectionProxyVolume;
internal SerializedInfluenceVolume influenceVolume;
internal SerializedProperty captureNearPlane;
internal SerializedProperty captureFarPlane;
internal SerializedProperty weight;
internal SerializedProperty multiplier;
internal SerializedProperty mode;
internal SerializedProperty refreshMode;
internal new PlanarReflectionProbe target { get { return serializedObject.targetObject as PlanarReflectionProbe; } }
internal SerializedFrameSettings frameSettings;
internal PlanarReflectionProbe target { get { return serializedObject.targetObject as PlanarReflectionProbe; } }
internal bool isMirrored
{

}
}
internal SerializedPlanarReflectionProbe(SerializedObject serializedObject) : base(serializedObject)
internal SerializedPlanarReflectionProbe(SerializedObject serializedObject)
this.serializedObject = serializedObject;
proxyVolumeReference = serializedObject.Find((PlanarReflectionProbe p) => p.proxyVolume);
influenceVolume = new SerializedInfluenceVolume(serializedObject.Find((PlanarReflectionProbe p) => p.influenceVolume));
nearClip = serializedObject.Find((PlanarReflectionProbe p) => p.captureNearPlane);
farClip = serializedObject.Find((PlanarReflectionProbe p) => p.captureFarPlane);
captureNearPlane = serializedObject.Find((PlanarReflectionProbe p) => p.captureNearPlane);
captureFarPlane = serializedObject.Find((PlanarReflectionProbe p) => p.captureFarPlane);
weight = serializedObject.Find((PlanarReflectionProbe p) => p.weight);
multiplier = serializedObject.Find((PlanarReflectionProbe p) => p.multiplier);
mode = serializedObject.Find((PlanarReflectionProbe p) => p.mode);
refreshMode = serializedObject.Find((PlanarReflectionProbe p) => p.refreshMode);
influenceVolume.editorSimplifiedModeBlendNormalDistance.floatValue = 0;
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++)
{
var p = ((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolume;
if (p != null)
objs.Add(p);
}
internal override void Update()
reflectionProxyVolume = objs.Count > 0
? new SerializedReflectionProxyVolumeComponent(new SerializedObject(objs.ToArray()))
: null;
}
public void Update()
base.Update();
serializedObject.Update();
//temporarily force value until other mode are supported
var updateProxyVolume = reflectionProxyVolume != null
&& serializedObject.targetObjects.Length != reflectionProxyVolume.serializedObject.targetObjects.Length;
if (!updateProxyVolume && reflectionProxyVolume != null)
{
var proxyVolumeTargets = reflectionProxyVolume.serializedObject.targetObjects;
for (var i = 0; i < serializedObject.targetObjects.Length; i++)
{
if (proxyVolumeTargets[i] != ((PlanarReflectionProbe)serializedObject.targetObjects[i]).proxyVolume)
{
updateProxyVolume = true;
break;
}
}
}
if (updateProxyVolume)
InstantiateProxyVolume(serializedObject);
public void Apply()
{
serializedObject.ApplyModifiedProperties();
if (reflectionProxyVolume != null)
reflectionProxyVolume.Apply();
}
}
}

163
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Drawers.cs


partial class InfluenceVolumeUI
{
//[TODO: planar / non planar will be redone in next PR]
internal static readonly CED.IDrawer SectionFoldoutShapePlanar;
internal static readonly CED.IDrawer SectionFoldoutShape;
static readonly CED.IDrawer SectionShapeBoxPlanar = CED.Action((s, p, o) => Drawer_SectionShapeBox( s, p, o, false, false, false));
static readonly CED.IDrawer SectionShapeBox = CED.Action((s, p, o) => Drawer_SectionShapeBox(s, p, o, true, true, true));
static readonly CED.IDrawer SectionShapeSpherePlanar = CED.Action((s, p, o) => Drawer_SectionShapeSphere(s, p, o, false, false));
static readonly CED.IDrawer SectionShapeSphere = CED.Action((s, p, o) => Drawer_SectionShapeSphere(s, p, o, true, true));
public static readonly CED.IDrawer SectionFoldoutShapePlanar;
public static readonly CED.IDrawer SectionFoldoutShape;
public static readonly CED.IDrawer SectionShapeBoxPlanar = CED.Action((s, p, o) => Drawer_SectionShapeBox(s,p,o,false,false));
public static readonly CED.IDrawer SectionShapeBox = CED.Action((s, p, o) => Drawer_SectionShapeBox(s, p, o, true, true));
public static readonly CED.IDrawer SectionShapeSpherePlanar = CED.Action((s, p, o) => Drawer_SectionShapeSphere(s, p, o, false, false));
public static readonly CED.IDrawer SectionShapeSphere = CED.Action((s, p, o) => Drawer_SectionShapeSphere(s, p, o, true, true));
influenceVolumeHeader,
"Influence Volume",
(s, d, o) => s.isSectionExpandedShape,
FoldoutOption.Indent,
CED.Action(Drawer_InfluenceAdvancedSwitch),

);
SectionFoldoutShape = CED.Group(
CED.FoldoutGroup(
influenceVolumeHeader,
"Influence Volume",
(s, d, o) => s.isSectionExpandedShape,
FoldoutOption.Indent,
CED.Action(Drawer_InfluenceAdvancedSwitch),

static void Drawer_FieldShapeType(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o)
{
EditorGUILayout.PropertyField(d.shape, shapeContent);
EditorGUILayout.PropertyField(d.shape, _.GetContent("Shape Type"));
}
static void Drawer_InfluenceAdvancedSwitch(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor owner)

GUILayout.FlexibleSpace();
if (d.shape.intValue == (int)InfluenceShape.Sphere)
{
GUI.enabled = false;
}
advanced = !GUILayout.Toggle(!advanced, normalModeContent, EditorStyles.miniButtonLeft, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
advanced = GUILayout.Toggle(advanced, advancedModeContent, EditorStyles.miniButtonRight, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
advanced = !GUILayout.Toggle(!advanced, CoreEditorUtils.GetContent("Normal|Normal parameters mode (only change for box shape)."), EditorStyles.miniButtonLeft, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
advanced = GUILayout.Toggle(advanced, CoreEditorUtils.GetContent("Advanced|Advanced parameters mode (only change for box shape)."), EditorStyles.miniButtonRight, GUILayout.Width(60f), GUILayout.ExpandWidth(false));
s.boxInfluenceHandle.allHandleControledByOne = s.boxInfluenceNormalHandle.allHandleControledByOne = !advanced;
if (d.editorAdvancedModeEnabled.boolValue ^ advanced)
{

d.boxBlendDistanceNegative.vector3Value = d.editorAdvancedModeBlendDistanceNegative.vector3Value;
d.boxBlendNormalDistancePositive.vector3Value = d.editorAdvancedModeBlendNormalDistancePositive.vector3Value;
d.boxBlendNormalDistanceNegative.vector3Value = d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value;
d.boxSideFadePositive.vector3Value = d.editorAdvancedModeFaceFadePositive.vector3Value;
d.boxSideFadeNegative.vector3Value = d.editorAdvancedModeFaceFadeNegative.vector3Value;
d.boxSideFadeNegative.vector3Value = d.boxSideFadePositive.vector3Value = Vector3.one;
if (d.shape.intValue == (int)InfluenceShape.Sphere)
{
GUI.enabled = true;
}
static void Drawer_SectionShapeBox(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, bool drawOffset, bool drawNormal, bool drawFace)
static void Drawer_SectionShapeBox(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, bool drawOffset, bool drawNormal)
{
bool advanced = d.editorAdvancedModeEnabled.boolValue;
var maxFadeDistance = d.boxSize.vector3Value * 0.5f;

EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(d.boxSize, boxSizeContent);
if (EditorGUI.EndChangeCheck())
{
Vector3 blendPositive = d.boxBlendDistancePositive.vector3Value;
Vector3 blendNegative = d.boxBlendDistanceNegative.vector3Value;
Vector3 blendNormalPositive = d.boxBlendNormalDistancePositive.vector3Value;
Vector3 blendNormalNegative = d.boxBlendNormalDistanceNegative.vector3Value;
Vector3 size = d.boxSize.vector3Value;
for(int i = 0; i<3; ++i)
{
size[i] = Mathf.Max(0f, size[i]);
}
d.boxSize.vector3Value = size;
Vector3 halfSize = size * .5f;
for (int i = 0; i < 3; ++i)
{
blendPositive[i] = Mathf.Clamp(blendPositive[i], 0f, halfSize[i]);
blendNegative[i] = Mathf.Clamp(blendNegative[i], 0f, halfSize[i]);
blendNormalPositive[i] = Mathf.Clamp(blendNormalPositive[i], 0f, halfSize[i]);
blendNormalNegative[i] = Mathf.Clamp(blendNormalNegative[i], 0f, halfSize[i]);
}
d.boxBlendDistancePositive.vector3Value = blendPositive;
d.boxBlendDistanceNegative.vector3Value = blendNegative;
d.boxBlendNormalDistancePositive.vector3Value = blendNormalPositive;
d.boxBlendNormalDistanceNegative.vector3Value = blendNormalNegative;
if (d.editorAdvancedModeEnabled.boolValue)
{
d.editorAdvancedModeBlendDistancePositive.vector3Value = d.boxBlendDistancePositive.vector3Value;
d.editorAdvancedModeBlendDistanceNegative.vector3Value = d.boxBlendDistanceNegative.vector3Value;
d.editorAdvancedModeBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistancePositive.vector3Value;
d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value;
}
else
{
d.editorSimplifiedModeBlendDistance.floatValue = Mathf.Max(blendPositive.x, blendPositive.y, blendPositive.z, blendNegative.x, blendNegative.y, blendNegative.z);
d.boxBlendDistancePositive.vector3Value = d.boxBlendDistanceNegative.vector3Value = Vector3.one * d.editorSimplifiedModeBlendDistance.floatValue;
d.editorSimplifiedModeBlendNormalDistance.floatValue = Mathf.Max(blendNormalPositive.x, blendNormalPositive.y, blendNormalPositive.z, blendNormalNegative.x, blendNormalNegative.y, blendNormalNegative.z);
d.boxBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value = Vector3.one * d.editorSimplifiedModeBlendNormalDistance.floatValue;
}
}
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.InfluenceShape, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUILayout.PropertyField(d.boxSize, _.GetContent("Box Size"));
PlanarReflectionProbeUI.Drawer_ToolBarButton(0, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
Drawer_Offset(s, d, o);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(d.offset, _.GetContent("Offset"));
HDReflectionProbeUI.Drawer_ToolBarButton(3, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUILayout.EndHorizontal();
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
Drawer_AdvancedBlendDistance(d, false, maxFadeDistance, blendDistanceContent);
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.Blend, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 2 : 1) * (EditorGUIUtility.singleLineHeight + 3)));
Drawer_AdvancedBlendDistance(
d,
false,
maxFadeDistance,
CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes.")
);
PlanarReflectionProbeUI.Drawer_ToolBarButton(1, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3)));
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * 2f);
Drawer_AdvancedBlendDistance(d, true, maxFadeDistance, blendNormalDistanceContent);
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.NormalBlend, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 2 : 1) * (EditorGUIUtility.singleLineHeight + 3)));
Drawer_AdvancedBlendDistance(
d,
true,
maxFadeDistance,
CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes.")
);
PlanarReflectionProbeUI.Drawer_ToolBarButton(2, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight((advanced ? 3 : 1) * (EditorGUIUtility.singleLineHeight + 3)));
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * 2f);
if (advanced && drawFace)
if (advanced)
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
CoreEditorUtils.DrawVector6(faceFadeContent, d.editorAdvancedModeFaceFadePositive, d.editorAdvancedModeFaceFadeNegative, Vector3.zero, Vector3.one, HDReflectionProbeEditor.k_handlesColor);
if (EditorGUI.EndChangeCheck())
{
d.boxSideFadePositive.vector3Value = d.editorAdvancedModeFaceFadePositive.vector3Value;
d.boxSideFadeNegative.vector3Value = d.editorAdvancedModeFaceFadeNegative.vector3Value;
}
GUILayout.Space(28f + 9f); //add right margin for alignment
EditorGUILayout.EndHorizontal();
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * 2f);
CoreEditorUtils.DrawVector6(
CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap."),
d.boxSideFadePositive, d.boxSideFadeNegative, Vector3.zero, Vector3.one, HDReflectionProbeEditor.k_handlesColor);
}
}

distance = EditorGUILayout.FloatField(content, distance);
if (EditorGUI.EndChangeCheck())
{
distance = Mathf.Clamp(distance, 0f, Mathf.Max(maxBlendDistance.x, maxBlendDistance.y, maxBlendDistance.z));
Vector3 decal = Vector3.one * distance;
bdp.x = Mathf.Clamp(decal.x, 0f, maxBlendDistance.x);
bdp.y = Mathf.Clamp(decal.y, 0f, maxBlendDistance.y);

{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(d.sphereRadius, radiusContent);
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.InfluenceShape, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUILayout.PropertyField(d.sphereRadius, _.GetContent("Radius"));
PlanarReflectionProbeUI.Drawer_ToolBarButton(0, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
Drawer_Offset(s, d, o);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(d.offset, _.GetContent("Offset"));
HDReflectionProbeUI.Drawer_ToolBarButton(3, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.Space();

EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(d.sphereBlendDistance, blendDistanceContent);
EditorGUILayout.PropertyField(d.sphereBlendDistance, _.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."));
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.Blend, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3));
PlanarReflectionProbeUI.Drawer_ToolBarButton(1, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3));
EditorGUILayout.EndHorizontal();
if (drawNormal)

EditorGUILayout.PropertyField(d.sphereBlendNormalDistance, blendNormalDistanceContent);
EditorGUILayout.PropertyField(d.sphereBlendNormalDistance, _.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."));
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.NormalBlend, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3));
PlanarReflectionProbeUI.Drawer_ToolBarButton(2, o, GUILayout.ExpandHeight(true), GUILayout.Width(28f), GUILayout.MinHeight(22f), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight + 3));
}
static void Drawer_Offset(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o)
{
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(d.offset, offsetContent);
if(EditorGUI.EndChangeCheck())
{
//call the offset setter as it will update legacy reflection probe
HDProbeEditor editor = (HDProbeEditor)o;
InfluenceVolume influenceVolume = editor.GetTarget(editor.target).influenceVolume;
influenceVolume.offset = d.offset.vector3Value;
}
HDProbeUI.Drawer_ToolBarButton(HDProbeUI.ToolBar.CapturePosition, o, GUILayout.Width(28f), GUILayout.MinHeight(22f));
EditorGUILayout.EndHorizontal();
}
}
}

311
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Handles.cs


{
partial class InfluenceVolumeUI
{
public static void DrawHandles_EditBase(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
public static void DrawHandles_EditBase(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
using (new Handles.DrawingScope(k_GizmoThemeColorBase, matrix))
var mat = Handles.matrix;
var c = Handles.color;
Handles.matrix = matrix;
Handles.color = k_GizmoThemeColorBase;
switch (d.shape)
switch ((InfluenceShape)d.shape.intValue)
{
case InfluenceShape.Box:
DrawBoxHandle(s, d, o, sourceAsset, s.boxBaseHandle);
case InfluenceShape.Box:
{
var center = d.offset;
var size = d.boxSize;
DrawBoxHandle(
s, d, o, sourceAsset,
s1 => s1.boxBaseHandle,
ref center,
ref size);
d.offset = center;
d.boxSize = size;
case InfluenceShape.Sphere:
DrawSphereHandle(s, d, o, sourceAsset, s.sphereBaseHandle);
}
case InfluenceShape.Sphere:
{
var center = d.offset;
var radius = d.sphereRadius;
DrawSphereHandle(
s, d, o, sourceAsset,
s1 => s1.sphereBaseHandle,
ref center,
ref radius);
d.offset = center;
d.sphereRadius = radius;
}
}
Handles.matrix = mat;
Handles.color = c;
public static void DrawHandles_EditInfluence(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
public static void DrawHandles_EditInfluence(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
using (new Handles.DrawingScope(k_GizmoThemeColorInfluence, matrix))
var mat = Handles.matrix;
var c = Handles.color;
Handles.matrix = matrix;
Handles.color = k_GizmoThemeColorInfluence;
switch (d.shape)
switch ((InfluenceShape)d.shape.intValue)
{
case InfluenceShape.Box:
EditorGUI.BeginChangeCheck();
DrawBoxFadeHandle(s, d, o, sourceAsset, s.boxInfluenceHandle, d.boxBlendDistancePositive, d.boxBlendDistanceNegative);
if (EditorGUI.EndChangeCheck())
case InfluenceShape.Box:
{
var positive = d.boxBlendDistancePositive;
var negative = d.boxBlendDistanceNegative;
DrawBoxFadeHandle(
s, d, o, sourceAsset,
s1 => s1.boxInfluenceHandle,
d.offset, d.boxSize,
ref positive,
ref negative);
s.data.boxBlendDistancePositive.vector3Value = positive;
s.data.boxBlendDistanceNegative.vector3Value = negative;
//save advanced/simplified saved data
if (s.data.editorAdvancedModeEnabled.boolValue)
//save advanced/simplified saved data
if (d.editorAdvancedModeEnabled.boolValue)
{
d.editorAdvancedModeBlendDistancePositive.vector3Value = d.boxBlendDistancePositive.vector3Value;
d.editorAdvancedModeBlendDistanceNegative.vector3Value = d.boxBlendDistanceNegative.vector3Value;
}
else
{
d.editorSimplifiedModeBlendDistance.floatValue = d.boxBlendDistancePositive.vector3Value.x;
}
d.Apply();
s.data.editorAdvancedModeBlendDistancePositive.vector3Value = positive;
s.data.editorAdvancedModeBlendDistanceNegative.vector3Value = negative;
else
{
s.data.editorSimplifiedModeBlendDistance.floatValue = positive.x;
}
s.data.Apply();
case InfluenceShape.Sphere:
DrawSphereFadeHandle(s, d, o, sourceAsset, s.sphereInfluenceHandle, d.sphereBlendDistance);
}
case InfluenceShape.Sphere:
{
var fade = d.sphereBlendDistance;
DrawSphereFadeHandle(
s, d, o, sourceAsset,
s1 => s1.sphereInfluenceHandle,
d.offset, d.sphereRadius,
ref fade);
d.sphereBlendDistance = fade;
}
}
Handles.matrix = mat;
Handles.color = c;
public static void DrawHandles_EditInfluenceNormal(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
public static void DrawHandles_EditInfluenceNormal(InfluenceVolumeUI s, InfluenceVolume d, Editor o, Matrix4x4 matrix, Object sourceAsset)
using (new Handles.DrawingScope(k_GizmoThemeColorInfluenceNormal, matrix))
var mat = Handles.matrix;
var c = Handles.color;
Handles.matrix = matrix;
Handles.color = k_GizmoThemeColorInfluenceNormal;
switch (d.shape)
switch ((InfluenceShape)d.shape.intValue)
{
case InfluenceShape.Box:
EditorGUI.BeginChangeCheck();
DrawBoxFadeHandle(s, d, o, sourceAsset, s.boxInfluenceNormalHandle, d.boxBlendNormalDistancePositive, d.boxBlendNormalDistanceNegative);
if (EditorGUI.EndChangeCheck())
case InfluenceShape.Box:
{
Vector3 positive = d.boxBlendNormalDistancePositive;
Vector3 negative = d.boxBlendNormalDistanceNegative;
DrawBoxFadeHandle(
s, d, o, sourceAsset,
s1 => s1.boxInfluenceNormalHandle,
d.offset, d.boxSize,
ref positive,
ref negative);
s.data.boxBlendNormalDistancePositive.vector3Value = positive;
s.data.boxBlendNormalDistanceNegative.vector3Value = negative;
//save advanced/simplified saved data
if (s.data.editorAdvancedModeEnabled.boolValue)
{
s.data.editorAdvancedModeBlendNormalDistancePositive.vector3Value = positive;
s.data.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = negative;
}
else
//save advanced/simplified saved data
if (d.editorAdvancedModeEnabled.boolValue)
{
d.editorAdvancedModeBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistancePositive.vector3Value;
d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value;
}
else
{
d.editorSimplifiedModeBlendNormalDistance.floatValue = d.boxBlendNormalDistancePositive.vector3Value.x;
}
d.Apply();
s.data.editorSimplifiedModeBlendNormalDistance.floatValue = positive.x;
s.data.Apply();
case InfluenceShape.Sphere:
DrawSphereFadeHandle(s, d, o, sourceAsset, s.sphereInfluenceNormalHandle, d.sphereBlendNormalDistance);
}
case InfluenceShape.Sphere:
{
var fade = d.sphereBlendNormalDistance;
DrawSphereFadeHandle(
s, d, o, sourceAsset,
s1 => s1.sphereInfluenceNormalHandle,
d.offset, d.sphereRadius,
ref fade);
d.sphereBlendNormalDistance = fade;
}
}
Handles.matrix = mat;
Handles.color = c;
static void DrawBoxHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, Gizmo6FacesBox box)
static void DrawBoxHandle(
InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
Func<InfluenceVolumeUI, Gizmo6FacesBox> boundsGetter,
ref Vector3 center, ref Vector3 size)
box.center = d.offset.vector3Value;
box.size = d.boxSize.vector3Value;
var b = boundsGetter(s);
b.center = center;
b.size = size;
box.DrawHandle();
b.DrawHandle();
d.offset.vector3Value = box.center;
var size = box.size;
Vector3 blendPositive = d.boxBlendDistancePositive.vector3Value;
Vector3 blendNegative = d.boxBlendDistanceNegative.vector3Value;
Vector3 blendNormalPositive = d.boxBlendNormalDistancePositive.vector3Value;
Vector3 blendNormalNegative = d.boxBlendNormalDistanceNegative.vector3Value;
for (int i = 0; i < 3; ++i)
{
size[i] = Mathf.Max(0f, size[i]);
}
d.boxSize.vector3Value = size;
Vector3 halfSize = size * .5f;
for (int i = 0; i < 3; ++i)
{
blendPositive[i] = Mathf.Clamp(blendPositive[i], 0f, halfSize[i]);
blendNegative[i] = Mathf.Clamp(blendNegative[i], 0f, halfSize[i]);
blendNormalPositive[i] = Mathf.Clamp(blendNormalPositive[i], 0f, halfSize[i]);
blendNormalNegative[i] = Mathf.Clamp(blendNormalNegative[i], 0f, halfSize[i]);
}
d.boxBlendDistancePositive.vector3Value = blendPositive;
d.boxBlendDistanceNegative.vector3Value = blendNegative;
d.boxBlendNormalDistancePositive.vector3Value = blendNormalPositive;
d.boxBlendNormalDistanceNegative.vector3Value = blendNormalNegative;
center = b.center;
size = b.size;
if (d.editorAdvancedModeEnabled.boolValue)
{
d.editorAdvancedModeBlendDistancePositive.vector3Value = d.boxBlendDistancePositive.vector3Value;
d.editorAdvancedModeBlendDistanceNegative.vector3Value = d.boxBlendDistanceNegative.vector3Value;
d.editorAdvancedModeBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistancePositive.vector3Value;
d.editorAdvancedModeBlendNormalDistanceNegative.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value;
}
else
{
d.editorSimplifiedModeBlendDistance.floatValue = Mathf.Min(
d.boxBlendDistancePositive.vector3Value.x,
d.boxBlendDistancePositive.vector3Value.y,
d.boxBlendDistancePositive.vector3Value.z,
d.boxBlendDistanceNegative.vector3Value.x,
d.boxBlendDistanceNegative.vector3Value.y,
d.boxBlendDistanceNegative.vector3Value.z);
d.boxBlendDistancePositive.vector3Value = d.boxBlendDistanceNegative.vector3Value = Vector3.one * d.editorSimplifiedModeBlendDistance.floatValue;
d.editorSimplifiedModeBlendNormalDistance.floatValue = Mathf.Min(
d.boxBlendNormalDistancePositive.vector3Value.x,
d.boxBlendNormalDistancePositive.vector3Value.y,
d.boxBlendNormalDistancePositive.vector3Value.z,
d.boxBlendNormalDistanceNegative.vector3Value.x,
d.boxBlendNormalDistanceNegative.vector3Value.y,
d.boxBlendNormalDistanceNegative.vector3Value.z);
d.boxBlendNormalDistancePositive.vector3Value = d.boxBlendNormalDistanceNegative.vector3Value = Vector3.one * d.editorSimplifiedModeBlendNormalDistance.floatValue;
}
d.Apply();
EditorUtility.SetDirty(sourceAsset);
static void DrawBoxFadeHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, Gizmo6FacesBox box, SerializedProperty positive, SerializedProperty negative)
static void DrawBoxFadeHandle(
InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
Func<InfluenceVolumeUI, Gizmo6FacesBox> boundsGetter,
Vector3 baseOffset, Vector3 baseSize,
ref Vector3 positive, ref Vector3 negative)
box.center = d.offset.vector3Value - (positive.vector3Value - negative.vector3Value) * 0.5f;
box.size = d.boxSize.vector3Value - positive.vector3Value - negative.vector3Value;
box.allHandleControledByOne = !d.editorAdvancedModeEnabled.boolValue;
var b = boundsGetter(s);
b.center = baseOffset - (positive - negative) * 0.5f;
b.size = baseSize - positive - negative;
b.allHandleControledByOne = !s.data.editorAdvancedModeEnabled.boolValue;
box.DrawHandle();
b.DrawHandle();
var influenceCenter = d.offset.vector3Value;
var halfInfluenceSize = d.boxSize.vector3Value * .5f;
var center = baseOffset;
var influenceSize = baseSize;
var centerDiff = box.center - influenceCenter;
var halfSizeDiff = halfInfluenceSize - box.size * .5f;
var positiveNew = halfSizeDiff - centerDiff;
var negativeNew = halfSizeDiff + centerDiff;
var blendDistancePositive = Vector3.Max(Vector3.zero, Vector3.Min(positiveNew, halfInfluenceSize));
var blendDistanceNegative = Vector3.Max(Vector3.zero, Vector3.Min(negativeNew, halfInfluenceSize));
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.vector3Value = blendDistancePositive;
negative.vector3Value = blendDistanceNegative;
positive = blendDistancePositive;
negative = blendDistanceNegative;
d.Apply();
EditorUtility.SetDirty(sourceAsset);
static void DrawSphereHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, SphereBoundsHandle sphere)
static void DrawSphereHandle(
InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
Func<InfluenceVolumeUI, SphereBoundsHandle> boundsGetter,
ref Vector3 center, ref float radius)
sphere.center = d.offset.vector3Value;
sphere.radius = d.sphereRadius.floatValue;
var b = boundsGetter(s);
b.center = center;
b.radius = radius;
sphere.DrawHandle();
b.DrawHandle();
float radius = sphere.radius;
d.sphereRadius.floatValue = radius;
d.sphereBlendDistance.floatValue = Mathf.Clamp(s.data.sphereBlendDistance.floatValue, 0, radius);
d.sphereBlendNormalDistance.floatValue = Mathf.Clamp(s.data.sphereBlendNormalDistance.floatValue, 0, radius);
d.Apply();
radius = b.radius;
EditorUtility.SetDirty(sourceAsset);
static void DrawSphereFadeHandle(InfluenceVolumeUI s, SerializedInfluenceVolume d, Editor o, Object sourceAsset, SphereBoundsHandle sphere, SerializedProperty radius)
static void DrawSphereFadeHandle(
InfluenceVolumeUI s, InfluenceVolume d, Editor o, Object sourceAsset,
Func<InfluenceVolumeUI, SphereBoundsHandle> boundsGetter,
Vector3 baseOffset, float baseRadius,
ref float radius)
sphere.center = d.offset.vector3Value;
sphere.radius = radius.floatValue;
var b = boundsGetter(s);
b.center = baseOffset;
b.radius = Mathf.Clamp(baseRadius - radius, 0, baseRadius);
sphere.DrawHandle();
b.DrawHandle();
radius.floatValue = Mathf.Clamp(d.sphereRadius.floatValue - sphere.radius, 0, d.sphereRadius.floatValue);
d.Apply();
radius = Mathf.Clamp(baseRadius - b.radius, 0, baseRadius);
EditorUtility.SetDirty(sourceAsset);
}
}
}

20
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.cs


partial class InfluenceVolumeUI : BaseUI<SerializedInfluenceVolume>
{
const int k_AnimBoolFields = 2;
internal static readonly Color k_GizmoThemeColorBase = new Color(255f / 255f, 229f / 255f, 148f / 255f, 80f / 255f);
internal static readonly Color k_GizmoThemeColorBaseFace = new Color(255f / 255f, 229f / 255f, 148f / 255f, 45f / 255f);
internal static readonly Color k_GizmoThemeColorInfluence = new Color(83f / 255f, 255f / 255f, 95f / 255f, 75f / 255f);
internal static readonly Color k_GizmoThemeColorInfluenceFace = new Color(83f / 255f, 255f / 255f, 95f / 255f, 17f / 255f);
internal static readonly Color k_GizmoThemeColorInfluenceNormal = new Color(0f / 255f, 229f / 255f, 255f / 255f, 80f / 255f);
internal static readonly Color k_GizmoThemeColorInfluenceNormalFace = new Color(0f / 255f, 229f / 255f, 255f / 255f, 36f / 255f);
internal static readonly Color k_GizmoThemeColorProjection = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static readonly Color k_GizmoThemeColorProjectionFace = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
internal static readonly Color k_GizmoThemeColorDisabled = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
internal static readonly Color k_GizmoThemeColorDisabledFace = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
static readonly int k_ShapeCount = Enum.GetValues(typeof(InfluenceShape)).Length;
public Gizmo6FacesBox boxBaseHandle;

boxInfluenceNormalHandle.faceColorsSelected = new Color[] { HDReflectionProbeEditor.k_GizmoThemeColorInfluenceNormalBlendFace };
}
public void SetIsSectionExpanded_Shape(InfluenceShape shape)
public override void Update()
SetIsSectionExpanded_Shape((int)shape);
base.Update();
SetIsSectionExpanded_Shape((InfluenceShape)data.shape.intValue);
public void SetIsSectionExpanded_Shape(int shape)
void SetIsSectionExpanded_Shape(InfluenceShape shape)
m_AnimBools[i].target = shape == i;
m_AnimBools[i].target = (int)shape == i;
}
public AnimBool IsSectionExpanded_Shape(InfluenceShape shapeType)

135
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/ProxyVolumeUI.cs


namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using _ = CoreEditorUtils;
//Skin
//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);
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);
internal static GUIContent shapeContent = CoreEditorUtils.GetContent("Shape|The shape of the Proxy.\nInfinite is compatible with any kind of InfluenceShape.");
internal static GUIContent boxSizeContent = CoreEditorUtils.GetContent("Box Size|The size of the box.");
internal static GUIContent sphereRadiusContent = CoreEditorUtils.GetContent("Sphere Radius|The radius of the sphere.");
//logic
public static readonly CED.IDrawer SectionShapeBox = CED.Action(Drawer_SectionShapeBox);
public static readonly CED.IDrawer SectionShapeSphere = CED.Action(Drawer_SectionShapeSphere);

);
}
public BoxBoundsHandle boxProjectionHandle = new BoxBoundsHandle();
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle();
public ProxyVolumeUI()
: base(k_ShapeCount)
{

return m_AnimBools[(int)shapeType];
}
//gizmo
public static void DrawGizmos(Transform transform, ProxyVolume proxyVolume)
{
switch (proxyVolume.shape)
{
case ProxyShape.Box:
Gizmos_Box(transform, proxyVolume);
break;
case ProxyShape.Sphere:
Gizmos_Sphere(transform, proxyVolume);
break;
}
}
static void Gizmos_Sphere(Transform t, ProxyVolume d)
{
var mat = Gizmos.matrix;
Color col = Gizmos.color;
Gizmos.matrix = Matrix4x4.TRS(t.position, t.rotation, Vector3.one);
Gizmos.color = k_GizmoThemeColorProjection;
Gizmos.DrawWireSphere(Vector3.zero, d.sphereRadius);
Gizmos.color = col;
Gizmos.matrix = mat;
}
static void Gizmos_Box(Transform t, ProxyVolume d)
{
var mat = Gizmos.matrix;
Color col = Gizmos.color;
Gizmos.matrix = Matrix4x4.TRS(t.position, t.rotation, Vector3.one);
Gizmos.color = k_GizmoThemeColorProjection;
Gizmos.DrawWireCube(Vector3.zero, d.boxSize);
Gizmos.color = col;
Gizmos.matrix = mat;
}
//handles
public BoxBoundsHandle boxProjectionHandle = new BoxBoundsHandle();
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle();
EditorGUILayout.PropertyField(d.shape, shapeContent);
EditorGUILayout.PropertyField(d.shape, _.GetContent("Shape Type"));
EditorGUILayout.PropertyField(d.boxSize, boxSizeContent);
EditorGUILayout.PropertyField(d.boxSize, _.GetContent("Box Size"));
EditorGUILayout.PropertyField(d.sphereRadius, sphereRadiusContent);
EditorGUILayout.PropertyField(d.sphereRadius, _.GetContent("Sphere Radius"));
}
public static void DrawHandles_EditBase(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI ui, Object sourceAsset)

}
}
public static void DrawHandles_EditNone(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI ui, Object sourceAsset)
{
}
Matrix4x4 mat = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
var mat = Handles.matrix;
Handles.matrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
Handles.color = k_GizmoThemeColorProjection;
using (new Handles.DrawingScope(k_GizmoThemeColorProjection, mat))
{
s.sphereProjectionHandle.DrawHandle();
}
s.sphereProjectionHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sourceAsset, "Modified Projection Volume");

//the gizmo is not an object of the scene. Flag it as dirty
Handles.matrix = mat;
}
static void Handles_EditBase_Box(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI s, Object sourceAsset)

Matrix4x4 mat = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
var mat = Handles.matrix;
Handles.matrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
Handles.color = k_GizmoThemeColorProjection;
using (new Handles.DrawingScope(k_GizmoThemeColorProjection, mat))
{
s.boxProjectionHandle.DrawHandle();
}
s.boxProjectionHandle.DrawHandle();
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(sourceAsset, "Modified Projection Volume AABB");

//the gizmo is not an object of the scene. Flag it as dirty
Handles.matrix = mat;
}
public static void DrawGizmos_EditNone(Transform transform, ProxyVolume proxyVolume, ProxyVolumeUI ui, Object sourceAsset)
{
switch (proxyVolume.shape)
{
case ProxyShape.Box:
Gizmos_EditNone_Box(transform, proxyVolume, ui, sourceAsset);
break;
case ProxyShape.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 = Matrix4x4.TRS(t.position, t.rotation, Vector3.one);
Gizmos.color = k_GizmoThemeColorProjection;
Gizmos.DrawWireSphere(Vector3.zero, d.sphereRadius);
Gizmos.matrix = mat;
}
static void Gizmos_EditNone_Box(Transform t, ProxyVolume d, ProxyVolumeUI s, Object o)
{
var mat = Gizmos.matrix;
Gizmos.matrix = Matrix4x4.TRS(t.position, t.rotation, Vector3.one);
Gizmos.color = k_GizmoThemeColorProjection;
Gizmos.DrawWireCube(Vector3.zero, d.boxSize);
Gizmos.matrix = mat;
}
}
}

9
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/ReflectionProxyVolumeComponentUI.cs


ProxyVolumeUI.DrawHandles_EditBase(target.transform, target.proxyVolume, ui.proxyVolume, target);
}
public static void DrawGizmos_EditNone(ReflectionProxyVolumeComponent target)
public static void DrawHandles_EditNone(ReflectionProxyVolumeComponentUI ui, ReflectionProxyVolumeComponent target)
{
ProxyVolumeUI.DrawHandles_EditNone(target.transform, target.proxyVolume, ui.proxyVolume, target);
}
public static void DrawGizmos_EditNone(ReflectionProxyVolumeComponentUI ui, ReflectionProxyVolumeComponent target)
ProxyVolumeUI.DrawGizmos(target.transform, target.proxyVolume);
ProxyVolumeUI.DrawGizmos_EditNone(target.transform, target.proxyVolume, ui.proxyVolume, target);
}
}
}

29
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/SerializedInfluenceVolume.cs


internal SerializedProperty boxSize;
internal SerializedProperty boxBlendDistancePositive;
internal SerializedProperty boxBlendDistanceNegative;
//internal SerializedProperty boxBlendSize;
//internal SerializedProperty boxBlendNormalSize;
internal SerializedProperty boxSideFadePositive;
internal SerializedProperty boxSideFadeNegative;
internal SerializedProperty sphereRadius;

internal SerializedProperty editorAdvancedModeBlendNormalDistanceNegative;
internal SerializedProperty editorSimplifiedModeBlendNormalDistance;
internal SerializedProperty editorAdvancedModeEnabled;
internal SerializedProperty editorAdvancedModeFaceFadePositive;
internal SerializedProperty editorAdvancedModeFaceFadeNegative;
public SerializedInfluenceVolume(SerializedProperty root)
{

boxSize = root.Find((InfluenceVolume i) => i.boxSize);
boxBlendDistancePositive = root.Find((InfluenceVolume i) => i.boxBlendDistancePositive);
boxBlendDistanceNegative = root.Find((InfluenceVolume i) => i.boxBlendDistanceNegative);
//boxBlendSize = root.Find((InfluenceVolume i) => i.boxBlendSize);
//boxBlendNormalSize = root.Find((InfluenceVolume i) => i.boxBlendNormalSize);
boxSideFadePositive = root.Find((InfluenceVolume i) => i.boxSideFadePositive);
boxSideFadeNegative = root.Find((InfluenceVolume i) => i.boxSideFadeNegative);
sphereRadius = root.Find((InfluenceVolume i) => i.sphereRadius);

editorAdvancedModeBlendNormalDistanceNegative = root.FindPropertyRelative("m_EditorAdvancedModeBlendNormalDistanceNegative");
editorSimplifiedModeBlendNormalDistance = root.FindPropertyRelative("m_EditorSimplifiedModeBlendNormalDistance");
editorAdvancedModeEnabled = root.FindPropertyRelative("m_EditorAdvancedModeEnabled");
editorAdvancedModeFaceFadePositive = root.FindPropertyRelative("m_EditorAdvancedModeFaceFadePositive");
editorAdvancedModeFaceFadeNegative = root.FindPropertyRelative("m_EditorAdvancedModeFaceFadeNegative");
if (editorAdvancedModeBlendDistancePositive.vector3Value == Vector3.zero
if(editorAdvancedModeBlendDistancePositive.vector3Value == Vector3.zero
&& editorAdvancedModeBlendDistanceNegative.vector3Value == Vector3.zero
&& editorSimplifiedModeBlendDistance.floatValue == 0f
&& editorAdvancedModeBlendNormalDistancePositive.vector3Value == Vector3.zero

|| boxBlendDistanceNegative.vector3Value != Vector3.zero
|| boxBlendNormalDistancePositive.vector3Value != Vector3.zero
|| boxBlendNormalDistanceNegative.vector3Value != Vector3.zero))
|| boxBlendDistanceNegative.vector3Value != Vector3.zero))
{
Vector3 positive = boxBlendDistancePositive.vector3Value;
Vector3 negative = boxBlendDistanceNegative.vector3Value;

|| negative.x != negative.y
|| negative.x != negative.z
|| positive.x != negative.x;
Apply();
}
if(editorAdvancedModeFaceFadePositive.vector3Value == Vector3.one
&& editorAdvancedModeFaceFadeNegative.vector3Value == Vector3.one
&& (boxSideFadePositive.vector3Value != Vector3.one
|| boxSideFadeNegative.vector3Value != Vector3.one))
{
editorAdvancedModeFaceFadePositive.vector3Value = boxSideFadePositive.vector3Value;
editorAdvancedModeFaceFadeNegative.vector3Value = boxSideFadeNegative.vector3Value;
if(!editorAdvancedModeEnabled.boolValue)
{
boxSideFadePositive.vector3Value = Vector3.one;
boxSideFadeNegative.vector3Value = Vector3.one;
}
Apply();
}
}

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/ReflectionMenuItem.cs


namespace UnityEditor.Experimental.Rendering.HDPipeline
{
partial class HDProbeUI
public class ReflectionMenuItems
{
[MenuItem("GameObject/3D Object/Mirror", priority = CoreUtils.gameObjectMenuPriority)]
static void CreateMirrorGameObject(MenuCommand menuCommand)

4
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.cs


out worldToCamera, out projection, out capturePosition, out captureRotation,
camera);
var gpuProj = GL.GetGPUProjectionMatrix(projection, true); // Had to change this from 'false'
// Provide non device dependent projection matrix (clip space range is [-1..1]^3)
var vp = projection * gpuView * Matrix4x4.Translate(capturePosition);
var vp = gpuProj * gpuView * Matrix4x4.Translate(capturePosition);
m_Env2DCaptureVP[fetchIndex] = vp;
}
else if (probe.reflectionProbe != null)

10
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoopDef.hlsl


{
if (cacheType == ENVCACHETYPE_TEXTURE2D)
{
// _Env2DCaptureVP transform from this camera view space to capture camera clip space.
// And it uses a non device dependent projection matrix (clip space range is [-1..1]^3)
float4 positionCS = mul(_Env2DCaptureVP[index], float4(texCoord, 1.0));
float3 ndc = (positionCS.xyz * rcp(positionCS.w)) * 0.5 + 0.5;
//_Env2DCaptureVP is in capture space
float3 ndc = ComputeNormalizedDeviceCoordinatesWithZ(texCoord, _Env2DCaptureVP[index]);
// Clip against oblique near clip plane and side clip planes.
// Don't clip against far clip plane to handle properly infinite projection.
color.a = any(ndc.xyz < 0) || any(ndc.xy > 1) ? 0.0 : 1.0;
color.a = any(ndc.xyz < 0) || any(ndc.xyz > 1) ? 0.0 : 1.0;
}
else if (cacheType == ENVCACHETYPE_CUBEMAP)
{

69
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs


Second,
HDProbeChild,
UseInfluenceVolume,
MergeEditors,
// Add new version here and they will automatically be the Current one
Max,
Current = Max - 1

int m_Version;
ReflectionProbe m_LegacyProbe;
/// <summary>Get the sibling component ReflectionProbe</summary>
public ReflectionProbe reflectionProbe
ReflectionProbe legacyProbe
if(m_LegacyProbe == null || m_LegacyProbe.Equals(null))
if (m_LegacyProbe == null || m_LegacyProbe.Equals(null))
return m_LegacyProbe;
return m_LegacyProbe;
else
{
return m_LegacyProbe;
}
}
}

bool needMigrateToHDProbeChild = false;
bool needMigrateToUseInfluenceVolume = false;
bool needMigrateToMergeEditors = false;
public void CopyTo(HDAdditionalReflectionData data)
{

{
needMigrateToUseInfluenceVolume = true;
}
else if (m_Version < (int)Version.MergeEditors)
{
needMigrateToMergeEditors = true;
}
else
{
// Add here data migration code that do not use other component

MigrateToHDProbeChild();
if (needMigrateToUseInfluenceVolume)
MigrateToUseInfluenceVolume();
if (needMigrateToMergeEditors)
MigrateToMergeEditors();
ReflectionSystem.RegisterProbe(this);
}
void OnDisable()
{
ReflectionSystem.UnregisterProbe(this);
}
void OnValidate()
{
ReflectionSystem.UnregisterProbe(this);
if (isActiveAndEnabled)
ReflectionSystem.RegisterProbe(this);
mode = reflectionProbe.mode;
refreshMode = reflectionProbe.refreshMode;
mode = legacyProbe.mode;
refreshMode = legacyProbe.refreshMode;
m_Version = (int)Version.HDProbeChild;
needMigrateToHDProbeChild = false;
OnAfterDeserialize(); //continue migrating if needed

{
influenceVolume.boxSize = reflectionProbe.size;
influenceVolume.boxSize = legacyProbe.size;
#pragma warning disable CS0618 // Type or member is obsolete
influenceVolume.sphereRadius = influenceSphereRadius;
influenceVolume.shape = influenceShape; //must be done after each size transfert

//User will lose parameters corresponding to non used mode between simplified and advanced
}
void MigrateToMergeEditors()
{
infiniteProjection = !reflectionProbe.boxProjection;
reflectionProbe.boxProjection = false;
m_Version = (int)Version.MergeEditors;
needMigrateToMergeEditors = false;
OnAfterDeserialize(); //continue migrating if needed
}
reflectionProbe.mode = value; //ensure compatibility till we capture without the legacy component
if(value == ReflectionProbeMode.Realtime)
{
refreshMode = ReflectionProbeRefreshMode.EveryFrame;
}
legacyProbe.mode = value; //ensure compatibility till we capture without the legacy component
}
}

{
base.refreshMode = value;
reflectionProbe.refreshMode = value; //ensure compatibility till we capture without the legacy component
legacyProbe.refreshMode = value; //ensure compatibility till we capture without the legacy component
reflectionProbe.size = size;
reflectionProbe.center = transform.rotation*offset;
}
public override bool infiniteProjection
{
get
{
return base.infiniteProjection || (proxyVolume == null && reflectionProbe.boxProjection);
}
legacyProbe.size = size;
legacyProbe.center = transform.rotation*offset;
}
}
}

25
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDProbe.cs


{
[SerializeField, FormerlySerializedAs("proxyVolumeComponent"), FormerlySerializedAs("m_ProxyVolumeReference")]
ReflectionProxyVolumeComponent m_ProxyVolume = null;
[SerializeField]
bool m_InfiniteProjection = true; //usable when no proxy set
[SerializeField]
FrameSettings m_FrameSettings = null;
[SerializeField, FormerlySerializedAsAttribute("dimmer"), FormerlySerializedAsAttribute("m_Dimmer"), FormerlySerializedAsAttribute("multiplier")]
float m_Multiplier = 1.0f;

ReflectionProbeMode m_Mode = ReflectionProbeMode.Baked;
[SerializeField]
ReflectionProbeRefreshMode m_RefreshMode = ReflectionProbeRefreshMode.OnAwake;
RenderTexture m_RealtimeTexture = null;
/// <summary>ProxyVolume currently used by this probe.</summary>
public ReflectionProxyVolumeComponent proxyVolume { get { return m_ProxyVolume; } }

/// <summary>Frame settings in use with this probe.</summary>
public FrameSettings frameSettings { get { return m_FrameSettings; } }
/// <summary>Get the realtime acquired Render Texture</summary>
public RenderTexture realtimeTexture { get { return m_RealtimeTexture; } internal set { m_RealtimeTexture = value; } }
/// <summary>The capture mode.</summary>
public virtual ReflectionProbeMode mode

{
get { return m_RefreshMode; }
set { m_RefreshMode = value; }
}
public virtual bool infiniteProjection
{
get
{
return proxyVolume != null && proxyVolume.proxyVolume.shape == ProxyShape.Infinite || m_InfiniteProjection;
}
set
{
m_InfiniteProjection = value;
}
}
internal void Awake()

19
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/PlanarReflectionProbe.cs


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

[SerializeField]
Texture m_BakedTexture;
[SerializeField]
FrameSettings m_FrameSettings = null;
[SerializeField]
float m_CaptureNearPlane = 1;
[SerializeField]
float m_CaptureFarPlane = 1000;

[SerializeField]
[Range(0, 180)]
float m_FieldOfViewOverride = 90;
RenderTexture m_RealtimeTexture;
public bool overrideFieldOfView { get { return m_OverrideFieldOfView; } }
public float fieldOfViewOverride { get { return m_FieldOfViewOverride; } }

}
public Texture customTexture { get { return m_CustomTexture; } set { m_CustomTexture = value; } }
public Texture bakedTexture { get { return m_BakedTexture; } set { m_BakedTexture = value; }}
public RenderTexture realtimeTexture { get { return m_RealtimeTexture; } internal set { m_RealtimeTexture = value; } }
public FrameSettings frameSettings { get { return m_FrameSettings; } }
public float captureNearPlane { get { return m_CaptureNearPlane; } }
public float captureFarPlane { get { return m_CaptureFarPlane; } }
public CapturePositionMode capturePositionMode { get { return m_CapturePositionMode; } }

: influenceVolume.boxSize;
}
}
public bool infiniteProjection
{
get
{
return proxyVolume != null
&& proxyVolume.proxyVolume.shape == ProxyShape.Infinite;
}
}
public bool useMirrorPlane
{

public void OnAfterDeserialize()
{
Assert.IsNotNull(influenceVolume, "influenceVolume must have an instance at this point. See HDProbe.Awake()");
if (m_Version != currentVersion)
{
// Add here data migration code

}
m_Version = currentVersion;
}
influenceVolume.boxBlendNormalDistanceNegative = Vector3.zero;
influenceVolume.boxBlendNormalDistancePositive = Vector3.zero;
}
}
}

29
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ProbeWrapper.cs


if (add.influenceVolume == null)
{
add.Awake(); // We need to init the 'default' data if it isn't
}
}
Vector3 distance = Vector3.one * probe.blendDistance;
add.influenceVolume.boxBlendDistancePositive = distance;
add.influenceVolume.boxBlendDistanceNegative = distance;

}
}
public override Texture texture
{
get
{
if(additional.mode == ReflectionProbeMode.Realtime)
{
return additional.realtimeTexture;
}
else
{
return probe.texture;
}
}
}
public override Texture texture { get { return probe.texture; } }
public override ReflectionProbeMode mode { get { return probe.probe.mode; } }
public override EnvShapeType influenceShapeType { get { return ConvertShape(additional.influenceVolume.shape); } }
public override float weight { get { return additional.weight; } }

: influenceExtents;
}
}
public override bool infiniteProjection { get { return additional.infiniteProjection; } }
public override bool infiniteProjection
{
get
{
return additional.proxyVolume != null
? additional.proxyVolume.proxyVolume.shape == ProxyShape.Infinite
: probe.boxProjection == 0;
}
}
public override Matrix4x4 proxyToWorld
{

10
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystem.cs


s_Instance.RegisterProbe(planarProbe);
}
public static void RegisterProbe(HDAdditionalReflectionData probe)
{
s_Instance.RegisterProbe(probe);
}
}
public static void UnregisterProbe(HDAdditionalReflectionData probe)
{
s_Instance.UnregisterProbe(probe);
}
public static void RequestRealtimeRender(PlanarReflectionProbe probe)

166
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystemInternal.cs


{
static Camera s_RenderCamera = null;
static HDAdditionalCameraData s_RenderCameraData;
static int frame = Time.frameCount;
HashSet<HDAdditionalReflectionData> m_AdditionalDataReflectionProbes;
HashSet<HDAdditionalReflectionData> m_AdditionalDataReflectionProbe_RealtimeUpdate;
HashSet<HDAdditionalReflectionData> m_AdditionalDataReflectionProbe_RequestRealtimeRender;
HDAdditionalReflectionData[] m_AdditionalDataReflectionProbe_RealtimeUpdate_WorkArray;
HashSet<PlanarReflectionProbe> m_PlanarReflectionProbes;
HashSet<PlanarReflectionProbe> m_PlanarReflectionProbe_DirtyBounds;

m_PlanarReflectionProbesArray = new PlanarReflectionProbe[parameters.maxActivePlanarReflectionProbe];
m_PlanarReflectionProbeBoundsArray = new BoundingSphere[parameters.maxActivePlanarReflectionProbe];
m_PlanarReflectionProbe_RealtimeUpdate_WorkArray = new PlanarReflectionProbe[parameters.maxPlanarReflectionProbePerCamera];
m_AdditionalDataReflectionProbe_RealtimeUpdate_WorkArray = new HDAdditionalReflectionData[parameters.maxPlanarReflectionProbePerCamera]; ;
m_AdditionalDataReflectionProbes = new HashSet<HDAdditionalReflectionData>();
m_AdditionalDataReflectionProbe_RealtimeUpdate = new HashSet<HDAdditionalReflectionData>();
m_AdditionalDataReflectionProbe_RequestRealtimeRender = new HashSet<HDAdditionalReflectionData>();
m_PlanarReflectionProbes = new HashSet<PlanarReflectionProbe>();
m_PlanarReflectionProbe_DirtyBounds = new HashSet<PlanarReflectionProbe>();
m_PlanarReflectionProbe_RequestRealtimeRender = new HashSet<PlanarReflectionProbe>();

if (previous != null)
{
m_PlanarReflectionProbes.UnionWith(previous.m_PlanarReflectionProbes);
m_PlanarReflectionProbes.UnionWith(previous.m_PlanarReflectionProbes);
m_AdditionalDataReflectionProbe_RequestRealtimeRender.UnionWith(previous.m_AdditionalDataReflectionProbe_RequestRealtimeRender);
m_AdditionalDataReflectionProbe_RealtimeUpdate.UnionWith(previous.m_AdditionalDataReflectionProbe_RealtimeUpdate);
m_PlanarReflectionProbe_DirtyBounds.UnionWith(m_PlanarReflectionProbes);
m_PlanarReflectionProbe_RequestRealtimeRender.UnionWith(previous.m_PlanarReflectionProbe_RequestRealtimeRender);
m_PlanarReflectionProbe_RealtimeUpdate.UnionWith(previous.m_PlanarReflectionProbe_RealtimeUpdate);

}
}
public void RegisterProbe(HDAdditionalReflectionData additional)
{
m_AdditionalDataReflectionProbes.Add(additional);
//SetProbeBoundsDirty(probe);
if (additional.mode == ReflectionProbeMode.Realtime)
{
//switch (additional.refreshMode)
//{
// case ReflectionProbeRefreshMode.OnAwake:
// m_AdditionalDataReflectionProbe_RequestRealtimeRender.Add(additional);
// break;
// case ReflectionProbeRefreshMode.EveryFrame:
m_AdditionalDataReflectionProbe_RealtimeUpdate.Add(additional);
// break;
//}
}
}
public void UnregisterProbe(PlanarReflectionProbe planarProbe)
{
m_PlanarReflectionProbes.Remove(planarProbe);

m_PlanarReflectionProbe_PerCamera_RealtimeUpdate.Remove(planarProbe);
}
public void UnregisterProbe(HDAdditionalReflectionData additional)
{
m_AdditionalDataReflectionProbes.Remove(additional);
m_AdditionalDataReflectionProbe_RequestRealtimeRender.Remove(additional);
m_AdditionalDataReflectionProbe_RealtimeUpdate.Remove(additional);
}
public void PrepareCull(Camera camera, ReflectionProbeCullResults results)
{
UpdateAllPlanarReflectionProbeBounds();

{
var probe = m_PlanarReflectionProbe_RealtimeUpdate_WorkArray[i];
if (!IsRealtimeTextureValid(probe.realtimeTexture, true))
if (!IsRealtimeTextureValid(probe.realtimeTexture))
{
if (probe.realtimeTexture != null)
probe.realtimeTexture.Release();

{
var probe = m_PlanarReflectionProbe_RealtimeUpdate_WorkArray[i];
if (!IsRealtimeTextureValid(probe.realtimeTexture, true))
if (!IsRealtimeTextureValid(probe.realtimeTexture))
{
if (probe.realtimeTexture != null)
probe.realtimeTexture.Release();

Render(probe, probe.realtimeTexture);
}
}
if ((probeTypes & ReflectionProbeType.ReflectionProbe) != 0 && frame != Time.frameCount)
{
//do only one per frame
frame = Time.frameCount;
// Discard disabled probes in requested render probes
m_AdditionalDataReflectionProbe_RequestRealtimeRender.IntersectWith(m_AdditionalDataReflectionProbes);
// Include all realtime probe modes
m_AdditionalDataReflectionProbe_RequestRealtimeRender.UnionWith(m_AdditionalDataReflectionProbe_RealtimeUpdate);
var length = Mathf.Min(m_AdditionalDataReflectionProbe_RequestRealtimeRender.Count, m_AdditionalDataReflectionProbe_RealtimeUpdate_WorkArray.Length);
m_AdditionalDataReflectionProbe_RequestRealtimeRender.CopyTo(m_AdditionalDataReflectionProbe_RealtimeUpdate_WorkArray);
m_AdditionalDataReflectionProbe_RequestRealtimeRender.Clear();
// 1. Allocate if necessary target texture
for (var i = 0; i < length; i++)
{
var additional = m_AdditionalDataReflectionProbe_RealtimeUpdate_WorkArray[i];
if (!IsRealtimeTextureValid(additional.realtimeTexture, false))
{
if (additional.realtimeTexture != null)
additional.realtimeTexture.Release();
additional.realtimeTexture = NewRenderTarget(additional);
}
}
// 2. Render
for (var i = 0; i < length; i++)
{
var additional = m_AdditionalDataReflectionProbe_RealtimeUpdate_WorkArray[i];
Render(additional, additional.realtimeTexture);
}
}
}
public RenderTexture NewRenderTarget(PlanarReflectionProbe probe)

return rt;
}
public RenderTexture NewRenderTarget(HDAdditionalReflectionData probe)
{
var rt = new RenderTexture(m_Parameters.reflectionProbeSize, m_Parameters.reflectionProbeSize, 0, RenderTextureFormat.ARGBHalf);
// No hide and don't save for this one
rt.useMipMap = true;
rt.autoGenerateMips = false;
rt.name = CoreUtils.GetRenderTargetAutoName(m_Parameters.reflectionProbeSize, m_Parameters.reflectionProbeSize, 1, RenderTextureFormat.ARGBHalf, "ProbeRT");
rt.dimension = TextureDimension.Cube;
rt.Create();
return rt;
}
//public float GetCaptureCameraFOVFor(PlanarReflectionProbe probe, Camera viewerCamera)
//{
// switch (probe.influenceVolume.shapeType)

// }
//}
bool IsRealtimeTextureValid(RenderTexture renderTexture, bool isPlanar)
bool IsRealtimeTextureValid(RenderTexture renderTexture)
if(isPlanar)
return renderTexture != null
&& renderTexture.width == m_Parameters.planarReflectionProbeSize
&& renderTexture.height == m_Parameters.planarReflectionProbeSize
&& renderTexture.format == RenderTextureFormat.ARGBHalf
&& renderTexture.useMipMap;
else
return renderTexture != null
&& renderTexture.width == m_Parameters.reflectionProbeSize
&& renderTexture.height == m_Parameters.reflectionProbeSize
&& renderTexture.format == RenderTextureFormat.ARGBHalf
&& renderTexture.useMipMap;
return renderTexture != null
&& renderTexture.width == m_Parameters.planarReflectionProbeSize
&& renderTexture.height == m_Parameters.planarReflectionProbeSize
&& renderTexture.format == RenderTextureFormat.ARGBHalf
&& renderTexture.useMipMap;
}
public void RequestRealtimeRender(PlanarReflectionProbe probe)

renderCamera.Render();
GL.invertCulling = false;
renderCamera.targetTexture = null;
target.IncrementUpdateCount();
}
public void Render(HDAdditionalReflectionData additional, RenderTexture target, Camera viewerCamera = null)
{
var renderCamera = GetRenderCamera();
// Copy current frameSettings of this probe to the HDAdditionalData of the render camera
//probe.frameSettings.CopyTo(s_RenderCameraData.GetFrameSettings());
SetupCameraForRender(renderCamera, additional, viewerCamera);
renderCamera.RenderToCubemap(target);
target.IncrementUpdateCount();
}

ctr.rotation = captureRotation;
}
static void SetupCameraForRender(Camera camera, HDAdditionalReflectionData additional, Camera viewerCamera = null)
{
float nearClipPlane, farClipPlane, aspect, fov;
Color backgroundColor;
CameraClearFlags clearFlags;
Vector3 capturePosition;
Quaternion captureRotation;
Matrix4x4 worldToCamera, projection;
CalculateCaptureCameraProperties(additional,
out nearClipPlane, out farClipPlane,
out aspect, out fov, out clearFlags, out backgroundColor,
out worldToCamera, out projection,
out capturePosition, out captureRotation, viewerCamera);
camera.farClipPlane = farClipPlane;
camera.nearClipPlane = nearClipPlane;
camera.fieldOfView = fov;
camera.aspect = aspect;
camera.clearFlags = clearFlags;
camera.backgroundColor = camera.backgroundColor;
camera.projectionMatrix = projection;
camera.worldToCameraMatrix = worldToCamera;
var ctr = camera.transform;
ctr.position = capturePosition;
ctr.rotation = captureRotation;
}
public static void CalculateCaptureCameraViewProj(PlanarReflectionProbe probe, out Matrix4x4 worldToCamera, out Matrix4x4 projection, out Vector3 capturePosition, out Quaternion captureRotation, Camera viewerCamera = null)
{
float nearClipPlane, farClipPlane, aspect, fov;

CalculateMirroredCaptureCameraProperties(probe, viewerCamera, out nearClipPlane, out farClipPlane, out aspect, out fov, out clearFlags, out backgroundColor, out worldToCamera, out projection, out capturePosition, out captureRotation);
else
CalculateStaticCaptureCameraProperties(probe, out nearClipPlane, out farClipPlane, out aspect, out fov, out clearFlags, out backgroundColor, out worldToCamera, out projection, out capturePosition, out captureRotation);
}
public static void CalculateCaptureCameraProperties(HDAdditionalReflectionData additional, out float nearClipPlane, out float farClipPlane, out float aspect, out float fov, out CameraClearFlags clearFlags, out Color backgroundColor, out Matrix4x4 worldToCamera, out Matrix4x4 projection, out Vector3 capturePosition, out Quaternion captureRotation, Camera viewerCamera = null)
{
nearClipPlane = additional.reflectionProbe.nearClipPlane;
farClipPlane = additional.reflectionProbe.farClipPlane;
aspect = 1f;
fov = 90f;
clearFlags = CameraClearFlags.Nothing;
backgroundColor = Color.white;
capturePosition = additional.transform.TransformPoint(additional.transform.position);
captureRotation = Quaternion.identity;
worldToCamera = GeometryUtils.CalculateWorldToCameraMatrixRHS(capturePosition, captureRotation);
projection = Matrix4x4.Perspective(fov, aspect, nearClipPlane, farClipPlane);
}
static bool IsProbeCaptureMirrored(PlanarReflectionProbe probe, Camera viewerCamera)

14
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/ReflectionSystemParameters.cs


{
maxPlanarReflectionProbePerCamera = 128,
maxActivePlanarReflectionProbe = 512,
planarReflectionProbeSize = 128,
maxActiveReflectionProbe = 512,
reflectionProbeSize = 128
planarReflectionProbeSize = 128
};
/// <summary>

/// Size of the planar probe textures.
/// </summary>
public int planarReflectionProbeSize;
/// <summary>
/// Maximum number of active non planar reflection in the world.
/// </summary>
public int maxActiveReflectionProbe;
/// <summary>
/// Size of the non planar probe textures.
/// </summary>
public int reflectionProbeSize;
}
}

16
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/Volumes/InfluenceVolume.cs


float m_EditorSimplifiedModeBlendNormalDistance;
[SerializeField, FormerlySerializedAs("editorAdvancedModeEnabled")]
bool m_EditorAdvancedModeEnabled;
[SerializeField]
Vector3 m_EditorAdvancedModeFaceFadePositive = Vector3.one;
[SerializeField]
Vector3 m_EditorAdvancedModeFaceFadeNegative = Vector3.one;
// Sphere
[SerializeField, FormerlySerializedAs("m_SphereBaseRadius")]

data.m_EditorAdvancedModeBlendNormalDistanceNegative = m_EditorAdvancedModeBlendNormalDistanceNegative;
data.m_EditorSimplifiedModeBlendNormalDistance = m_EditorSimplifiedModeBlendNormalDistance;
data.m_EditorAdvancedModeEnabled = m_EditorAdvancedModeEnabled;
data.m_EditorAdvancedModeFaceFadePositive = m_EditorAdvancedModeFaceFadePositive;
data.m_EditorAdvancedModeFaceFadeNegative = m_EditorAdvancedModeFaceFadeNegative;
}
/// <summary>Shape of this InfluenceVolume.</summary>

}
/// <summary>Offset of this influence volume to the component handling him.</summary>
public Vector3 offset
{
get { return m_Offset; }
set
{
m_Offset = value;
m_Probe.UpdatedInfluenceVolumeShape(boxSize, m_Offset);
}
}
public Vector3 offset { get { return m_Offset; } set { m_Offset = value; } }
/// <summary>Size of the InfluenceVolume in Box Mode.</summary>
public Vector3 boxSize

8
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs


}
// TODO: Render only visible probes
var probeTypeToRender = ReflectionProbeType.ReflectionProbe;
var isPlanarReflection = cameras.Any(c => c.cameraType == CameraType.Reflection);
if (!isPlanarReflection)
probeTypeToRender |= ReflectionProbeType.PlanarReflection;
ReflectionSystem.RenderAllRealtimeProbes(probeTypeToRender);
var isReflection = cameras.Any(c => c.cameraType == CameraType.Reflection);
if (!isReflection)
ReflectionSystem.RenderAllRealtimeProbes(ReflectionProbeType.PlanarReflection);
// We first update the state of asset frame settings as they can be use by various camera
// but we keep the dirty state to correctly reset other camera that use RenderingPath.Default.

4
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipelineAsset.cs


{
maxPlanarReflectionProbePerCamera = renderPipelineSettings.lightLoopSettings.planarReflectionProbeCacheSize,
maxActivePlanarReflectionProbe = 512,
planarReflectionProbeSize = (int)renderPipelineSettings.lightLoopSettings.planarReflectionTextureSize,
maxActiveReflectionProbe = 512,
reflectionProbeSize = (int)renderPipelineSettings.lightLoopSettings.reflectionCubemapSize
planarReflectionProbeSize = (int)renderPipelineSettings.lightLoopSettings.planarReflectionTextureSize
};
}
}

89
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Handles.cs


using UnityEditor.IMGUI.Controls;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEditor.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
partial class HDReflectionProbeEditor
{
enum InfluenceType
{
Standard,
Normal
}
void OnSceneGUI()
{
var s = m_UIState;
var p = m_SerializedHdReflectionProbe;
var o = this;
BakeRealtimeProbeIfPositionChanged(s, p, o);
HDReflectionProbeUI.DoShortcutKey(p, o);
if (!s.sceneViewEditing)
return;
var mat = Matrix4x4.TRS(p.target.transform.position, p.target.transform.rotation, Vector3.one);
EditorGUI.BeginChangeCheck();
switch (EditMode.editMode)
{
// Influence editing
case EditMode.SceneViewEditMode.ReflectionProbeBox:
InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData);
break;
// Influence fade editing
case EditMode.SceneViewEditMode.GridBox:
InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData);
break;
// Influence normal fade editing
case EditMode.SceneViewEditMode.Collider:
InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, p.targetData.influenceVolume, o, mat, p.targetData);
break;
// Origin editing
case EditMode.SceneViewEditMode.ReflectionProbeOrigin:
Handle_OriginEditing(s, p, o);
break;
}
if (EditorGUI.EndChangeCheck())
Repaint();
}
static void Handle_OriginEditing(HDReflectionProbeUI s, SerializedHDReflectionProbe sp, Editor o)
{
var p = (ReflectionProbe)sp.so.targetObject;
var transformPosition = p.transform.position;
var size = p.size;
EditorGUI.BeginChangeCheck();
var newPostion = Handles.PositionHandle(transformPosition, HDReflectionProbeEditorUtility.GetLocalSpaceRotation(p));
var changed = EditorGUI.EndChangeCheck();
if (changed || s.oldLocalSpace != HDReflectionProbeEditorUtility.GetLocalSpace(p))
{
var localNewPosition = s.oldLocalSpace.inverse.MultiplyPoint3x4(newPostion);
var b = new Bounds(p.center, size);
localNewPosition = b.ClosestPoint(localNewPosition);
Undo.RecordObject(p.transform, "Modified Reflection Probe Origin");
p.transform.position = s.oldLocalSpace.MultiplyPoint3x4(localNewPosition);
Undo.RecordObject(p, "Modified Reflection Probe Origin");
p.center = HDReflectionProbeEditorUtility.GetLocalSpace(p).inverse.MultiplyPoint3x4(s.oldLocalSpace.MultiplyPoint3x4(p.center));
EditorUtility.SetDirty(p);
s.UpdateOldLocalSpace(p);
}
}
}
}

312
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Drawers.cs


using System;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<PlanarReflectionProbeUI, SerializedPlanarReflectionProbe>;
partial class PlanarReflectionProbeUI
{
public static readonly CED.IDrawer Inspector;
public static readonly CED.IDrawer SectionProbeModeSettings;
public static readonly CED.IDrawer ProxyVolumeSettings = CED.FoldoutGroup(
"Proxy Volume",
(s, d, o) => s.isSectionExpendedProxyVolume,
FoldoutOption.Indent,
CED.Action(Drawer_SectionProxySettings)
);
public static readonly CED.IDrawer SectionProbeModeBakedSettings = CED.noop;
public static readonly CED.IDrawer SectionProbeModeCustomSettings = CED.Action(Drawer_SectionProbeModeCustomSettings);
public static readonly CED.IDrawer SectionProbeModeRealtimeSettings = CED.Action(Drawer_SectionProbeModeRealtimeSettings);
public static readonly CED.IDrawer SectionBakeButton = CED.Action(Drawer_SectionBakeButton);
public static readonly CED.IDrawer SectionFoldoutAdditionalSettings = CED.FoldoutGroup(
"Artistic Settings",
(s, d, o) => s.isSectionExpendedAdditionalSettings,
FoldoutOption.Indent,
CED.Action(Drawer_SectionInfluenceSettings)
);
public static readonly CED.IDrawer SectionFoldoutCaptureSettings;
public static readonly CED.IDrawer SectionCaptureMirrorSettings = CED.Action(Drawer_SectionCaptureMirror);
public static readonly CED.IDrawer SectionCaptureStaticSettings = CED.Action(Drawer_SectionCaptureStatic);
static PlanarReflectionProbeUI()
{
SectionFoldoutCaptureSettings = CED.FoldoutGroup(
"Capture Settings",
(s, d, o) => s.isSectionExpandedCaptureSettings,
FoldoutOption.Indent,
CED.Action(Drawer_SectionCaptureSettings),
CED.FadeGroup(
(s, d, o, i) =>
{
switch (i)
{
default:
case 0: return s.isSectionExpandedCaptureMirrorSettings;
case 1: return s.isSectionExpandedCaptureStaticSettings;
}
},
FadeOption.None,
SectionCaptureMirrorSettings,
SectionCaptureStaticSettings)
);
SectionProbeModeSettings = CED.Group(
CED.Action(Drawer_FieldCaptureType),
CED.FadeGroup(
(s, d, o, i) => s.IsSectionExpandedReflectionProbeMode((ReflectionProbeMode)i),
FadeOption.Indent,
SectionProbeModeBakedSettings,
SectionProbeModeRealtimeSettings,
SectionProbeModeCustomSettings
)
);
Inspector = CED.Group(
CED.Action(Drawer_Toolbar),
CED.space,
ProxyVolumeSettings,
CED.Select(
(s, d, o) => s.influenceVolume,
(s, d, o) => d.influenceVolume,
InfluenceVolumeUI.SectionFoldoutShapePlanar
),
CED.Action(Drawer_DifferentShapeError),
SectionFoldoutCaptureSettings,
SectionFoldoutAdditionalSettings,
CED.Select(
(s, d, o) => s.frameSettings,
(s, d, o) => d.frameSettings,
FrameSettingsUI.Inspector
),
CED.space,
CED.Action(Drawer_SectionBakeButton)
);
}
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;
const EditMode.SceneViewEditMode EditMirrorPosition = EditMode.SceneViewEditMode.GridMove;
const EditMode.SceneViewEditMode EditMirrorRotation = EditMode.SceneViewEditMode.GridSelect;
static void Drawer_SectionCaptureStatic(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.captureLocalPosition, _.GetContent("Capture Local Position"));
_.DrawMultipleFields(
"Clipping Planes",
new[] { d.captureNearPlane, d.captureFarPlane },
new[] { _.GetContent("Near|The closest point relative to the camera that drawing will occur."), _.GetContent("Far|The furthest point relative to the camera that drawing will occur.\n") });
}
static void Drawer_SectionCaptureMirror(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
// EditorGUILayout.PropertyField(d.captureMirrorPlaneLocalPosition, _.GetContent("Plane Position"));
// EditorGUILayout.PropertyField(d.captureMirrorPlaneLocalNormal, _.GetContent("Plane Normal"));
}
static void Drawer_DifferentShapeError(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
var proxy = d.proxyVolumeReference.objectReferenceValue as ReflectionProxyVolumeComponent;
if (proxy != null && (int)proxy.proxyVolume.shape != d.influenceVolume.shape.enumValueIndex)
{
EditorGUILayout.HelpBox(
"Proxy volume and influence volume have different shape types, this is not supported.",
MessageType.Error,
true
);
}
}
static void Drawer_SectionCaptureSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
GUI.enabled = false;
EditorGUILayout.LabelField(
_.GetContent("Probe Texture Size (Set By HDRP)"),
_.GetContent(hdrp.renderPipelineSettings.lightLoopSettings.planarReflectionTextureSize.ToString()),
EditorStyles.label);
EditorGUILayout.Toggle(
_.GetContent("Probe Compression (Set By HDRP)"),
hdrp.renderPipelineSettings.lightLoopSettings.planarReflectionCacheCompressed);
GUI.enabled = true;
EditorGUILayout.PropertyField(d.overrideFieldOfView, _.GetContent("Override FOV"));
if (d.overrideFieldOfView.boolValue)
{
++EditorGUI.indentLevel;
EditorGUILayout.PropertyField(d.fieldOfViewOverride, _.GetContent("Field Of View"));
--EditorGUI.indentLevel;
}
}
static void Drawer_SectionProbeModeCustomSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
d.customTexture.objectReferenceValue = EditorGUILayout.ObjectField(_.GetContent("Capture"), d.customTexture.objectReferenceValue, typeof(Texture), false);
var texture = d.customTexture.objectReferenceValue as Texture;
if (texture != null && texture.dimension != TextureDimension.Tex2D)
EditorGUILayout.HelpBox("Provided Texture is not a 2D Texture, it will be ignored", MessageType.Warning);
}
static void Drawer_SectionBakeButton(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)d.mode.intValue, d.target);
}
static void Drawer_SectionProbeModeRealtimeSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
GUI.enabled = false;
EditorGUILayout.PropertyField(d.refreshMode, _.GetContent("Refresh Mode"));
EditorGUILayout.PropertyField(d.capturePositionMode, _.GetContent("Capture Position Mode"));
GUI.enabled = true;
}
static void Drawer_SectionProxySettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.proxyVolumeReference, _.GetContent("Reference"));
if (d.proxyVolumeReference.objectReferenceValue != null)
{
var proxy = (ReflectionProxyVolumeComponent)d.proxyVolumeReference.objectReferenceValue;
if ((int)proxy.proxyVolume.shape != d.influenceVolume.shape.enumValueIndex)
EditorGUILayout.HelpBox(
"Proxy volume and influence volume have different shape types, this is not supported.",
MessageType.Error,
true
);
}
else
{
EditorGUILayout.HelpBox(
"When no Proxy setted, Influence shape will be used as Proxy shape too.",
MessageType.Info,
true
);
}
}
static void Drawer_SectionInfluenceSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.weight, _.GetContent("Weight"));
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(d.multiplier, _.GetContent("Multiplier"));
if (EditorGUI.EndChangeCheck())
d.multiplier.floatValue = Mathf.Max(0.0f, d.multiplier.floatValue);
}
static void Drawer_FieldCaptureType(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
GUI.enabled = false;
EditorGUILayout.PropertyField(d.mode, _.GetContent("Type"));
GUI.enabled = true;
}
static readonly EditMode.SceneViewEditMode[] k_Toolbar_SceneViewEditModes =
{
EditBaseShape,
EditInfluenceShape,
EditInfluenceNormalShape,
//EditCenter
};
static readonly EditMode.SceneViewEditMode[] k_Toolbar_Static_SceneViewEditModes =
{
//EditCenter //offset have no meanings with planar
};
static readonly EditMode.SceneViewEditMode[] k_Toolbar_Mirror_SceneViewEditModes =
{
//EditMirrorPosition, //offset have no meanings with planar
EditMirrorRotation
};
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)"),
});
}
}
static GUIContent[] s_Toolbar_Static_Contents = null;
static GUIContent[] toolbar_Static_Contents
{
get
{
return s_Toolbar_Static_Contents ?? (s_Toolbar_Static_Contents = new GUIContent[]
{
//EditorGUIUtility.IconContent("MoveTool", "|Move the capture position.") //offset have no meanings with planar
});
}
}
static GUIContent[] s_Toolbar_Mirror_Contents = null;
static GUIContent[] toolbar_Mirror_Contents
{
get
{
return s_Toolbar_Mirror_Contents ?? (s_Toolbar_Mirror_Contents = new[]
{
//EditorGUIUtility.IconContent("MoveTool", "|Move the mirror plane."), //offset have no meanings with planar
EditorGUIUtility.IconContent("RotateTool", "|Rotate the mirror plane.")
});
}
}
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);
if (d.isMirrored)
EditMode.DoInspectorToolbar(k_Toolbar_Mirror_SceneViewEditModes, toolbar_Mirror_Contents, GetBoundsGetter(o), o);
else
EditMode.DoInspectorToolbar(k_Toolbar_Static_SceneViewEditModes, toolbar_Static_Contents, GetBoundsGetter(o), o);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
static public void Drawer_ToolBarButton(int buttonIndex, Editor owner, params GUILayoutOption[] styles)
{
if (GUILayout.Button(toolbar_Contents[buttonIndex], styles))
{
EditMode.ChangeEditMode(k_Toolbar_SceneViewEditModes[buttonIndex], GetBoundsGetter(owner)(), owner);
}
}
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;
};
}
}
}

34
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Skin.cs


using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
partial class InfluenceVolumeUI
{
static readonly Color k_GizmoThemeColorBase = new Color(255f / 255f, 229f / 255f, 148f / 255f, 80f / 255f);
static readonly Color k_GizmoThemeColorBaseFace = new Color(255f / 255f, 229f / 255f, 148f / 255f, 45f / 255f);
static readonly Color k_GizmoThemeColorInfluence = new Color(83f / 255f, 255f / 255f, 95f / 255f, 75f / 255f);
static readonly Color k_GizmoThemeColorInfluenceFace = new Color(83f / 255f, 255f / 255f, 95f / 255f, 17f / 255f);
static readonly Color k_GizmoThemeColorInfluenceNormal = new Color(0f / 255f, 229f / 255f, 255f / 255f, 80f / 255f);
static readonly Color k_GizmoThemeColorInfluenceNormalFace = new Color(0f / 255f, 229f / 255f, 255f / 255f, 36f / 255f);
static readonly Color k_GizmoThemeColorProjection = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
static readonly Color k_GizmoThemeColorProjectionFace = new Color(0x00 / 255f, 0xE5 / 255f, 0xFF / 255f, 0x20 / 255f);
static readonly Color k_GizmoThemeColorDisabled = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
static readonly Color k_GizmoThemeColorDisabledFace = new Color(0x99 / 255f, 0x89 / 255f, 0x59 / 255f, 0x10 / 255f);
static readonly GUIContent shapeContent = CoreEditorUtils.GetContent("Shape");
static readonly GUIContent boxSizeContent = CoreEditorUtils.GetContent("Box Size|The size of the box in which the reflections will be applied to objects. The value is not affected by the Transform of the Game Object.");
static readonly GUIContent offsetContent = CoreEditorUtils.GetContent("Offset|The center of the InfluenceVolume in which the reflections will be applied to objects. The value is relative to the position of the Game Object.");
static readonly GUIContent blendDistanceContent = CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes.");
static readonly GUIContent blendNormalDistanceContent = CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes.");
static readonly GUIContent faceFadeContent = CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap.");
static readonly GUIContent radiusContent = CoreEditorUtils.GetContent("Radius");
static readonly GUIContent normalModeContent = CoreEditorUtils.GetContent("Normal|Normal parameters mode (only change for box shape).");
static readonly GUIContent advancedModeContent = CoreEditorUtils.GetContent("Advanced|Advanced parameters mode (only change for box shape).");
static readonly string influenceVolumeHeader = "Influence Volume";
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/Volume/InfluenceVolumeUI.Skin.cs.meta


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

80
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeEditor.cs


using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor.Callbacks;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
using Object = UnityEngine.Object;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
abstract class HDProbeEditor : Editor
{
static Dictionary<HDProbe, HDProbeUI> s_StateMap = new Dictionary<HDProbe, HDProbeUI>();
internal static bool TryGetUIStateFor(HDProbe p, out HDProbeUI r)
{
return s_StateMap.TryGetValue(p, out r);
}
internal abstract HDProbe GetTarget(Object editorTarget);
protected SerializedHDProbe m_SerializedHDProbe;
HDProbeUI m_UIState;
HDProbeUI[] m_UIHandleState;
protected HDProbe[] m_TypedTargets;
protected virtual void OnEnable()
{
if(m_UIState == null)
{
m_UIState = HDProbeUI.CreateFor(this);
}
m_UIState.Reset(m_SerializedHDProbe, Repaint);
m_TypedTargets = new HDProbe[targets.Length];
m_UIHandleState = new HDProbeUI[m_TypedTargets.Length];
for (var i = 0; i < m_TypedTargets.Length; i++)
{
m_TypedTargets[i] = GetTarget(targets[i]);
m_UIHandleState[i] = HDProbeUI.CreateFor(m_TypedTargets[i]);
m_UIHandleState[i].Reset(m_SerializedHDProbe, null);
s_StateMap[m_TypedTargets[i]] = m_UIHandleState[i];
}
}
protected virtual void OnDisable()
{
for (var i = 0; i < m_TypedTargets.Length; i++)
s_StateMap.Remove(m_TypedTargets[i]);
}
protected abstract void Draw(HDProbeUI s, SerializedHDProbe serialized, Editor owner);
public override void OnInspectorGUI()
{
var s = m_UIState;
var d = m_SerializedHDProbe;
var o = this;
s.Update();
d.Update();
Draw(s, d, o);
d.Apply();
}
protected virtual void OnSceneGUI()
{
//mandatory update as for strange reason the serialized rollback one update here
m_UIState.Update();
m_SerializedHDProbe.Update();
HDProbeUI.DrawHandles(m_UIState, m_SerializedHDProbe, this);
m_UIState.DoShortcutKey(this);
}
}
}

297
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs


using System;
using System.Collections.Generic;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using _ = CoreEditorUtils;
using CED = CoreEditorDrawer<HDProbeUI, SerializedHDProbe>;
partial class HDProbeUI
{
public static readonly CED.IDrawer SectionProbeModeSettings;
public static readonly CED.IDrawer ProxyVolumeSettings = CED.FoldoutGroup(
proxySettingsHeader,
(s, d, o) => s.isSectionExpendedProxyVolume,
FoldoutOption.Indent,
CED.Action(Drawer_SectionProxySettings)
);
public static readonly CED.IDrawer SectionProbeModeBakedSettings = CED.noop;
public static readonly CED.IDrawer SectionProbeModeRealtimeSettings = CED.Action(Drawer_SectionProbeModeRealtimeSettings);
public static readonly CED.IDrawer SectionBakeButton = CED.Action(Drawer_SectionBakeButton);
public static readonly CED.IDrawer SectionFoldoutAdditionalSettings = CED.FoldoutGroup(
additionnalSettingsHeader,
(s, d, o) => s.isSectionExpendedAdditionalSettings,
FoldoutOption.Indent,
CED.Action(Drawer_SectionCustomSettings)
);
static HDProbeUI()
{
SectionProbeModeSettings = CED.Group(
CED.Action(Drawer_FieldCaptureType),
CED.FadeGroup(
(s, d, o, i) => s.IsSectionExpandedReflectionProbeMode((ReflectionProbeMode)i),
FadeOption.Indent,
SectionProbeModeBakedSettings,
SectionProbeModeRealtimeSettings
)
);
}
protected static void Drawer_DifferentShapeError(HDProbeUI s, SerializedHDProbe d, Editor o)
{
var proxy = d.proxyVolumeReference.objectReferenceValue as ReflectionProxyVolumeComponent;
if (proxy != null
&& (int)proxy.proxyVolume.shape != d.influenceVolume.shape.enumValueIndex
&& proxy.proxyVolume.shape != ProxyShape.Infinite)
{
EditorGUILayout.HelpBox(
proxyInfluenceShapeMismatchHelpBoxText,
MessageType.Error,
true
);
}
}
static GUIStyle disabled;
static void PropertyField(SerializedProperty prop, GUIContent content)
{
if(prop != null)
{
EditorGUILayout.PropertyField(prop, content);
}
else
{
if(disabled == null)
{
disabled = new GUIStyle(GUI.skin.label);
disabled.onNormal.textColor *= 0.5f;
}
EditorGUILayout.LabelField(content, disabled);
}
}
protected static void Drawer_SectionBakeButton(HDProbeUI s, SerializedHDProbe d, Editor o)
{
if (d.target is HDAdditionalReflectionData)
EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)d.mode.intValue, ((HDAdditionalReflectionData)d.target).reflectionProbe);
else //PlanarReflectionProbe
EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)d.mode.intValue, d.target as PlanarReflectionProbe);
}
static void Drawer_SectionProbeModeRealtimeSettings(HDProbeUI s, SerializedHDProbe d, Editor o)
{
GUI.enabled = false;
EditorGUILayout.PropertyField(d.refreshMode, _.GetContent("Refresh Mode"));
GUI.enabled = true;
}
protected static void Drawer_SectionProxySettings(HDProbeUI s, SerializedHDProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.proxyVolumeReference, proxyVolumeContent);
if (d.target.proxyVolume == null)
{
EditorGUI.BeginChangeCheck();
d.infiniteProjection.boolValue = !EditorGUILayout.Toggle(useInfiniteProjectionContent, !d.infiniteProjection.boolValue);
if(EditorGUI.EndChangeCheck())
{
d.Apply();
}
}
if (d.proxyVolumeReference.objectReferenceValue != null)
{
var proxy = (ReflectionProxyVolumeComponent)d.proxyVolumeReference.objectReferenceValue;
if ((int)proxy.proxyVolume.shape != d.influenceVolume.shape.enumValueIndex
&& proxy.proxyVolume.shape != ProxyShape.Infinite)
EditorGUILayout.HelpBox(
proxyInfluenceShapeMismatchHelpBoxText,
MessageType.Error,
true
);
}
else
{
EditorGUILayout.HelpBox(
d.infiniteProjection.boolValue ? noProxyInfiniteHelpBoxText : noProxyHelpBoxText,
MessageType.Info,
true
);
}
}
protected static void Drawer_SectionCustomSettings(HDProbeUI s, SerializedHDProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.weight, weightContent);
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(d.multiplier, multiplierContent);
if (EditorGUI.EndChangeCheck())
d.multiplier.floatValue = Mathf.Max(0.0f, d.multiplier.floatValue);
}
static void Drawer_FieldCaptureType(HDProbeUI s, SerializedHDProbe d, Editor o)
{
GUI.enabled = false;
EditorGUILayout.PropertyField(d.mode, fieldCaptureTypeContent);
GUI.enabled = true;
}
[Flags]
internal enum ToolBar
{
InfluenceShape = 1<<0,
Blend = 1<<1,
NormalBlend = 1<<2,
CapturePosition = 1<<3
}
protected ToolBar[] toolBars = null;
protected const EditMode.SceneViewEditMode EditBaseShape = EditMode.SceneViewEditMode.ReflectionProbeBox;
protected const EditMode.SceneViewEditMode EditInfluenceShape = EditMode.SceneViewEditMode.GridBox;
protected const EditMode.SceneViewEditMode EditInfluenceNormalShape = EditMode.SceneViewEditMode.Collider;
protected const EditMode.SceneViewEditMode EditCenter = EditMode.SceneViewEditMode.GridMove;
//Note: EditMode.SceneViewEditMode.ReflectionProbeOrigin is still used
//by legacy reflection probe and have its own mecanism that we don't want
internal static bool IsProbeEditMode(EditMode.SceneViewEditMode editMode)
{
return editMode == EditBaseShape
|| editMode == EditInfluenceShape
|| editMode == EditInfluenceNormalShape
|| editMode == EditCenter;
}
static Dictionary<ToolBar, EditMode.SceneViewEditMode> s_Toolbar_Mode = null;
protected static Dictionary<ToolBar, EditMode.SceneViewEditMode> toolbar_Mode
{
get
{
return s_Toolbar_Mode ?? (s_Toolbar_Mode = new Dictionary<ToolBar, EditMode.SceneViewEditMode>
{
{ ToolBar.InfluenceShape, EditBaseShape },
{ ToolBar.Blend, EditInfluenceShape },
{ ToolBar.NormalBlend, EditInfluenceNormalShape },
{ ToolBar.CapturePosition, EditCenter }
});
}
}
//[TODO] change this to be modifiable shortcuts
static Dictionary<KeyCode, ToolBar> s_Toolbar_ShortCutKey = null;
protected static Dictionary<KeyCode, ToolBar> toolbar_ShortCutKey
{
get
{
return s_Toolbar_ShortCutKey ?? (s_Toolbar_ShortCutKey = new Dictionary<KeyCode, ToolBar>
{
{ KeyCode.Alpha1, ToolBar.InfluenceShape },
{ KeyCode.Alpha2, ToolBar.Blend },
{ KeyCode.Alpha3, ToolBar.NormalBlend },
{ KeyCode.Alpha4, ToolBar.CapturePosition }
});
}
}
protected static void Drawer_Toolbars(HDProbeUI s, SerializedHDProbe d, Editor o)
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.changed = false;
foreach(ToolBar toolBar in s.toolBars)
{
List<EditMode.SceneViewEditMode> listMode = new List<EditMode.SceneViewEditMode>();
List<GUIContent> listContent = new List<GUIContent>();
if ((toolBar & ToolBar.InfluenceShape) > 0)
{
listMode.Add(toolbar_Mode[ToolBar.InfluenceShape]);
listContent.Add(toolbar_Contents[ToolBar.InfluenceShape]);
}
if ((toolBar & ToolBar.Blend) > 0)
{
listMode.Add(toolbar_Mode[ToolBar.Blend]);
listContent.Add(toolbar_Contents[ToolBar.Blend]);
}
if ((toolBar & ToolBar.NormalBlend) > 0)
{
listMode.Add(toolbar_Mode[ToolBar.NormalBlend]);
listContent.Add(toolbar_Contents[ToolBar.NormalBlend]);
}
if ((toolBar & ToolBar.CapturePosition) > 0)
{
listMode.Add(toolbar_Mode[ToolBar.CapturePosition]);
listContent.Add(toolbar_Contents[ToolBar.CapturePosition]);
}
EditMode.DoInspectorToolbar(listMode.ToArray(), listContent.ToArray(), GetBoundsGetter(o), o);
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
static internal void Drawer_ToolBarButton(ToolBar button, Editor owner, params GUILayoutOption[] options)
{
bool enabled = toolbar_Mode[button] == EditMode.editMode;
EditorGUI.BeginChangeCheck();
enabled = GUILayout.Toggle(enabled, toolbar_Contents[button], EditorStyles.miniButton, options);
if (EditorGUI.EndChangeCheck())
{
EditMode.SceneViewEditMode targetMode = EditMode.editMode == toolbar_Mode[button] ? EditMode.SceneViewEditMode.None : toolbar_Mode[button];
EditMode.ChangeEditMode(targetMode, GetBoundsGetter(owner)(), owner);
}
}
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;
};
}
public void DoShortcutKey(Editor owner)
{
var evt = Event.current;
if (evt.type != EventType.KeyDown || !evt.shift)
return;
ToolBar toolbar;
if(toolbar_ShortCutKey.TryGetValue(evt.keyCode, out toolbar))
{
bool used = false;
foreach(ToolBar t in toolBars)
{
if((t&toolbar)>0)
{
used = true;
break;
}
}
if (!used)
{
return;
}
var targetMode = toolbar_Mode[toolbar];
var mode = EditMode.editMode == targetMode ? EditMode.SceneViewEditMode.None : targetMode;
EditMode.ChangeEditMode(mode, GetBoundsGetter(owner)(), owner);
evt.Use();
}
}
}
}

101
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Handles.cs


using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
partial class HDProbeUI
{
internal static void DrawHandles(HDProbeUI s, SerializedHDProbe d, Editor o)
{
HDProbe probe = d.target as HDProbe;
var mat = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one);
switch (EditMode.editMode)
{
case EditBaseShape:
InfluenceVolumeUI.DrawHandles_EditBase(s.influenceVolume, d.influenceVolume, o, mat, probe);
break;
case EditInfluenceShape:
InfluenceVolumeUI.DrawHandles_EditInfluence(s.influenceVolume, d.influenceVolume, o, mat, probe);
break;
case EditInfluenceNormalShape:
InfluenceVolumeUI.DrawHandles_EditInfluenceNormal(s.influenceVolume, d.influenceVolume, o, mat, probe);
break;
case EditCenter:
{
using (new Handles.DrawingScope(Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one)))
{
Vector3 offsetWorld = probe.transform.position + probe.transform.rotation * probe.influenceVolume.offset;
EditorGUI.BeginChangeCheck();
var newOffsetWorld = Handles.PositionHandle(offsetWorld, probe.transform.rotation);
if (EditorGUI.EndChangeCheck())
{
Vector3 newOffset = Quaternion.Inverse(probe.transform.rotation) * (newOffsetWorld - probe.transform.position);
Undo.RecordObjects(new Object[] { probe, probe.transform }, "Translate Influence Position");
d.influenceVolume.offset.vector3Value = newOffset;
d.influenceVolume.Apply();
//call modification to legacy ReflectionProbe
probe.influenceVolume.offset = newOffset;
}
}
break;
}
}
}
[DrawGizmo(GizmoType.Selected)]
internal static void DrawGizmos(HDProbe d, GizmoType gizmoType)
{
HDProbeUI s;
if (!HDProbeEditor.TryGetUIStateFor(d, out s))
return;
var mat = Matrix4x4.TRS(d.transform.position, d.transform.rotation, Vector3.one);
switch (EditMode.editMode)
{
case EditBaseShape:
InfluenceVolumeUI.DrawGizmos(
s.influenceVolume, d.influenceVolume, mat,
InfluenceVolumeUI.HandleType.Base,
InfluenceVolumeUI.HandleType.All);
break;
case EditInfluenceShape:
InfluenceVolumeUI.DrawGizmos(
s.influenceVolume,
d.influenceVolume,
mat,
InfluenceVolumeUI.HandleType.Influence,
InfluenceVolumeUI.HandleType.All);
break;
case EditInfluenceNormalShape:
InfluenceVolumeUI.DrawGizmos(
s.influenceVolume,
d.influenceVolume,
mat,
InfluenceVolumeUI.HandleType.InfluenceNormal,
InfluenceVolumeUI.HandleType.All);
break;
default:
{
var showedHandles = s.influenceVolume.showInfluenceHandles
? InfluenceVolumeUI.HandleType.All
: InfluenceVolumeUI.HandleType.Base;
InfluenceVolumeUI.DrawGizmos(
s.influenceVolume,
d.influenceVolume,
mat,
InfluenceVolumeUI.HandleType.None,
showedHandles);
break;
}
}
if (d.proxyVolume != null)
ReflectionProxyVolumeComponentUI.DrawGizmos_EditNone(d.proxyVolume);
}
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Handles.cs.meta


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

77
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Skin.cs


using System;
using System.Collections.Generic;
using UnityEditor.AnimatedValues;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
partial class HDProbeUI
{
static readonly Color[][] k_handlesColor = new Color[][]
{
new Color[]
{
Color.red,
Color.green,
Color.blue
},
new Color[]
{
new Color(.5f, 0f, 0f, 1f),
new Color(0f, .5f, 0f, 1f),
new Color(0f, 0f, .5f, 1f)
}
};
static readonly GUIContent bakeTypeContent = CoreEditorUtils.GetContent("Type|'Baked Cubemap' uses the 'Auto Baking' mode from the Lighting window. If it is enabled then baking is automatic otherwise manual bake is needed (use the bake button below). \n'Custom' can be used if a custom cubemap is wanted. \n'Realtime' can be used to dynamically re-render the cubemap during runtime (via scripting).");
static readonly GUIContent proxyVolumeContent = CoreEditorUtils.GetContent("Proxy Volume");
protected static readonly GUIContent useInfiniteProjectionContent = CoreEditorUtils.GetContent("Same As Influence Volume|If enabled, parallax correction will occure, causing reflections to appear to change based on the object's position within the probe's box, while still using a single probe as the source of the reflection. This works well for reflections on objects that are moving through enclosed spaces such as corridors and rooms. When disabled, the cubemap reflection will be treated as coming from infinitely far away. Note that this feature can be globally disabled from Graphics Settings -> Tier Settings");
static readonly GUIContent normalModeContent = CoreEditorUtils.GetContent("Normal|Normal parameters mode (only change for box shape).");
static readonly GUIContent advancedModeContent = CoreEditorUtils.GetContent("Advanced|Advanced parameters mode (only change for box shape).");
protected static readonly GUIContent fieldCaptureTypeContent = CoreEditorUtils.GetContent("Type");
protected static readonly GUIContent resolutionContent = CoreEditorUtils.GetContent("Resolution");
protected static readonly GUIContent shadowDistanceContent = CoreEditorUtils.GetContent("Shadow Distance");
protected static readonly GUIContent cullingMaskContent = CoreEditorUtils.GetContent("Culling Mask");
protected static readonly GUIContent useOcclusionCullingContent = CoreEditorUtils.GetContent("Use Occlusion Culling");
protected static readonly GUIContent nearClipCullingContent = CoreEditorUtils.GetContent("Near Clip");
protected static readonly GUIContent farClipCullingContent = CoreEditorUtils.GetContent("Far Clip");
static readonly GUIContent weightContent = CoreEditorUtils.GetContent("Weight|Blend weight applied on this reflection probe. This can be used for fading in or out a reflection probe.");
static readonly GUIContent multiplierContent = CoreEditorUtils.GetContent("Intensity Multiplier|Allows you to boost or dimmer the reflected cubemap. Values above 1 will make reflections brighter and values under 1 will make reflections darker. Using values different than 1 is not physically correct.");
static readonly GUIContent textureSizeContent = CoreEditorUtils.GetContent("Probe Texture Size (Set By HDRP)");
static readonly GUIContent compressionTextureContent = CoreEditorUtils.GetContent("Probe Compression (Set By HDRP)");
const string mimapHelpBoxText = "No mipmaps in the cubemap, Smoothness value in Standard shader will be ignored.";
const string noProxyHelpBoxText = "Influence shape will be used as Projection shape too.";
const string noProxyInfiniteHelpBoxText = "Projection will be at infinite.";
const string proxyInfluenceShapeMismatchHelpBoxText = "Proxy volume and influence volume have different shapes, this is not supported.";
const string proxySettingsHeader = "Projection Settings";
//influenceVolume have its own header
protected const string captureSettingsHeader = "Capture Settings";
const string additionnalSettingsHeader = "Custom Settings";
static Dictionary<ToolBar, GUIContent> s_Toolbar_Contents = null;
protected static Dictionary<ToolBar, GUIContent> toolbar_Contents
{
get
{
return s_Toolbar_Contents ?? (s_Toolbar_Contents = new Dictionary<ToolBar, GUIContent>
{
{ ToolBar.InfluenceShape, EditorGUIUtility.IconContent("EditCollider", "|Modify the base shape. (SHIFT+1)") },
{ ToolBar.Blend, EditorGUIUtility.IconContent("PreMatCube", "|Modify the influence volume. (SHIFT+2)") },
{ ToolBar.NormalBlend, EditorGUIUtility.IconContent("SceneViewOrtho", "|Modify the influence normal volume. (SHIFT+3)") },
{ ToolBar.CapturePosition, EditorGUIUtility.IconContent("MoveTool", "|Change the Offset of the shape.") }
});
}
}
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Skin.cs.meta


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

90
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.cs


using System;
using UnityEditor.AnimatedValues;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
abstract partial class HDProbeUI : BaseUI<SerializedHDProbe>
{
const int k_AnimBoolSingleFieldCount = 6;
static readonly int k_ReflectionProbeModeCount = Enum.GetValues(typeof(ReflectionProbeMode)).Length;
static readonly int k_ReflectionInfluenceShapeCount = Enum.GetValues(typeof(InfluenceShape)).Length;
static readonly int k_AnimBoolTotal = k_ReflectionProbeModeCount + k_AnimBoolSingleFieldCount + k_ReflectionInfluenceShapeCount;
public InfluenceVolumeUI influenceVolume = new InfluenceVolumeUI();
public FrameSettingsUI frameSettings = new FrameSettingsUI();
public ReflectionProxyVolumeComponentUI reflectionProxyVolume = new ReflectionProxyVolumeComponentUI();
public AnimBool isSectionExpandedInfluenceSettings { get { return m_AnimBools[k_ReflectionProbeModeCount]; } }
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[k_ReflectionProbeModeCount + 1]; } }
public AnimBool isSectionExpandedCaptureMirrorSettings { get { return m_AnimBools[k_ReflectionProbeModeCount + 2]; } }
public AnimBool isSectionExpandedCaptureStaticSettings { get { return m_AnimBools[k_ReflectionProbeModeCount + 3]; } }
public AnimBool isSectionExpendedProxyVolume { get { return m_AnimBools[k_ReflectionProbeModeCount + 4]; } }
public AnimBool isSectionExpendedAdditionalSettings { get { return m_AnimBools[k_ReflectionProbeModeCount + 5]; } }
public bool showCaptureHandles { get; set; }
internal static HDProbeUI CreateFor(HDProbeEditor o)
{
if (o is PlanarReflectionProbeEditor)
return new PlanarReflectionProbeUI();
else
return new HDReflectionProbeUI();
}
internal static HDProbeUI CreateFor(HDProbe p)
{
if (p is PlanarReflectionProbe)
return new PlanarReflectionProbeUI();
else
return new HDReflectionProbeUI();
}
public HDProbeUI()
: base(k_AnimBoolTotal)
{
isSectionExpandedInfluenceSettings.value = true;
isSectionExpandedCaptureSettings.value = true;
isSectionExpendedProxyVolume.value = true;
isSectionExpendedAdditionalSettings.value = false;
}
public AnimBool IsSectionExpandedReflectionProbeMode(ReflectionProbeMode mode)
{
return m_AnimBools[(int)mode];
}
public void SetModeTarget(int value)
{
for (var i = 0; i < k_ReflectionProbeModeCount; i++)
GetReflectionProbeModeBool(i).target = i == value;
}
AnimBool GetReflectionProbeModeBool(int i)
{
return m_AnimBools[i];
}
public override void Reset(SerializedHDProbe data, UnityAction repaint)
{
frameSettings.Reset(data.frameSettings, repaint);
influenceVolume.Reset(data.influenceVolume, repaint);
base.Reset(data, repaint);
}
public override void Update()
{
for (var i = 0; i < k_ReflectionProbeModeCount; i++)
m_AnimBools[i].target = i == data.mode.intValue;
SetModeTarget(data.mode.hasMultipleDifferentValues ? -1 : data.mode.intValue);
influenceVolume.SetIsSectionExpanded_Shape(data.influenceVolume.shape.hasMultipleDifferentValues ? -1 : data.influenceVolume.shape.intValue);
frameSettings.Update();
influenceVolume.Update();
base.Update();
}
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.cs.meta


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

57
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs


using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
internal abstract class SerializedHDProbe
{
internal SerializedObject serializedObject;
internal SerializedProperty proxyVolumeReference;
internal SerializedProperty infiniteProjection;
internal SerializedInfluenceVolume influenceVolume;
internal SerializedFrameSettings frameSettings;
internal SerializedProperty weight;
internal SerializedProperty multiplier;
internal SerializedProperty mode;
internal SerializedProperty refreshMode;
internal SerializedProperty resolution;
internal SerializedProperty shadowDistance;
internal SerializedProperty cullingMask;
internal SerializedProperty useOcclusionCulling;
internal SerializedProperty nearClip;
internal SerializedProperty farClip;
internal HDProbe target { get { return serializedObject.targetObject as HDProbe; } }
internal SerializedHDProbe(SerializedObject serializedObject)
{
this.serializedObject = serializedObject;
proxyVolumeReference = serializedObject.Find((HDProbe p) => p.proxyVolume);
influenceVolume = new SerializedInfluenceVolume(serializedObject.Find((HDProbe p) => p.influenceVolume));
infiniteProjection = serializedObject.Find((HDProbe p) => p.infiniteProjection);
frameSettings = new SerializedFrameSettings(serializedObject.Find((HDProbe p) => p.frameSettings));
weight = serializedObject.Find((HDProbe p) => p.weight);
multiplier = serializedObject.Find((HDProbe p) => p.multiplier);
mode = serializedObject.Find((HDProbe p) => p.mode);
refreshMode = serializedObject.Find((HDProbe p) => p.refreshMode);
}
internal virtual void Update()
{
serializedObject.Update();
//InfluenceVolume does not have Update. Add it here if it have in the future.
}
internal virtual void Apply()
{
serializedObject.ApplyModifiedProperties();
}
}
}

11
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/SerializedHDProbe.cs.meta


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

/com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.ContextualMenu.cs.meta → /com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/ReflectionMenuItem.cs.meta

/com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.ContextualMenu.cs → /com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/ReflectionMenuItem.cs

/com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeUI.Drawers.cs.meta → /com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/PlanarReflectionProbeUI.Drawers.cs.meta

/com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDProbeEditor.cs.meta → /com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Handles.cs.meta

正在加载...
取消
保存