Frédéric Vauchelles
7 年前
当前提交
7e7fcb74
共有 16 个文件被更改,包括 901 次插入 和 853 次删除
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/BaseUI.cs
-
32ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditor.Handles.cs
-
48ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditor.ProbeUtility.cs
-
197ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditor.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditorUtility.cs.meta
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeUI.Drawers.cs.meta
-
182ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditorUtility.cs
-
435ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeUI.Drawers.cs
-
116ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeUI.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeUI.cs.meta
-
100ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedHDReflectionProbe.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/SerializedHDReflectionProbe.cs.meta
-
213ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditor.Data.cs
-
403ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditor.Drawers.cs
-
0/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditorUtility.cs.meta
-
0/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeUI.Drawers.cs.meta
|
|||
using System; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.SceneManagement; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
public static class HDReflectionProbeEditorUtility |
|||
{ |
|||
static int _Cubemap = Shader.PropertyToID("_Cubemap"); |
|||
static Material s_PreviewMaterial; |
|||
static Mesh s_SphereMesh; |
|||
|
|||
[InitializeOnLoadMethod] |
|||
static void Initialize() |
|||
{ |
|||
s_PreviewMaterial = new Material(Shader.Find("Debug/ReflectionProbePreview")) |
|||
{ |
|||
hideFlags = HideFlags.HideAndDontSave |
|||
}; |
|||
s_SphereMesh = Resources.GetBuiltinResource(typeof(Mesh), "New-Sphere.fbx") as Mesh; |
|||
} |
|||
|
|||
public static Matrix4x4 GetLocalSpace(ReflectionProbe probe) |
|||
{ |
|||
var t = probe.transform.position; |
|||
return Matrix4x4.TRS(t, GetLocalSpaceRotation(probe), Vector3.one); |
|||
} |
|||
|
|||
public static Quaternion GetLocalSpaceRotation(ReflectionProbe probe) |
|||
{ |
|||
var supportsRotation = (SupportedRenderingFeatures.active.reflectionProbeSupportFlags & SupportedRenderingFeatures.ReflectionProbeSupportFlags.Rotation) != 0; |
|||
return supportsRotation |
|||
? probe.transform.rotation |
|||
: Quaternion.identity; |
|||
} |
|||
|
|||
// Ensures that probe's AABB encapsulates probe's position
|
|||
// Returns true, if center or size was modified
|
|||
public static bool ValidateAABB(ReflectionProbe p, ref Vector3 center, ref Vector3 size) |
|||
{ |
|||
var localSpace = GetLocalSpace(p); |
|||
var localTransformPosition = localSpace.inverse.MultiplyPoint3x4(p.transform.position); |
|||
|
|||
var b = new Bounds(center, size); |
|||
|
|||
if (b.Contains(localTransformPosition)) |
|||
return false; |
|||
|
|||
b.Encapsulate(localTransformPosition); |
|||
|
|||
center = b.center; |
|||
size = b.size; |
|||
return true; |
|||
} |
|||
|
|||
public static bool IsCollidingWithOtherProbes(string targetPath, ReflectionProbe targetProbe, out ReflectionProbe collidingProbe) |
|||
{ |
|||
ReflectionProbe[] probes = Object.FindObjectsOfType<ReflectionProbe>().ToArray(); |
|||
collidingProbe = null; |
|||
foreach (var probe in probes) |
|||
{ |
|||
if (probe == targetProbe || probe.customBakedTexture == null) |
|||
continue; |
|||
string path = AssetDatabase.GetAssetPath(probe.customBakedTexture); |
|||
if (path == targetPath) |
|||
{ |
|||
collidingProbe = probe; |
|||
return true; |
|||
} |
|||
} |
|||
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) |
|||
{ |
|||
var renderer = p.GetComponent<Renderer>(); |
|||
renderer.sharedMaterial.SetTexture(_Cubemap, p.texture); |
|||
} |
|||
|
|||
public static float CalculateSphereMaxBlendDistance(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor o) |
|||
{ |
|||
return p.influenceSphereRadius.floatValue; |
|||
} |
|||
|
|||
public static Vector3 CalculateBoxMaxBlendDistance(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor o) |
|||
{ |
|||
return p.boxSize.vector3Value * 0.5f; |
|||
} |
|||
|
|||
internal static void InitializeProbe(ReflectionProbe p, HDAdditionalReflectionData data) |
|||
{ |
|||
var meshFilter = p.GetComponent<MeshFilter>() ?? p.gameObject.AddComponent<MeshFilter>(); |
|||
var meshRenderer = p.GetComponent<MeshRenderer>() ?? p.gameObject.AddComponent<MeshRenderer>(); |
|||
|
|||
meshFilter.sharedMesh = s_SphereMesh; |
|||
|
|||
var material = meshRenderer.sharedMaterial; |
|||
if (material == null |
|||
|| material == s_PreviewMaterial |
|||
|| material.shader != s_PreviewMaterial.shader) |
|||
{ |
|||
material = Object.Instantiate(s_PreviewMaterial); |
|||
material.SetTexture(_Cubemap, p.texture); |
|||
material.hideFlags = HideFlags.HideAndDontSave; |
|||
meshRenderer.material = material; |
|||
} |
|||
|
|||
meshRenderer.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off; |
|||
meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; |
|||
meshRenderer.motionVectorGenerationMode = MotionVectorGenerationMode.ForceNoMotion; |
|||
} |
|||
|
|||
internal static void ChangeVisibility(ReflectionProbe p, bool visible) |
|||
{ |
|||
var meshRenderer = p.GetComponent<MeshRenderer>() ?? p.gameObject.AddComponent<MeshRenderer>(); |
|||
meshRenderer.enabled = visible; |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Reflection; |
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEditor.IMGUI.Controls; |
|||
using UnityEditorInternal; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
using CED = CoreEditorDrawer<HDReflectionProbeUI, SerializedHDReflectionProbe>; |
|||
|
|||
public partial class HDReflectionProbeUI |
|||
{ |
|||
static HDReflectionProbeUI() |
|||
{ |
|||
Inspector = new[] |
|||
{ |
|||
SectionPrimarySettings, |
|||
SectionInfluenceVolumeSettings, |
|||
SectionSeparateProjectionVolumeSettings, |
|||
//SectionSeparateProjectionVolumeSettings,
|
|||
SectionCaptureSettings, |
|||
SectionAdditionalSettings, |
|||
ButtonBake |
|||
}; |
|||
} |
|||
|
|||
public static readonly CED.IDrawer[] Inspector; |
|||
|
|||
public static readonly CED.IDrawer SectionPrimarySettings = CED.Group( |
|||
|
|||
CED.Action(Drawer_ReflectionProbeMode), |
|||
CED.FadeGroup((s, p, o, i) => s.IsSectionExpandedMode((ReflectionProbeMode)i), |
|||
true, |
|||
CED.noop, // Baked
|
|||
CED.Action(Drawer_ModeSettingsRealtime), // Realtime
|
|||
CED.Action(Drawer_ModeSettingsCustom) // Custom
|
|||
), |
|||
CED.space, |
|||
CED.Action(Drawer_InfluenceShape), |
|||
//CED.Action(Drawer_IntensityMultiplier),
|
|||
CED.space, |
|||
CED.Action(Drawer_Toolbar), |
|||
CED.space |
|||
); |
|||
|
|||
public static readonly CED.IDrawer SectionInfluenceVolumeSettings = CED.FoldoutGroup( |
|||
"Influence volume settings", |
|||
(s, p, o) => s.isSectionExpandedInfluenceVolume, |
|||
true, |
|||
CED.FadeGroup( |
|||
(s, p, o, i) => s.IsSectionExpandedShape((ReflectionInfluenceShape)i), |
|||
false, |
|||
CED.Action(Drawer_InfluenceBoxSettings), // Box
|
|||
CED.Action(Drawer_InfluenceSphereSettings) // Sphere
|
|||
)/*, |
|||
CED.Action(Drawer_UseSeparateProjectionVolume)*/ |
|||
); |
|||
|
|||
public static readonly CED.IDrawer SectionSeparateProjectionVolumeSettings = CED.FadeGroup( |
|||
(s, p, o, i) => s.isSectionExpandedSeparateProjection, |
|||
false, |
|||
CED.FoldoutGroup( |
|||
"Reprojection volume settings", |
|||
(s, p, o) => s.isSectionExpandedSeparateProjection, |
|||
true, |
|||
CED.FadeGroup( |
|||
(s, p, o, i) => s.IsSectionExpandedShape((ReflectionInfluenceShape)i), |
|||
false, |
|||
CED.Action(Drawer_ProjectionBoxSettings), // Box
|
|||
CED.Action(Drawer_ProjectionSphereSettings) // Sphere
|
|||
) |
|||
) |
|||
); |
|||
|
|||
public static readonly CED.IDrawer SectionCaptureSettings = CED.FoldoutGroup( |
|||
"Capture settings", |
|||
(s, p, o) => s.isSectionExpandedCaptureSettings, |
|||
true, |
|||
CED.Action(Drawer_CaptureSettings) |
|||
); |
|||
|
|||
public static readonly CED.IDrawer SectionAdditionalSettings = CED.FoldoutGroup( |
|||
"Additional settings", |
|||
(s, p, o) => s.isSectionExpandedAdditional, |
|||
true, |
|||
CED.Action(Drawer_AdditionalSettings) |
|||
); |
|||
|
|||
public static readonly CED.IDrawer ButtonBake = CED.Action(Drawer_BakeActions); |
|||
|
|||
static void Drawer_CaptureSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner) |
|||
{ |
|||
var renderPipelineAsset = (HDRenderPipelineAsset)GraphicsSettings.renderPipelineAsset; |
|||
p.resolution.intValue = renderPipelineAsset.GetRenderPipelineSettings().lightLoopSettings.reflectionCubemapSize; |
|||
EditorGUILayout.LabelField(CoreEditorUtils.GetContent("Resolution"), CoreEditorUtils.GetContent(p.resolution.intValue.ToString())); |
|||
|
|||
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.dimmer); |
|||
|
|||
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 readonly string[] k_BakeCustomOptionText = { "Bake as new Cubemap..." }; |
|||
static readonly string[] k_BakeButtonsText = { "Bake All Reflection Probes" }; |
|||
static void Drawer_BakeActions(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner) |
|||
{ |
|||
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(); |
|||
} |
|||
|
|||
#region Influence Volume
|
|||
static void Drawer_InfluenceBoxSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner) |
|||
{ |
|||
var maxBlendDistance = HDReflectionProbeEditorUtility.CalculateBoxMaxBlendDistance(s, p, owner); |
|||
CoreEditorUtils.DrawVector6Slider( |
|||
CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."), |
|||
p.blendDistancePositive, p.blendDistanceNegative, Vector3.zero, maxBlendDistance); |
|||
|
|||
CoreEditorUtils.DrawVector6Slider( |
|||
CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes."), |
|||
p.blendNormalDistancePositive, p.blendNormalDistanceNegative, Vector3.zero, maxBlendDistance); |
|||
|
|||
CoreEditorUtils.DrawVector6Slider( |
|||
CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap."), |
|||
p.boxSideFadePositive, p.boxSideFadeNegative, Vector3.zero, Vector3.one); |
|||
|
|||
EditorGUILayout.Space(); |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
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.")); |
|||
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.")); |
|||
EditorGUILayout.PropertyField(p.boxProjection, CoreEditorUtils.GetContent("Box Projection|Box projection 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 box projection 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")); |
|||
|
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
var center = p.boxOffset.vector3Value; |
|||
var size = p.boxSize.vector3Value; |
|||
if (HDReflectionProbeEditorUtility.ValidateAABB(p.target, ref center, ref size)) |
|||
{ |
|||
p.boxOffset.vector3Value = center; |
|||
p.boxSize.vector3Value = size; |
|||
} |
|||
} |
|||
} |
|||
|
|||
static void Drawer_InfluenceSphereSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner) |
|||
{ |
|||
var maxBlendDistance = HDReflectionProbeEditorUtility.CalculateSphereMaxBlendDistance(s, p, owner); |
|||
|
|||
var blendDistance = p.blendDistancePositive.vector3Value.x; |
|||
EditorGUI.BeginChangeCheck(); |
|||
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.blendDistancePositive.vector3Value = Vector3.one * blendDistance; |
|||
p.blendDistanceNegative.vector3Value = Vector3.one * blendDistance; |
|||
} |
|||
|
|||
var blendNormalDistance = p.blendNormalDistancePositive.vector3Value.x; |
|||
EditorGUI.BeginChangeCheck(); |
|||
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.blendNormalDistancePositive.vector3Value = Vector3.one * blendNormalDistance; |
|||
p.blendNormalDistanceNegative.vector3Value = Vector3.one * blendNormalDistance; |
|||
} |
|||
|
|||
EditorGUILayout.PropertyField(p.influenceSphereRadius, CoreEditorUtils.GetContent("Radius")); |
|||
EditorGUILayout.PropertyField(p.boxProjection, CoreEditorUtils.GetContent("Sphere Projection|Sphere projection causes reflections to appear to change based on the object's position within the probe's sphere, 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 sphere projection 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")); |
|||
} |
|||
#endregion
|
|||
|
|||
#region Projection Volume
|
|||
static void Drawer_UseSeparateProjectionVolume(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.useSeparateProjectionVolume); |
|||
s.isSectionExpandedSeparateProjection.target = p.useSeparateProjectionVolume.boolValue; |
|||
} |
|||
|
|||
static void Drawer_ProjectionBoxSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.boxReprojectionVolumeSize); |
|||
EditorGUILayout.PropertyField(p.boxReprojectionVolumeCenter); |
|||
} |
|||
|
|||
static void Drawer_ProjectionSphereSettings(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.sphereReprojectionVolumeRadius); |
|||
} |
|||
#endregion
|
|||
|
|||
#region Field Drawers
|
|||
static readonly GUIContent[] k_Content_ReflectionProbeMode = { new GUIContent("Baked"), new GUIContent("Custom"), new GUIContent("Realtime") }; |
|||
static readonly int[] k_Content_ReflectionProbeModeValues = { (int)ReflectionProbeMode.Baked, (int)ReflectionProbeMode.Custom, (int)ReflectionProbeMode.Realtime }; |
|||
static void Drawer_ReflectionProbeMode(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner) |
|||
{ |
|||
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).")); |
|||
EditorGUI.showMixedValue = false; |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
s.SetModeTarget(p.mode.intValue); |
|||
foreach (var targetObject in p.so.targetObjects) |
|||
HDReflectionProbeEditorUtility.ResetProbeSceneTextureInMaterial((ReflectionProbe)targetObject); |
|||
} |
|||
} |
|||
|
|||
static void Drawer_InfluenceShape(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner) |
|||
{ |
|||
EditorGUI.BeginChangeCheck(); |
|||
EditorGUI.showMixedValue = p.influenceShape.hasMultipleDifferentValues; |
|||
EditorGUILayout.PropertyField(p.influenceShape, CoreEditorUtils.GetContent("Shape")); |
|||
EditorGUI.showMixedValue = false; |
|||
if (EditorGUI.EndChangeCheck()) |
|||
s.SetShapeTarget(p.influenceShape.intValue); |
|||
} |
|||
|
|||
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 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 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
|
|||
|
|||
#region Mode Specific Settings
|
|||
static void Drawer_ModeSettingsCustom(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.renderDynamicObjects, CoreEditorUtils.GetContent("Dynamic Objects|If enabled dynamic objects are also rendered into the cubemap")); |
|||
|
|||
p.customBakedTexture.objectReferenceValue = EditorGUILayout.ObjectField(CoreEditorUtils.GetContent("Cubemap"), p.customBakedTexture.objectReferenceValue, typeof(Cubemap), false); |
|||
} |
|||
|
|||
static void Drawer_ModeSettingsRealtime(HDReflectionProbeUI s, SerializedHDReflectionProbe p, Editor owner) |
|||
{ |
|||
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
|
|||
|
|||
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 }); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Reflection; |
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEditor.IMGUI.Controls; |
|||
using UnityEditorInternal; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
public partial class HDReflectionProbeUI : BaseUI<SerializedHDReflectionProbe> |
|||
{ |
|||
const int k_AnimBoolSingleFieldCount = 4; |
|||
static readonly int k_ReflectionProbeModeCount = Enum.GetValues(typeof(ReflectionProbeMode)).Length; |
|||
static readonly int k_ReflectionInfluenceShapeCount = Enum.GetValues(typeof(ReflectionInfluenceShape)).Length; |
|||
static readonly int k_AnimBoolsCount = k_ReflectionProbeModeCount + k_ReflectionInfluenceShapeCount + k_AnimBoolSingleFieldCount; |
|||
|
|||
[Flags] |
|||
public enum Operation |
|||
{ |
|||
None = 0, |
|||
FitVolumeToSurroundings = 1 << 0 |
|||
} |
|||
Operation operations { get; set; } |
|||
|
|||
public Editor owner { get; set; } |
|||
public bool HasOperation(Operation op) { return (operations & op) == op; } |
|||
public void ClearOperation(Operation op) { operations &= ~op; } |
|||
public void AddOperation(Operation op) { operations |= op; } |
|||
|
|||
public BoxBoundsHandle boxInfluenceHandle = new BoxBoundsHandle(); |
|||
public BoxBoundsHandle boxProjectionHandle = new BoxBoundsHandle(); |
|||
public BoxBoundsHandle boxBlendHandle = new BoxBoundsHandle(); |
|||
public BoxBoundsHandle boxBlendNormalHandle = new BoxBoundsHandle(); |
|||
public SphereBoundsHandle sphereInfluenceHandle = new SphereBoundsHandle(); |
|||
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle(); |
|||
public SphereBoundsHandle sphereBlendHandle = new SphereBoundsHandle(); |
|||
public SphereBoundsHandle sphereBlendNormalHandle = new SphereBoundsHandle(); |
|||
public Matrix4x4 oldLocalSpace = Matrix4x4.identity; |
|||
|
|||
public AnimBool isSectionExpandedInfluenceVolume { get { return m_AnimBools[0]; } } |
|||
public AnimBool isSectionExpandedSeparateProjection { 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); |
|||
ClearOperation(op); |
|||
return has; |
|||
} |
|||
|
|||
public bool sceneViewEditing |
|||
{ |
|||
get { return HDReflectionProbeEditor.IsReflectionProbeEditMode(EditMode.editMode) && EditMode.IsOwner(owner); } |
|||
} |
|||
|
|||
public HDReflectionProbeUI() |
|||
: base(k_AnimBoolsCount) |
|||
{ |
|||
isSectionExpandedCaptureSettings.value = true; |
|||
isSectionExpandedInfluenceVolume.value = true; |
|||
isSectionExpandedAdditional.value = false; |
|||
} |
|||
|
|||
public override void Update() |
|||
{ |
|||
operations = 0; |
|||
|
|||
SetModeTarget(data.mode.intValue); |
|||
SetShapeTarget(data.influenceShape.intValue); |
|||
|
|||
isSectionExpandedSeparateProjection.value = data.useSeparateProjectionVolume.boolValue; |
|||
base.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(ReflectionInfluenceShape 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; |
|||
} |
|||
|
|||
internal void UpdateOldLocalSpace(ReflectionProbe target) |
|||
{ |
|||
oldLocalSpace = HDReflectionProbeEditorUtility.GetLocalSpace(target); |
|||
} |
|||
|
|||
AnimBool GetReflectionProbeModeBool(int i) |
|||
{ |
|||
return m_AnimBools[k_AnimBoolSingleFieldCount + i]; |
|||
} |
|||
|
|||
AnimBool GetReflectionInfluenceShapeBool(int i) |
|||
{ |
|||
return m_AnimBools[k_AnimBoolSingleFieldCount + k_ReflectionProbeModeCount + i]; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: cafdb0675d72d5946a84481bf765b025 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
public class SerializedHDReflectionProbe |
|||
{ |
|||
internal ReflectionProbe target; |
|||
internal HDAdditionalReflectionData targetData; |
|||
|
|||
internal SerializedObject so; |
|||
internal SerializedObject addso; |
|||
|
|||
internal SerializedProperty mode; |
|||
internal SerializedProperty renderDynamicObjects; |
|||
internal SerializedProperty customBakedTexture; |
|||
internal SerializedProperty refreshMode; |
|||
internal SerializedProperty timeSlicingMode; |
|||
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 influenceShape; |
|||
internal SerializedProperty influenceSphereRadius; |
|||
internal SerializedProperty useSeparateProjectionVolume; |
|||
internal SerializedProperty boxReprojectionVolumeSize; |
|||
internal SerializedProperty boxReprojectionVolumeCenter; |
|||
internal SerializedProperty sphereReprojectionVolumeRadius; |
|||
internal SerializedProperty blendDistancePositive; |
|||
internal SerializedProperty blendDistanceNegative; |
|||
internal SerializedProperty blendNormalDistancePositive; |
|||
internal SerializedProperty blendNormalDistanceNegative; |
|||
internal SerializedProperty boxSideFadePositive; |
|||
internal SerializedProperty boxSideFadeNegative; |
|||
internal SerializedProperty dimmer; |
|||
|
|||
public SerializedHDReflectionProbe(SerializedObject so, SerializedObject addso) |
|||
{ |
|||
this.so = so; |
|||
this.addso = addso; |
|||
|
|||
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"); |
|||
|
|||
influenceShape = addso.Find((HDAdditionalReflectionData d) => d.influenceShape); |
|||
influenceSphereRadius = addso.Find((HDAdditionalReflectionData d) => d.influenceSphereRadius); |
|||
useSeparateProjectionVolume = addso.Find((HDAdditionalReflectionData d) => d.useSeparateProjectionVolume); |
|||
boxReprojectionVolumeSize = addso.Find((HDAdditionalReflectionData d) => d.boxReprojectionVolumeSize); |
|||
boxReprojectionVolumeCenter = addso.Find((HDAdditionalReflectionData d) => d.boxReprojectionVolumeCenter); |
|||
sphereReprojectionVolumeRadius = addso.Find((HDAdditionalReflectionData d) => d.sphereReprojectionVolumeRadius); |
|||
dimmer = addso.Find((HDAdditionalReflectionData d) => d.dimmer); |
|||
blendDistancePositive = addso.Find((HDAdditionalReflectionData d) => d.blendDistancePositive); |
|||
blendDistanceNegative = addso.Find((HDAdditionalReflectionData d) => d.blendDistanceNegative); |
|||
blendNormalDistancePositive = addso.Find((HDAdditionalReflectionData d) => d.blendNormalDistancePositive); |
|||
blendNormalDistanceNegative = addso.Find((HDAdditionalReflectionData d) => d.blendNormalDistanceNegative); |
|||
boxSideFadePositive = addso.Find((HDAdditionalReflectionData d) => d.boxSideFadePositive); |
|||
boxSideFadeNegative = addso.Find((HDAdditionalReflectionData d) => d.boxSideFadeNegative); |
|||
} |
|||
|
|||
public void Update() |
|||
{ |
|||
so.Update(); |
|||
addso.Update(); |
|||
|
|||
// Set the legacy blend distance to 0 so the legacy culling system use the probe extent
|
|||
legacyBlendDistance.floatValue = 0; |
|||
} |
|||
|
|||
public void Apply() |
|||
{ |
|||
so.ApplyModifiedProperties(); |
|||
addso.ApplyModifiedProperties(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: bd5f27599094ee7479eb849f9c26c187 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEditor.IMGUI.Controls; |
|||
using UnityEditorInternal; |
|||
using UnityEngine; |
|||
using UnityEngine.Events; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
partial class HDReflectionProbeEditor |
|||
{ |
|||
internal class SerializedReflectionProbe |
|||
{ |
|||
internal ReflectionProbe target; |
|||
internal HDAdditionalReflectionData targetData; |
|||
|
|||
internal SerializedObject so; |
|||
|
|||
internal SerializedProperty mode; |
|||
internal SerializedProperty renderDynamicObjects; |
|||
internal SerializedProperty customBakedTexture; |
|||
internal SerializedProperty refreshMode; |
|||
internal SerializedProperty timeSlicingMode; |
|||
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 influenceShape; |
|||
internal SerializedProperty influenceSphereRadius; |
|||
internal SerializedProperty useSeparateProjectionVolume; |
|||
internal SerializedProperty boxReprojectionVolumeSize; |
|||
internal SerializedProperty boxReprojectionVolumeCenter; |
|||
internal SerializedProperty sphereReprojectionVolumeRadius; |
|||
internal SerializedProperty blendDistancePositive; |
|||
internal SerializedProperty blendDistanceNegative; |
|||
internal SerializedProperty blendNormalDistancePositive; |
|||
internal SerializedProperty blendNormalDistanceNegative; |
|||
internal SerializedProperty boxSideFadePositive; |
|||
internal SerializedProperty boxSideFadeNegative; |
|||
internal SerializedProperty dimmer; |
|||
|
|||
public SerializedReflectionProbe(SerializedObject so, SerializedObject addso) |
|||
{ |
|||
this.so = so; |
|||
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"); |
|||
|
|||
influenceShape = addso.Find((HDAdditionalReflectionData d) => d.influenceShape); |
|||
influenceSphereRadius = addso.Find((HDAdditionalReflectionData d) => d.influenceSphereRadius); |
|||
useSeparateProjectionVolume = addso.Find((HDAdditionalReflectionData d) => d.useSeparateProjectionVolume); |
|||
boxReprojectionVolumeSize = addso.Find((HDAdditionalReflectionData d) => d.boxReprojectionVolumeSize); |
|||
boxReprojectionVolumeCenter = addso.Find((HDAdditionalReflectionData d) => d.boxReprojectionVolumeCenter); |
|||
sphereReprojectionVolumeRadius = addso.Find((HDAdditionalReflectionData d) => d.sphereReprojectionVolumeRadius); |
|||
dimmer = addso.Find((HDAdditionalReflectionData d) => d.dimmer); |
|||
blendDistancePositive = addso.Find((HDAdditionalReflectionData d) => d.blendDistancePositive); |
|||
blendDistanceNegative = addso.Find((HDAdditionalReflectionData d) => d.blendDistanceNegative); |
|||
blendNormalDistancePositive = addso.Find((HDAdditionalReflectionData d) => d.blendNormalDistancePositive); |
|||
blendNormalDistanceNegative = addso.Find((HDAdditionalReflectionData d) => d.blendNormalDistanceNegative); |
|||
boxSideFadePositive = addso.Find((HDAdditionalReflectionData d) => d.boxSideFadePositive); |
|||
boxSideFadeNegative = addso.Find((HDAdditionalReflectionData d) => d.boxSideFadeNegative); |
|||
} |
|||
} |
|||
|
|||
[Flags] |
|||
internal enum Operation |
|||
{ |
|||
None = 0, |
|||
FitVolumeToSurroundings = 1 << 0 |
|||
} |
|||
|
|||
internal class UIState |
|||
{ |
|||
AnimBool[] m_IsSectionExpandedModeSettings = new AnimBool[Enum.GetValues(typeof(ReflectionProbeMode)).Length]; |
|||
AnimBool[] m_IsSectionExpandedInfluenceShape = new AnimBool[Enum.GetValues(typeof(ReflectionInfluenceShape)).Length]; |
|||
|
|||
Editor owner { get; set; } |
|||
Operation operations { get; set; } |
|||
public bool HasOperation(Operation op) { return (operations & op) == op; } |
|||
public void ClearOperation(Operation op) { operations &= ~op; } |
|||
public void AddOperation(Operation op) { operations |= op; } |
|||
|
|||
public BoxBoundsHandle boxInfluenceHandle = new BoxBoundsHandle(); |
|||
public BoxBoundsHandle boxProjectionHandle = new BoxBoundsHandle(); |
|||
public BoxBoundsHandle boxBlendHandle = new BoxBoundsHandle(); |
|||
public BoxBoundsHandle boxBlendNormalHandle = new BoxBoundsHandle(); |
|||
public SphereBoundsHandle sphereInfluenceHandle = new SphereBoundsHandle(); |
|||
public SphereBoundsHandle sphereProjectionHandle = new SphereBoundsHandle(); |
|||
public SphereBoundsHandle sphereBlendHandle = new SphereBoundsHandle(); |
|||
public SphereBoundsHandle sphereBlendNormalHandle = new SphereBoundsHandle(); |
|||
public Matrix4x4 oldLocalSpace = Matrix4x4.identity; |
|||
|
|||
public AnimBool isSectionExpandedInfluenceVolume = new AnimBool(); |
|||
public AnimBool isSectionExpandedSeparateProjection = new AnimBool(); |
|||
public AnimBool isSectionExpandedCaptureSettings = new AnimBool(); |
|||
public AnimBool isSectionExpandedAdditional = new AnimBool(); |
|||
|
|||
List<AnimBool> m_AnimBools = new List<AnimBool>(); |
|||
|
|||
public bool HasAndClearOperation(Operation op) |
|||
{ |
|||
var has = HasOperation(op); |
|||
ClearOperation(op); |
|||
return has; |
|||
} |
|||
|
|||
public bool sceneViewEditing |
|||
{ |
|||
get { return IsReflectionProbeEditMode(EditMode.editMode) && EditMode.IsOwner(owner); } |
|||
} |
|||
|
|||
internal UIState() |
|||
{ |
|||
for (var i = 0; i < m_IsSectionExpandedModeSettings.Length; i++) |
|||
{ |
|||
m_IsSectionExpandedModeSettings[i] = new AnimBool(); |
|||
m_AnimBools.Add(m_IsSectionExpandedModeSettings[i]); |
|||
} |
|||
|
|||
for (var i = 0; i < m_IsSectionExpandedInfluenceShape.Length; i++) |
|||
{ |
|||
m_IsSectionExpandedInfluenceShape[i] = new AnimBool(); |
|||
m_AnimBools.Add(m_IsSectionExpandedInfluenceShape[i]); |
|||
} |
|||
|
|||
m_AnimBools.Add(isSectionExpandedInfluenceVolume); |
|||
m_AnimBools.Add(isSectionExpandedSeparateProjection); |
|||
m_AnimBools.Add(isSectionExpandedCaptureSettings); |
|||
m_AnimBools.Add(isSectionExpandedAdditional); |
|||
} |
|||
|
|||
internal void Reset( |
|||
Editor owner, |
|||
UnityAction repaint, |
|||
SerializedReflectionProbe p) |
|||
{ |
|||
this.owner = owner; |
|||
operations = 0; |
|||
|
|||
for (var i = 0; i < m_IsSectionExpandedModeSettings.Length; i++) |
|||
m_IsSectionExpandedModeSettings[i].value = p.mode.intValue == i; |
|||
|
|||
for (var i = 0; i < m_IsSectionExpandedInfluenceShape.Length; i++) |
|||
m_IsSectionExpandedInfluenceShape[i].value = p.influenceShape.intValue == i; |
|||
|
|||
isSectionExpandedSeparateProjection.value = p.useSeparateProjectionVolume.boolValue; |
|||
isSectionExpandedCaptureSettings.value = true; |
|||
isSectionExpandedInfluenceVolume.value = true; |
|||
isSectionExpandedAdditional.value = false; |
|||
|
|||
for (var i = 0; i < m_AnimBools.Count; ++i) |
|||
{ |
|||
m_AnimBools[i].valueChanged.RemoveAllListeners(); |
|||
m_AnimBools[i].valueChanged.AddListener(repaint); |
|||
} |
|||
} |
|||
|
|||
public AnimBool IsSectionExpandedMode(ReflectionProbeMode mode) |
|||
{ |
|||
return m_IsSectionExpandedModeSettings[(int)mode]; |
|||
} |
|||
|
|||
public void SetModeTarget(int value) |
|||
{ |
|||
for (var i = 0; i < m_IsSectionExpandedModeSettings.Length; i++) |
|||
m_IsSectionExpandedModeSettings[i].target = i == value; |
|||
} |
|||
|
|||
public AnimBool IsSectionExpandedShape(ReflectionInfluenceShape value) |
|||
{ |
|||
return m_IsSectionExpandedInfluenceShape[(int)value]; |
|||
} |
|||
|
|||
public void SetShapeTarget(int value) |
|||
{ |
|||
for (var i = 0; i < m_IsSectionExpandedInfluenceShape.Length; i++) |
|||
m_IsSectionExpandedInfluenceShape[i].target = i == value; |
|||
} |
|||
|
|||
internal void UpdateOldLocalSpace(ReflectionProbe target) |
|||
{ |
|||
oldLocalSpace = GetLocalSpace(target); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Reflection; |
|||
using UnityEditorInternal; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
using CED = CoreEditorDrawer<HDReflectionProbeEditor.UIState, HDReflectionProbeEditor.SerializedReflectionProbe>; |
|||
|
|||
partial class HDReflectionProbeEditor |
|||
{ |
|||
#region Sections
|
|||
static readonly CED.IDrawer[] k_PrimarySection = |
|||
{ |
|||
CED.Action(Drawer_ReflectionProbeMode), |
|||
CED.FadeGroup((s, p, o, i) => s.IsSectionExpandedMode((ReflectionProbeMode)i), |
|||
true, |
|||
CED.noop, // Baked
|
|||
CED.Action(Drawer_ModeSettingsRealtime), // Realtime
|
|||
CED.Action(Drawer_ModeSettingsCustom) // Custom
|
|||
), |
|||
CED.space, |
|||
CED.Action(Drawer_InfluenceShape), |
|||
//CED.Action(Drawer_IntensityMultiplier),
|
|||
CED.space, |
|||
CED.Action(Drawer_Toolbar), |
|||
CED.space |
|||
}; |
|||
|
|||
static readonly CED.IDrawer k_InfluenceVolumeSection = CED.FoldoutGroup( |
|||
"Influence volume settings", |
|||
(s, p, o) => s.isSectionExpandedInfluenceVolume, |
|||
true, |
|||
CED.FadeGroup( |
|||
(s, p, o, i) => s.IsSectionExpandedShape((ReflectionInfluenceShape)i), |
|||
false, |
|||
CED.Action(Drawer_InfluenceBoxSettings), // Box
|
|||
CED.Action(Drawer_InfluenceSphereSettings) // Sphere
|
|||
)/*, |
|||
CED.Action(Drawer_UseSeparateProjectionVolume)*/ |
|||
); |
|||
|
|||
static readonly CED.IDrawer k_SeparateProjectionVolumeSection = CED.FadeGroup( |
|||
(s, p, o, i) => s.isSectionExpandedSeparateProjection, |
|||
false, |
|||
CED.FoldoutGroup( |
|||
"Reprojection volume settings", |
|||
(s, p, o) => s.isSectionExpandedSeparateProjection, |
|||
true, |
|||
CED.FadeGroup( |
|||
(s, p, o, i) => s.IsSectionExpandedShape((ReflectionInfluenceShape)i), |
|||
false, |
|||
CED.Action(Drawer_ProjectionBoxSettings), // Box
|
|||
CED.Action(Drawer_ProjectionSphereSettings) // Sphere
|
|||
) |
|||
) |
|||
); |
|||
|
|||
static readonly CED.IDrawer k_CaptureSection = CED.FoldoutGroup( |
|||
"Capture settings", |
|||
(s, p, o) => s.isSectionExpandedCaptureSettings, |
|||
true, |
|||
CED.Action(Drawer_CaptureSettings) |
|||
); |
|||
|
|||
static readonly CED.IDrawer k_AdditionalSection = CED.FoldoutGroup( |
|||
"Additional settings", |
|||
(s, p, o) => s.isSectionExpandedAdditional, |
|||
true, |
|||
CED.Action(Drawer_AdditionalSettings) |
|||
); |
|||
|
|||
static readonly CED.IDrawer k_BakingActions = CED.Action(Drawer_BakeActions); |
|||
#endregion
|
|||
|
|||
static void Drawer_CaptureSettings(UIState s, SerializedReflectionProbe p, Editor owner) |
|||
{ |
|||
var renderPipelineAsset = (HDRenderPipelineAsset)GraphicsSettings.renderPipelineAsset; |
|||
p.resolution.intValue = renderPipelineAsset.GetRenderPipelineSettings().lightLoopSettings.reflectionCubemapSize; |
|||
EditorGUILayout.LabelField(CoreEditorUtils.GetContent("Resolution"), CoreEditorUtils.GetContent(p.resolution.intValue.ToString())); |
|||
|
|||
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(UIState s, SerializedReflectionProbe p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.dimmer); |
|||
|
|||
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 readonly string[] k_BakeCustomOptionText = { "Bake as new Cubemap..." }; |
|||
static readonly string[] k_BakeButtonsText = { "Bake All Reflection Probes" }; |
|||
static void Drawer_BakeActions(UIState s, SerializedReflectionProbe p, Editor owner) |
|||
{ |
|||
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) |
|||
{ |
|||
BakeCustomReflectionProbe(probe, false, true); |
|||
ResetProbeSceneTextureInMaterial(probe); |
|||
} |
|||
}, |
|||
GUILayout.ExpandWidth(true))) |
|||
{ |
|||
var probe = p.target; |
|||
BakeCustomReflectionProbe(probe, true, true); |
|||
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) |
|||
BakeAllReflectionProbesSnapshots(); |
|||
}, |
|||
GUILayout.ExpandWidth(true))) |
|||
{ |
|||
var probe = p.target; |
|||
BakeReflectionProbeSnapshot(probe); |
|||
ResetProbeSceneTextureInMaterial(probe); |
|||
GUIUtility.ExitGUI(); |
|||
} |
|||
|
|||
GUI.enabled = true; |
|||
break; |
|||
} |
|||
|
|||
case ReflectionProbeMode.Realtime: |
|||
// Not showing bake button in realtime
|
|||
break; |
|||
} |
|||
GUILayout.FlexibleSpace(); |
|||
EditorGUILayout.EndHorizontal(); |
|||
} |
|||
|
|||
#region Influence Volume
|
|||
static void Drawer_InfluenceBoxSettings(UIState s, SerializedReflectionProbe p, Editor owner) |
|||
{ |
|||
var maxBlendDistance = CalculateBoxMaxBlendDistance(s, p, owner); |
|||
CoreEditorUtils.DrawVector6Slider( |
|||
CoreEditorUtils.GetContent("Blend Distance|Area around the probe where it is blended with other probes. Only used in deferred probes."), |
|||
p.blendDistancePositive, p.blendDistanceNegative, Vector3.zero, maxBlendDistance); |
|||
|
|||
CoreEditorUtils.DrawVector6Slider( |
|||
CoreEditorUtils.GetContent("Blend Normal Distance|Area around the probe where the normals influence the probe. Only used in deferred probes."), |
|||
p.blendNormalDistancePositive, p.blendNormalDistanceNegative, Vector3.zero, maxBlendDistance); |
|||
|
|||
CoreEditorUtils.DrawVector6Slider( |
|||
CoreEditorUtils.GetContent("Face fade|Fade faces of the cubemap."), |
|||
p.boxSideFadePositive, p.boxSideFadeNegative, Vector3.zero, Vector3.one); |
|||
|
|||
EditorGUILayout.Space(); |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
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.")); |
|||
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.")); |
|||
EditorGUILayout.PropertyField(p.boxProjection, CoreEditorUtils.GetContent("Box Projection|Box projection 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 box projection 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")); |
|||
|
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
var center = p.boxOffset.vector3Value; |
|||
var size = p.boxSize.vector3Value; |
|||
if (ValidateAABB(p.target, ref center, ref size)) |
|||
{ |
|||
p.boxOffset.vector3Value = center; |
|||
p.boxSize.vector3Value = size; |
|||
} |
|||
} |
|||
} |
|||
|
|||
static void Drawer_InfluenceSphereSettings(UIState s, SerializedReflectionProbe p, Editor owner) |
|||
{ |
|||
var maxBlendDistance = CalculateSphereMaxBlendDistance(s, p, owner); |
|||
|
|||
var blendDistance = p.blendDistancePositive.vector3Value.x; |
|||
EditorGUI.BeginChangeCheck(); |
|||
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.blendDistancePositive.vector3Value = Vector3.one * blendDistance; |
|||
p.blendDistanceNegative.vector3Value = Vector3.one * blendDistance; |
|||
} |
|||
|
|||
var blendNormalDistance = p.blendNormalDistancePositive.vector3Value.x; |
|||
EditorGUI.BeginChangeCheck(); |
|||
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.blendNormalDistancePositive.vector3Value = Vector3.one * blendNormalDistance; |
|||
p.blendNormalDistanceNegative.vector3Value = Vector3.one * blendNormalDistance; |
|||
} |
|||
|
|||
EditorGUILayout.PropertyField(p.influenceSphereRadius, CoreEditorUtils.GetContent("Radius")); |
|||
EditorGUILayout.PropertyField(p.boxProjection, CoreEditorUtils.GetContent("Sphere Projection|Sphere projection causes reflections to appear to change based on the object's position within the probe's sphere, 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 sphere projection 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")); |
|||
} |
|||
#endregion
|
|||
|
|||
#region Projection Volume
|
|||
static void Drawer_UseSeparateProjectionVolume(UIState s, SerializedReflectionProbe p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.useSeparateProjectionVolume); |
|||
s.isSectionExpandedSeparateProjection.target = p.useSeparateProjectionVolume.boolValue; |
|||
} |
|||
|
|||
static void Drawer_ProjectionBoxSettings(UIState s, SerializedReflectionProbe p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.boxReprojectionVolumeSize); |
|||
EditorGUILayout.PropertyField(p.boxReprojectionVolumeCenter); |
|||
} |
|||
|
|||
static void Drawer_ProjectionSphereSettings(UIState s, SerializedReflectionProbe p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.sphereReprojectionVolumeRadius); |
|||
} |
|||
#endregion
|
|||
|
|||
#region Field Drawers
|
|||
static readonly GUIContent[] k_Content_ReflectionProbeMode = { new GUIContent("Baked"), new GUIContent("Custom"), new GUIContent("Realtime") }; |
|||
static readonly int[] k_Content_ReflectionProbeModeValues = { (int)ReflectionProbeMode.Baked, (int)ReflectionProbeMode.Custom, (int)ReflectionProbeMode.Realtime }; |
|||
static void Drawer_ReflectionProbeMode(UIState s, SerializedReflectionProbe p, Editor owner) |
|||
{ |
|||
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).")); |
|||
EditorGUI.showMixedValue = false; |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
s.SetModeTarget(p.mode.intValue); |
|||
foreach (var targetObject in p.so.targetObjects) |
|||
ResetProbeSceneTextureInMaterial((ReflectionProbe)targetObject); |
|||
} |
|||
} |
|||
|
|||
static void Drawer_InfluenceShape(UIState s, SerializedReflectionProbe p, Editor owner) |
|||
{ |
|||
EditorGUI.BeginChangeCheck(); |
|||
EditorGUI.showMixedValue = p.influenceShape.hasMultipleDifferentValues; |
|||
EditorGUILayout.PropertyField(p.influenceShape, CoreEditorUtils.GetContent("Shape")); |
|||
EditorGUI.showMixedValue = false; |
|||
if (EditorGUI.EndChangeCheck()) |
|||
s.SetShapeTarget(p.influenceShape.intValue); |
|||
} |
|||
|
|||
static void Drawer_IntensityMultiplier(UIState s, SerializedReflectionProbe 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(UIState s, SerializedReflectionProbe 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 Func<Bounds> GetBoundsGetter(SerializedReflectionProbe 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; |
|||
}; |
|||
} |
|||
#endregion
|
|||
|
|||
#region Mode Specific Settings
|
|||
static void Drawer_ModeSettingsCustom(UIState s, SerializedReflectionProbe p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.renderDynamicObjects, CoreEditorUtils.GetContent("Dynamic Objects|If enabled dynamic objects are also rendered into the cubemap")); |
|||
|
|||
p.customBakedTexture.objectReferenceValue = EditorGUILayout.ObjectField(CoreEditorUtils.GetContent("Cubemap"), p.customBakedTexture.objectReferenceValue, typeof(Cubemap), false); |
|||
} |
|||
|
|||
static void Drawer_ModeSettingsRealtime(UIState s, SerializedReflectionProbe p, Editor owner) |
|||
{ |
|||
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
|
|||
|
|||
static float CalculateSphereMaxBlendDistance(UIState s, SerializedReflectionProbe p, Editor o) |
|||
{ |
|||
return p.influenceSphereRadius.floatValue; |
|||
} |
|||
|
|||
static Vector3 CalculateBoxMaxBlendDistance(UIState s, SerializedReflectionProbe p, Editor o) |
|||
{ |
|||
return p.boxSize.vector3Value * 0.5f; |
|||
} |
|||
|
|||
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 }); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue