浏览代码

[PlanarReflection] Added Bake button (wip)

/main
Frédéric Vauchelles 7 年前
当前提交
d3b61a0b
共有 11 个文件被更改,包括 388 次插入158 次删除
  1. 60
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditorUtility.cs
  2. 82
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeUI.Drawers.cs
  3. 46
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeEditor.cs
  4. 74
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.Drawers.cs
  5. 18
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/PlanarReflectionProbeUI.cs
  6. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedPlanarReflectionProbe.cs
  7. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/PlanarReflectionProbe.cs
  8. 92
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/EditorReflectionSystem.cs
  9. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/EditorReflectionSystem.cs.meta
  10. 136
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/EditorReflectionSystemGUI.cs
  11. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/EditorReflectionSystemGUI.cs.meta

60
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditorUtility.cs


using System;
using System;
using System.IO;
using System.Linq;
using System.Reflection;

}
}
return false;
}
static MethodInfo k_Lightmapping_BakeReflectionProbeSnapshot = typeof(UnityEditor.Lightmapping).GetMethod("BakeReflectionProbeSnapshot", BindingFlags.Static | BindingFlags.NonPublic);
public static bool BakeReflectionProbeSnapshot(ReflectionProbe probe)
{
return (bool)k_Lightmapping_BakeReflectionProbeSnapshot.Invoke(null, new object[] { probe });
}
static MethodInfo k_Lightmapping_BakeAllReflectionProbesSnapshots = typeof(UnityEditor.Lightmapping).GetMethod("BakeAllReflectionProbesSnapshots", BindingFlags.Static | BindingFlags.NonPublic);
public static bool BakeAllReflectionProbesSnapshots()
{
return (bool)k_Lightmapping_BakeAllReflectionProbesSnapshots.Invoke(null, new object[0]);
}
public static void BakeCustomReflectionProbe(ReflectionProbe probe, bool usePreviousAssetPath, bool custom)
{
if (!custom && probe.bakedTexture != null)
probe.customBakedTexture = probe.bakedTexture;
string path = "";
if (usePreviousAssetPath)
path = AssetDatabase.GetAssetPath(probe.customBakedTexture);
string targetExtension = probe.hdr ? "exr" : "png";
if (string.IsNullOrEmpty(path) || Path.GetExtension(path) != "." + targetExtension)
{
// We use the path of the active scene as the target path
var targetPath = SceneManager.GetActiveScene().path;
targetPath = Path.Combine(Path.GetDirectoryName(targetPath), Path.GetFileNameWithoutExtension(targetPath));
if (string.IsNullOrEmpty(targetPath))
targetPath = "Assets";
else if (Directory.Exists(targetPath) == false)
Directory.CreateDirectory(targetPath);
string fileName = probe.name + (probe.hdr ? "-reflectionHDR" : "-reflection") + "." + targetExtension;
fileName = Path.GetFileNameWithoutExtension(AssetDatabase.GenerateUniqueAssetPath(Path.Combine(targetPath, fileName)));
path = EditorUtility.SaveFilePanelInProject("Save reflection probe's cubemap.", fileName, targetExtension, "", targetPath);
if (string.IsNullOrEmpty(path))
return;
ReflectionProbe collidingProbe;
if (HDReflectionProbeEditorUtility.IsCollidingWithOtherProbes(path, probe, out collidingProbe))
{
if (!EditorUtility.DisplayDialog("Cubemap is used by other reflection probe",
string.Format("'{0}' path is used by the game object '{1}', do you really want to overwrite it?",
path, collidingProbe.name), "Yes", "No"))
{
return;
}
}
}
EditorUtility.DisplayProgressBar("Reflection Probes", "Baking " + path, 0.5f);
if (!UnityEditor.Lightmapping.BakeReflectionProbe(probe, path))
Debug.LogError("Failed to bake reflection probe to " + path);
EditorUtility.ClearProgressBar();
}
public static void ResetProbeSceneTextureInMaterial(ReflectionProbe p)

82
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeUI.Drawers.cs


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

}
}
static readonly string[] k_BakeCustomOptionText = { "Bake as new Cubemap..." };
static readonly string[] k_BakeButtonsText = { "Bake All Reflection Probes" };
if (p.mode.intValue == (int)ReflectionProbeMode.Realtime)
{
EditorGUILayout.HelpBox("Refresh of this reflection probe should be initiated from the scripting API because the type is 'Realtime'", MessageType.Info);
if (!QualitySettings.realtimeReflectionProbes)
EditorGUILayout.HelpBox("Realtime reflection probes are disabled in Quality Settings", MessageType.Warning);
return;
}
if (p.mode.intValue == (int)ReflectionProbeMode.Baked && UnityEditor.Lightmapping.giWorkflowMode != UnityEditor.Lightmapping.GIWorkflowMode.OnDemand)
{
EditorGUILayout.HelpBox("Baking of this reflection probe is automatic because this probe's type is 'Baked' and the Lighting window is using 'Auto Baking'. The cubemap created is stored in the GI cache.", MessageType.Info);
return;
}
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
switch ((ReflectionProbeMode)p.mode.intValue)
{
case ReflectionProbeMode.Custom:
{
if (ButtonWithDropdownList(
CoreEditorUtils.GetContent("Bake|Bakes Reflection Probe's cubemap, overwriting the existing cubemap texture asset (if any)."), k_BakeCustomOptionText,
data =>
{
var mode = (int)data;
var probe = p.target;
if (mode == 0)
{
HDReflectionProbeEditorUtility.BakeCustomReflectionProbe(probe, false, true);
HDReflectionProbeEditorUtility.ResetProbeSceneTextureInMaterial(probe);
}
},
GUILayout.ExpandWidth(true)))
{
var probe = p.target;
HDReflectionProbeEditorUtility.BakeCustomReflectionProbe(probe, true, true);
HDReflectionProbeEditorUtility.ResetProbeSceneTextureInMaterial(probe);
GUIUtility.ExitGUI();
}
break;
}
case ReflectionProbeMode.Baked:
{
GUI.enabled = p.target.enabled;
// Bake button in non-continous mode
if (ButtonWithDropdownList(
CoreEditorUtils.GetContent("Bake"),
k_BakeButtonsText,
data =>
{
var mode = (int)data;
if (mode == 0)
HDReflectionProbeEditorUtility.BakeAllReflectionProbesSnapshots();
},
GUILayout.ExpandWidth(true)))
{
var probe = p.target;
HDReflectionProbeEditorUtility.BakeReflectionProbeSnapshot(probe);
HDReflectionProbeEditorUtility.ResetProbeSceneTextureInMaterial(probe);
GUIUtility.ExitGUI();
}
GUI.enabled = true;
break;
}
case ReflectionProbeMode.Realtime:
// Not showing bake button in realtime
break;
}
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
EditorReflectionSystemGUI.DrawBakeButton((ReflectionProbeMode)p.mode.intValue, p.target);
}
#region Influence Volume

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


using System.Collections.Generic;
using UnityEngine;
using _ = CoreEditorUtils;
[CustomEditorForRenderPipeline(typeof(PlanarReflectionProbe), typeof(HDRenderPipelineAsset))]
[CanEditMultipleObjects]
class PlanarReflectionProbeEditor : Editor

PlanarReflectionProbeUI m_UIState = new PlanarReflectionProbeUI();
PlanarReflectionProbeUI[] m_UIHandleState;
PlanarReflectionProbe[] m_TypedTargets;
List<Texture> m_PreviewedTextures = new List<Texture>();
void OnEnable()
{

{
for (var i = 0; i < m_TypedTargets.Length; i++)
PlanarReflectionProbeUI.DrawHandles(m_UIHandleState[i], m_TypedTargets[i], this);
}
public override bool HasPreviewGUI()
{
for (var i = 0; i < m_TypedTargets.Length; i++)
{
if (m_TypedTargets[i].texture != null)
return true;
}
return false;
}
public override GUIContent GetPreviewTitle()
{
return _.GetContent("Planar Reflection");
}
public override void OnPreviewGUI(Rect r, GUIStyle background)
{
m_PreviewedTextures.Clear();
for (var i = 0; i < m_TypedTargets.Length; i++)
m_PreviewedTextures.Add(m_TypedTargets[i].texture);
var space = Vector2.one;
var rowSize = Mathf.CeilToInt(Mathf.Sqrt(m_PreviewedTextures.Count));
var size = r.size / rowSize - space * (rowSize - 1);
for (var i = 0; i < m_TypedTargets.Length; i++)
{
var row = i / rowSize;
var col = i % rowSize;
var itemRect = new Rect(
r.x + size.x * row + ((row > 0) ? (row - 1) * space.x : 0),
r.y + size.y * col + ((col > 0) ? (col - 1) * space.y : 0),
size.x,
size.y);
if (m_PreviewedTextures[i] != null)
GUI.DrawTexture(itemRect, m_PreviewedTextures[i]);
else
GUI.Label(itemRect, _.GetContent("Not Available"));
}
}
}
}

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


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

{
public static readonly CED.IDrawer Inspector;
public static readonly CED.IDrawer SectionCaptureSettings = CED.Group(
CED.Action(Drawer_SectionCaptureSettings)
public static readonly CED.IDrawer SectionProbeModeSettings;
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 SectionFoldoutInfluenceSettings = CED.FoldoutGroup(
"Influence Settings",
(s, d, o) => s.isSectionExpandedInfluenceSettings,
true,
CED.Action(Drawer_SectionInfluenceSettings)
public static readonly CED.IDrawer SectionFoldoutAdvancedSettings = CED.FoldoutGroup(
"Advanced Settings",
(s, d, o) => s.isSectionExpandedAdvancedSettings,
public static readonly CED.IDrawer SectionFoldoutCaptureSettings = CED.FoldoutGroup(
"Capture Settings",
(s, d, o) => s.isSectionExpandedCaptureSettings,
CED.Action(Drawer_SectionAdvancedSettings)
CED.Action(Drawer_SectionCaptureSettings)
SectionProbeModeSettings = CED.Group(
CED.Action(Drawer_FieldCaptureType),
CED.FadeGroup(
(s, d, o, i) => s.IsSectionExpandedReflectionProbeMode((ReflectionProbeMode)i),
true,
SectionProbeModeBakedSettings,
SectionProbeModeRealtimeSettings,
SectionProbeModeCustomSettings
)
);
SectionCaptureSettings,
SectionProbeModeSettings,
CED.space,
CED.Action((s, d, o) => EditorGUILayout.LabelField(_.GetContent("Proxy Volume"), EditorStyles.boldLabel)),
CED.Action(Drawer_FieldProxyVolumeReference),

(s, d, o) => d.influenceVolume,
InfluenceVolumeUI.SectionFoldoutShape
),
SectionFoldoutAdvancedSettings
SectionFoldoutInfluenceSettings,
SectionFoldoutCaptureSettings,
CED.space,
CED.Action(Drawer_SectionBakeButton)
);
}

const EditMode.SceneViewEditMode EditCenter = EditMode.SceneViewEditMode.ReflectionProbeOrigin;
const EditMode.SceneViewEditMode EditCenter = EditMode.SceneViewEditMode.ReflectionProbeOrigin;
static void Drawer_SectionCaptureSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.captureOffset, _.GetContent("Capture Offset"));
}
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_SectionAdvancedSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
static void Drawer_SectionProbeModeRealtimeSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.refreshMode, _.GetContent("Refresh Mode"));
}
static void Drawer_SectionInfluenceSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
static void Drawer_SectionCaptureSettings(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
static void Drawer_FieldCaptureType(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
EditorGUILayout.LabelField(_.GetContent("Capture Settings"), EditorStyles.boldLabel);
++EditorGUI.indentLevel;
EditorGUILayout.PropertyField(d.captureOffset, _.GetContent("Capture Position"));
--EditorGUI.indentLevel;
static void Drawer_FieldProxyVolumeReference(PlanarReflectionProbeUI s, SerializedPlanarReflectionProbe d, Editor o)
{
EditorGUILayout.PropertyField(d.proxyVolumeReference, _.GetContent("Reference"));

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


using System;
using UnityEngine.Rendering;
const int k_AnimBoolFields = 2;
static readonly int k_ReflectionProbeModeModeCount = Enum.GetValues(typeof(ReflectionProbeMode)).Length;
static readonly int k_AnimBoolTotal = k_AnimBoolFields + k_ReflectionProbeModeModeCount;
public AnimBool isSectionExpandedAdvancedSettings { get { return m_AnimBools[0]; } }
public AnimBool isSectionExpandedInfluenceSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount]; } }
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[k_ReflectionProbeModeModeCount + 1]; } }
: base(1)
: base(k_AnimBoolTotal)
}
public AnimBool IsSectionExpandedReflectionProbeMode(ReflectionProbeMode mode)
{
return m_AnimBools[(int)mode];
}
public override void Reset(SerializedPlanarReflectionProbe data, UnityAction repaint)

public override void Update()
{
for (var i = 0; i < k_ReflectionProbeModeModeCount; i++)
m_AnimBools[i].target = i == data.mode.intValue;
influenceVolume.Update();
base.Update();
}

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


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

public SerializedProperty captureOffset;
public SerializedProperty dimmer;
public SerializedProperty mode;
public SerializedProperty refreshMode;
public SerializedProperty customTexture;
public PlanarReflectionProbe target { get { return serializedObject.targetObject as PlanarReflectionProbe; } }
public SerializedPlanarReflectionProbe(SerializedObject serializedObject)
{

captureOffset = serializedObject.Find((PlanarReflectionProbe p) => p.centerOffset);
dimmer = serializedObject.Find((PlanarReflectionProbe p) => p.dimmer);
mode = serializedObject.Find((PlanarReflectionProbe p) => p.mode);
refreshMode = serializedObject.Find((PlanarReflectionProbe p) => p.refreshMode);
customTexture = serializedObject.Find((PlanarReflectionProbe p) => p.customTexture);
}
public void Update()

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


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

float m_Dimmer = 1;
[SerializeField]
ReflectionProbeMode m_Mode = ReflectionProbeMode.Baked;
[SerializeField]
ReflectionProbeRefreshMode m_RefreshMode = ReflectionProbeRefreshMode.OnAwake;
[SerializeField]
Texture m_CustomTexture;
public ProxyVolumeComponent proxyVolumeReference { get { return m_ProxyVolumeReference; } }
public InfluenceVolume influenceVolume { get { return m_InfluenceVolume; } }

public Vector3 influenceForward { get { return transform.forward; } }
public Vector3 capturePosition { get { return transform.position; } }
public Vector3 influencePosition { get { return transform.TransformPoint(m_CenterOffset); } }
public Texture customTexture { get { return m_CustomTexture; } }
public ReflectionProbeRefreshMode refreshMode { get { return m_RefreshMode; } }
#region Proxy Properties
public Vector3 proxyRight

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


using System;
using System.IO;
using System.Reflection;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.SceneManagement;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
public static class EditorReflectionSystem
{
static int _Cubemap = Shader.PropertyToID("_Cubemap");
public static void BakeCustomReflectionProbe(PlanarReflectionProbe probe, bool usePreviousAssetPath, bool custom)
{
throw new NotImplementedException();
}
public static void BakeCustomReflectionProbe(ReflectionProbe probe, bool usePreviousAssetPath, bool custom)
{
if (!custom && probe.bakedTexture != null)
probe.customBakedTexture = probe.bakedTexture;
string path = "";
if (usePreviousAssetPath)
path = AssetDatabase.GetAssetPath(probe.customBakedTexture);
string targetExtension = probe.hdr ? "exr" : "png";
if (string.IsNullOrEmpty(path) || Path.GetExtension(path) != "." + targetExtension)
{
// We use the path of the active scene as the target path
var targetPath = SceneManager.GetActiveScene().path;
targetPath = Path.Combine(Path.GetDirectoryName(targetPath), Path.GetFileNameWithoutExtension(targetPath));
if (string.IsNullOrEmpty(targetPath))
targetPath = "Assets";
else if (Directory.Exists(targetPath) == false)
Directory.CreateDirectory(targetPath);
string fileName = probe.name + (probe.hdr ? "-reflectionHDR" : "-reflection") + "." + targetExtension;
fileName = Path.GetFileNameWithoutExtension(AssetDatabase.GenerateUniqueAssetPath(Path.Combine(targetPath, fileName)));
path = EditorUtility.SaveFilePanelInProject("Save reflection probe's cubemap.", fileName, targetExtension, "", targetPath);
if (string.IsNullOrEmpty(path))
return;
ReflectionProbe collidingProbe;
if (HDReflectionProbeEditorUtility.IsCollidingWithOtherProbes(path, probe, out collidingProbe))
{
if (!EditorUtility.DisplayDialog("Cubemap is used by other reflection probe",
string.Format("'{0}' path is used by the game object '{1}', do you really want to overwrite it?",
path, collidingProbe.name), "Yes", "No"))
{
return;
}
}
}
EditorUtility.DisplayProgressBar("Reflection Probes", "Baking " + path, 0.5f);
if (!UnityEditor.Lightmapping.BakeReflectionProbe(probe, path))
Debug.LogError("Failed to bake reflection probe to " + path);
EditorUtility.ClearProgressBar();
}
public static void ResetProbeSceneTextureInMaterial(ReflectionProbe p)
{
var renderer = p.GetComponent<Renderer>();
renderer.sharedMaterial.SetTexture(_Cubemap, p.texture);
}
public static void ResetProbeSceneTextureInMaterial(PlanarReflectionProbe p)
{
throw new NotImplementedException();
}
static MethodInfo k_Lightmapping_BakeReflectionProbeSnapshot = typeof(UnityEditor.Lightmapping).GetMethod("BakeReflectionProbeSnapshot", BindingFlags.Static | BindingFlags.NonPublic);
public static bool BakeReflectionProbeSnapshot(ReflectionProbe probe)
{
return (bool)k_Lightmapping_BakeReflectionProbeSnapshot.Invoke(null, new object[] { probe });
}
public static bool BakeReflectionProbeSnapshot(PlanarReflectionProbe probe)
{
throw new NotImplementedException();
}
static MethodInfo k_Lightmapping_BakeAllReflectionProbesSnapshots = typeof(UnityEditor.Lightmapping).GetMethod("BakeAllReflectionProbesSnapshots", BindingFlags.Static | BindingFlags.NonPublic);
public static bool BakeAllReflectionProbesSnapshots()
{
return (bool)k_Lightmapping_BakeAllReflectionProbesSnapshots.Invoke(null, new object[0]);
}
}
}

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


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

136
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/EditorReflectionSystemGUI.cs


using System.Reflection;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
using UnityEngine.Rendering;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
using _ = CoreEditorUtils;
public static class EditorReflectionSystemGUI
{
static readonly string[] k_BakeCustomOptionText = { "Bake as new Cubemap..." };
static readonly string[] k_BakeButtonsText = { "Bake All Reflection Probes" };
public static void DrawBakeButton(ReflectionProbeMode reflectionProbeMode, ReflectionProbe probe)
{
DrawBakeButton(reflectionProbeMode, probe, null);
}
public static void DrawBakeButton(ReflectionProbeMode reflectionProbeMode, PlanarReflectionProbe probe)
{
DrawBakeButton(reflectionProbeMode, null, probe);
}
static void DrawBakeButton(ReflectionProbeMode reflectionProbeMode, ReflectionProbe probe, PlanarReflectionProbe planarProbe)
{
if (reflectionProbeMode == ReflectionProbeMode.Realtime)
{
EditorGUILayout.HelpBox("Refresh of this reflection probe should be initiated from the scripting API because the type is 'Realtime'", MessageType.Info);
if (!QualitySettings.realtimeReflectionProbes)
EditorGUILayout.HelpBox("Realtime reflection probes are disabled in Quality Settings", MessageType.Warning);
return;
}
if (reflectionProbeMode == ReflectionProbeMode.Baked
&& UnityEditor.Lightmapping.giWorkflowMode != UnityEditor.Lightmapping.GIWorkflowMode.OnDemand)
{
EditorGUILayout.HelpBox("Baking of this reflection probe is automatic because this probe's type is 'Baked' and the Lighting window is using 'Auto Baking'. The cubemap created is stored in the GI cache.", MessageType.Info);
return;
}
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
switch (reflectionProbeMode)
{
case ReflectionProbeMode.Custom:
{
if (ButtonWithDropdownList(
_.GetContent("Bake|Bakes Reflection Probe's cubemap, overwriting the existing cubemap texture asset (if any)."), k_BakeCustomOptionText,
data =>
{
var mode = (int)data;
if (mode == 0)
{
if (probe != null)
{
EditorReflectionSystem.BakeCustomReflectionProbe(probe, false, true);
EditorReflectionSystem.ResetProbeSceneTextureInMaterial(probe);
}
if (planarProbe != null)
{
EditorReflectionSystem.BakeCustomReflectionProbe(planarProbe, false, true);
EditorReflectionSystem.ResetProbeSceneTextureInMaterial(planarProbe);
}
}
},
GUILayout.ExpandWidth(true)))
{
if (probe != null)
{
EditorReflectionSystem.BakeCustomReflectionProbe(probe, true, true);
EditorReflectionSystem.ResetProbeSceneTextureInMaterial(probe);
}
if (planarProbe != null)
{
EditorReflectionSystem.BakeCustomReflectionProbe(planarProbe, true, true);
EditorReflectionSystem.ResetProbeSceneTextureInMaterial(planarProbe);
}
GUIUtility.ExitGUI();
}
break;
}
case ReflectionProbeMode.Baked:
{
GUI.enabled = probe != null && probe.enabled
|| planarProbe != null && planarProbe.enabled;
// Bake button in non-continous mode
if (ButtonWithDropdownList(
_.GetContent("Bake"),
k_BakeButtonsText,
data =>
{
var mode = (int)data;
if (mode == 0)
EditorReflectionSystem.BakeAllReflectionProbesSnapshots();
},
GUILayout.ExpandWidth(true)))
{
if (probe != null)
{
EditorReflectionSystem.BakeReflectionProbeSnapshot(probe);
EditorReflectionSystem.ResetProbeSceneTextureInMaterial(probe);
}
if (planarProbe != null)
{
EditorReflectionSystem.BakeReflectionProbeSnapshot(planarProbe);
EditorReflectionSystem.ResetProbeSceneTextureInMaterial(planarProbe);
}
GUIUtility.ExitGUI();
}
GUI.enabled = true;
break;
}
case ReflectionProbeMode.Realtime:
// Not showing bake button in realtime
break;
}
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
}
static MethodInfo k_EditorGUI_ButtonWithDropdownList = typeof(EditorGUI).GetMethod("ButtonWithDropdownList", BindingFlags.Static | BindingFlags.NonPublic, null, CallingConventions.Any, new[] { typeof(GUIContent), typeof(string[]), typeof(GenericMenu.MenuFunction2), typeof(GUILayoutOption[]) }, new ParameterModifier[0]);
static bool ButtonWithDropdownList(GUIContent content, string[] buttonNames, GenericMenu.MenuFunction2 callback, params GUILayoutOption[] options)
{
return (bool)k_EditorGUI_ButtonWithDropdownList.Invoke(null, new object[] { content, buttonNames, callback, options });
}
}
}

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


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