浏览代码
Merge pull request #751 from Unity-Technologies/feature/HDCameraEditor
Merge pull request #751 from Unity-Technologies/feature/HDCameraEditor
Feature/hd camera editor/main
当前提交
82a58487
共有 47 个文件被更改,包括 2324 次插入 和 971 次删除
-
15ScriptableRenderPipeline/Core/CoreRP/CoreUtils.cs
-
97ScriptableRenderPipeline/Core/CoreRP/Editor/CoreEditorDrawers.cs
-
29ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDAdditionalCameraData.cs
-
16ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineInspector.Styles.cs
-
115ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineInspector.cs
-
32ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineMenuItems.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/HDReflectionProbeUI.Drawers.cs.meta
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditorUtility.cs.meta
-
22ScriptableRenderPipeline/Core/CoreRP/DelegateUtility.cs
-
11ScriptableRenderPipeline/Core/CoreRP/DelegateUtility.cs.meta
-
214ScriptableRenderPipeline/Core/CoreRP/Editor/CameraEditorUtils.cs
-
11ScriptableRenderPipeline/Core/CoreRP/Editor/CameraEditorUtils.cs.meta
-
34ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/BaseUI.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/BaseUI.cs.meta
-
8ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera.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
-
8ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings.meta
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.cs.meta
-
91ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedHDCamera.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/SerializedHDCamera.cs.meta
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Handlers.cs.meta
-
301ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraUI.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraUI.cs.meta
-
70ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.Handlers.cs
-
75ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Camera/HDCameraEditor.cs
-
76ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedFrameSettings.cs
-
30ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedLightLoopSettings.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedFrameSettings.cs.meta
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/SerializedLightLoopSettings.cs.meta
-
142ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/FrameSettingsUI.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/FrameSettingsUI.cs.meta
-
64ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/LightLoopSettingsUI.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/RenderLoopSettings/LightLoopSettingsUI.cs.meta
-
196ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditor.Data.cs
-
403ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditor.Drawers.cs
-
0/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeUI.Drawers.cs.meta
-
0/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/HDReflectionProbeEditorUtility.cs.meta
|
|||
using System; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering |
|||
{ |
|||
public static class DelegateUtility |
|||
{ |
|||
public static Delegate Cast(Delegate source, Type type) |
|||
{ |
|||
if (source == null) |
|||
return null; |
|||
Delegate[] delegates = source.GetInvocationList(); |
|||
if (delegates.Length == 1) |
|||
return Delegate.CreateDelegate(type, |
|||
delegates[0].Target, delegates[0].Method); |
|||
Delegate[] delegatesDest = new Delegate[delegates.Length]; |
|||
for (int nDelegate = 0; nDelegate < delegates.Length; nDelegate++) |
|||
delegatesDest[nDelegate] = Delegate.CreateDelegate(type, |
|||
delegates[nDelegate].Target, delegates[nDelegate].Method); |
|||
return Delegate.Combine(delegatesDest); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 13bcacf4237fb3c4e9b547cc7420a120 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
public static class CameraEditorUtils |
|||
{ |
|||
public delegate Camera GetPreviewCamera(Camera sourceCamera, Vector2 previewSize); |
|||
|
|||
static readonly Color k_ColorThemeCameraGizmo = new Color(233f / 255f, 233f / 255f, 233f / 255f, 128f / 255f); |
|||
const float k_PreviewNormalizedSize = 0.2f; |
|||
|
|||
internal static Material s_GUITextureBlit2SRGBMaterial; |
|||
internal static Material GUITextureBlit2SRGBMaterial |
|||
{ |
|||
get |
|||
{ |
|||
if (!s_GUITextureBlit2SRGBMaterial) |
|||
{ |
|||
Shader shader = EditorGUIUtility.LoadRequired("SceneView/GUITextureBlit2SRGB.shader") as Shader; |
|||
s_GUITextureBlit2SRGBMaterial = new Material(shader); |
|||
s_GUITextureBlit2SRGBMaterial.hideFlags = HideFlags.HideAndDontSave; |
|||
} |
|||
s_GUITextureBlit2SRGBMaterial.SetFloat("_ManualTex2SRGB", QualitySettings.activeColorSpace == ColorSpace.Linear ? 1.0f : 0.0f); |
|||
return s_GUITextureBlit2SRGBMaterial; |
|||
} |
|||
} |
|||
|
|||
public static void HandleFrustrum(Camera c) |
|||
{ |
|||
Color orgHandlesColor = Handles.color; |
|||
Color slidersColor = k_ColorThemeCameraGizmo; |
|||
slidersColor.a *= 2f; |
|||
Handles.color = slidersColor; |
|||
|
|||
// get the corners of the far clip plane in world space
|
|||
var far = new Vector3[4]; |
|||
float frustumAspect; |
|||
if (!GetFrustum(c, null, far, out frustumAspect)) |
|||
return; |
|||
var leftBottomFar = far[0]; |
|||
var leftTopFar = far[1]; |
|||
var rightTopFar = far[2]; |
|||
var rightBottomFar = far[3]; |
|||
|
|||
// manage our own gui changed state, so we can use it for individual slider changes
|
|||
var guiChanged = GUI.changed; |
|||
|
|||
// FOV handles
|
|||
var farMid = Vector3.Lerp(leftBottomFar, rightTopFar, 0.5f); |
|||
|
|||
// Top and bottom handles
|
|||
float halfHeight = -1.0f; |
|||
var changedPosition = MidPointPositionSlider(leftTopFar, rightTopFar, c.transform.up); |
|||
if (!GUI.changed) |
|||
changedPosition = MidPointPositionSlider(leftBottomFar, rightBottomFar, -c.transform.up); |
|||
if (GUI.changed) |
|||
halfHeight = (changedPosition - farMid).magnitude; |
|||
|
|||
// Left and right handles
|
|||
GUI.changed = false; |
|||
changedPosition = MidPointPositionSlider(rightBottomFar, rightTopFar, c.transform.right); |
|||
if (!GUI.changed) |
|||
changedPosition = MidPointPositionSlider(leftBottomFar, leftTopFar, -c.transform.right); |
|||
if (GUI.changed) |
|||
halfHeight = (changedPosition - farMid).magnitude / frustumAspect; |
|||
|
|||
// Update camera settings if changed
|
|||
if (halfHeight >= 0.0f) |
|||
{ |
|||
Undo.RecordObject(c, "Adjust Camera"); |
|||
if (c.orthographic) |
|||
c.orthographicSize = halfHeight; |
|||
else |
|||
{ |
|||
Vector3 pos = farMid + c.transform.up * halfHeight; |
|||
c.fieldOfView = Vector3.Angle(c.transform.forward, (pos - c.transform.position)) * 2f; |
|||
} |
|||
guiChanged = true; |
|||
} |
|||
|
|||
GUI.changed = guiChanged; |
|||
Handles.color = orgHandlesColor; |
|||
} |
|||
|
|||
public static void DrawCameraSceneViewOverlay(Object target, SceneView sceneView, GetPreviewCamera previewCameraGetter) |
|||
{ |
|||
if (target == null) return; |
|||
|
|||
// cache some deep values
|
|||
var c = (Camera)target; |
|||
|
|||
var previewSize = Handles.GetMainGameViewSize(); |
|||
if (previewSize.x < 0f) |
|||
{ |
|||
// Fallback to Scene View of not a valid game view size
|
|||
previewSize.x = sceneView.position.width; |
|||
previewSize.y = sceneView.position.height; |
|||
} |
|||
// Apply normalizedviewport rect of camera
|
|||
var normalizedViewPortRect = c.rect; |
|||
previewSize.x *= Mathf.Max(normalizedViewPortRect.width, 0f); |
|||
previewSize.y *= Mathf.Max(normalizedViewPortRect.height, 0f); |
|||
|
|||
// Prevent using invalid previewSize
|
|||
if (previewSize.x <= 0f || previewSize.y <= 0f) |
|||
return; |
|||
|
|||
var aspect = previewSize.x / previewSize.y; |
|||
|
|||
// Scale down (fit to scene view)
|
|||
previewSize.y = k_PreviewNormalizedSize * sceneView.position.height; |
|||
previewSize.x = previewSize.y * aspect; |
|||
if (previewSize.y > sceneView.position.height * 0.5f) |
|||
{ |
|||
previewSize.y = sceneView.position.height * 0.5f; |
|||
previewSize.x = previewSize.y * aspect; |
|||
} |
|||
if (previewSize.x > sceneView.position.width * 0.5f) |
|||
{ |
|||
previewSize.x = sceneView.position.width * 0.5f; |
|||
previewSize.y = previewSize.x / aspect; |
|||
} |
|||
|
|||
// Get and reserve rect
|
|||
Rect cameraRect = GUILayoutUtility.GetRect(previewSize.x, previewSize.y); |
|||
|
|||
if (Event.current.type == EventType.Repaint) |
|||
{ |
|||
var previewCamera = previewCameraGetter(c, previewSize); |
|||
if (previewCamera.targetTexture == null) |
|||
{ |
|||
Debug.LogError("The preview camera must render in a render target"); |
|||
return; |
|||
} |
|||
|
|||
GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear; |
|||
previewCamera.Render(); |
|||
GL.sRGBWrite = false; |
|||
Graphics.DrawTexture(cameraRect, previewCamera.targetTexture, new Rect(0, 0, 1, 1), 0, 0, 0, 0, GUI.color, GUITextureBlit2SRGBMaterial); |
|||
} |
|||
} |
|||
|
|||
public static bool IsViewPortRectValidToRender(Rect normalizedViewPortRect) |
|||
{ |
|||
if (normalizedViewPortRect.width <= 0f || normalizedViewPortRect.height <= 0f) |
|||
return false; |
|||
if (normalizedViewPortRect.x >= 1f || normalizedViewPortRect.xMax <= 0f) |
|||
return false; |
|||
if (normalizedViewPortRect.y >= 1f || normalizedViewPortRect.yMax <= 0f) |
|||
return false; |
|||
return true; |
|||
} |
|||
|
|||
public static float GetGameViewAspectRatio() |
|||
{ |
|||
Vector2 gameViewSize = Handles.GetMainGameViewSize(); |
|||
if (gameViewSize.x < 0f) |
|||
{ |
|||
// Fallback to Scene View of not a valid game view size
|
|||
gameViewSize.x = Screen.width; |
|||
gameViewSize.y = Screen.height; |
|||
} |
|||
|
|||
return gameViewSize.x / gameViewSize.y; |
|||
} |
|||
|
|||
public static float GetFrustumAspectRatio(Camera camera) |
|||
{ |
|||
var normalizedViewPortRect = camera.rect; |
|||
if (normalizedViewPortRect.width <= 0f || normalizedViewPortRect.height <= 0f) |
|||
return -1f; |
|||
|
|||
var viewportAspect = normalizedViewPortRect.width / normalizedViewPortRect.height; |
|||
return GetGameViewAspectRatio() * viewportAspect; |
|||
} |
|||
|
|||
// Returns near- and far-corners in this order: leftBottom, leftTop, rightTop, rightBottom
|
|||
// Assumes input arrays are of length 4 (if allocated)
|
|||
public static bool GetFrustum(Camera camera, Vector3[] near, Vector3[] far, out float frustumAspect) |
|||
{ |
|||
frustumAspect = GetFrustumAspectRatio(camera); |
|||
if (frustumAspect < 0) |
|||
return false; |
|||
|
|||
if (far != null) |
|||
{ |
|||
far[0] = new Vector3(0, 0, camera.farClipPlane); // leftBottomFar
|
|||
far[1] = new Vector3(0, 1, camera.farClipPlane); // leftTopFar
|
|||
far[2] = new Vector3(1, 1, camera.farClipPlane); // rightTopFar
|
|||
far[3] = new Vector3(1, 0, camera.farClipPlane); // rightBottomFar
|
|||
for (int i = 0; i < 4; ++i) |
|||
far[i] = camera.ViewportToWorldPoint(far[i]); |
|||
} |
|||
|
|||
if (near != null) |
|||
{ |
|||
near[0] = new Vector3(0, 0, camera.nearClipPlane); // leftBottomNear
|
|||
near[1] = new Vector3(0, 1, camera.nearClipPlane); // leftTopNear
|
|||
near[2] = new Vector3(1, 1, camera.nearClipPlane); // rightTopNear
|
|||
near[3] = new Vector3(1, 0, camera.nearClipPlane); // rightBottomNear
|
|||
for (int i = 0; i < 4; ++i) |
|||
near[i] = camera.ViewportToWorldPoint(near[i]); |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
static Vector3 MidPointPositionSlider(Vector3 position1, Vector3 position2, Vector3 direction) |
|||
{ |
|||
Vector3 midPoint = Vector3.Lerp(position1, position2, 0.5f); |
|||
return Handles.Slider(midPoint, direction, HandleUtility.GetHandleSize(midPoint) * 0.03f, Handles.DotHandleCap, 0f); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c9fabbcdc8ab50c44a8112c70c67735c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEngine.Events; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
public class BaseUI<TType> |
|||
{ |
|||
protected AnimBool[] m_AnimBools = null; |
|||
protected TType data { get; private set; } |
|||
|
|||
public BaseUI(int animBoolCount) |
|||
{ |
|||
m_AnimBools = new AnimBool[animBoolCount]; |
|||
for (var i = 0; i < m_AnimBools.Length; ++i) |
|||
m_AnimBools[i] = new AnimBool(); |
|||
} |
|||
|
|||
public virtual void Reset(TType data, UnityAction repaint) |
|||
{ |
|||
this.data = data; |
|||
for (var i = 0; i < m_AnimBools.Length; ++i) |
|||
{ |
|||
m_AnimBools[i].valueChanged.RemoveAllListeners(); |
|||
m_AnimBools[i].valueChanged.AddListener(repaint); |
|||
} |
|||
|
|||
Update(); |
|||
} |
|||
|
|||
public virtual void Update() |
|||
{ |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 16cf8f99963cf854e96c25e5f022bf46 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 9dc3c4b1d2c33704f894c37b8b2a1057 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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: |
|
|||
fileFormatVersion: 2 |
|||
guid: beec4e0c83397f34086a0bf8d0063062 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 770782413fdaa404c8616b39223b69e9 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
class SerializedHDCamera |
|||
{ |
|||
public SerializedObject serializedObject; |
|||
public SerializedObject serializedAdditionalDataObject; |
|||
|
|||
public SerializedProperty backgroundColor; |
|||
public SerializedProperty normalizedViewPortRect; |
|||
public SerializedProperty fieldOfView; |
|||
public SerializedProperty orthographic; |
|||
public SerializedProperty orthographicSize; |
|||
public SerializedProperty depth; |
|||
public SerializedProperty cullingMask; |
|||
public SerializedProperty occlusionCulling; |
|||
public SerializedProperty targetTexture; |
|||
public SerializedProperty HDR; |
|||
public SerializedProperty stereoConvergence; |
|||
public SerializedProperty stereoSeparation; |
|||
public SerializedProperty nearClippingPlane; |
|||
public SerializedProperty farClippingPlane; |
|||
public SerializedProperty targetEye; |
|||
|
|||
#if ENABLE_MULTIPLE_DISPLAYS
|
|||
public SerializedProperty targetDisplay; |
|||
#endif
|
|||
|
|||
public SerializedProperty renderingPath; |
|||
public SerializedProperty volumeLayerMask; |
|||
public SerializedFrameSettings frameSettings; |
|||
|
|||
|
|||
public SerializedHDCamera(SerializedObject serializedObject) |
|||
{ |
|||
this.serializedObject = serializedObject; |
|||
var additionals = CoreEditorUtils.GetAdditionalData<HDAdditionalCameraData>(serializedObject.targetObjects); |
|||
serializedAdditionalDataObject = new SerializedObject(additionals); |
|||
|
|||
var hideFlags = serializedAdditionalDataObject.FindProperty("m_ObjectHideFlags"); |
|||
hideFlags.intValue = (int)HideFlags.HideInInspector; |
|||
serializedAdditionalDataObject.ApplyModifiedProperties(); |
|||
|
|||
backgroundColor = serializedObject.FindProperty("m_BackGroundColor"); |
|||
normalizedViewPortRect = serializedObject.FindProperty("m_NormalizedViewPortRect"); |
|||
nearClippingPlane = serializedObject.FindProperty("near clip plane"); |
|||
farClippingPlane = serializedObject.FindProperty("far clip plane"); |
|||
fieldOfView = serializedObject.FindProperty("field of view"); |
|||
orthographic = serializedObject.FindProperty("orthographic"); |
|||
orthographicSize = serializedObject.FindProperty("orthographic size"); |
|||
depth = serializedObject.FindProperty("m_Depth"); |
|||
cullingMask = serializedObject.FindProperty("m_CullingMask"); |
|||
occlusionCulling = serializedObject.FindProperty("m_OcclusionCulling"); |
|||
targetTexture = serializedObject.FindProperty("m_TargetTexture"); |
|||
HDR = serializedObject.FindProperty("m_HDR"); |
|||
|
|||
stereoConvergence = serializedObject.FindProperty("m_StereoConvergence"); |
|||
stereoSeparation = serializedObject.FindProperty("m_StereoSeparation"); |
|||
|
|||
#if ENABLE_MULTIPLE_DISPLAYS
|
|||
targetDisplay = serializedObject.FindProperty("m_TargetDisplay"); |
|||
#endif
|
|||
|
|||
targetEye = serializedObject.FindProperty("m_TargetEye"); |
|||
|
|||
renderingPath = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.renderingPath); |
|||
volumeLayerMask = serializedAdditionalDataObject.Find((HDAdditionalCameraData d) => d.volumeLayerMask); |
|||
frameSettings = new SerializedFrameSettings(serializedAdditionalDataObject.FindProperty("m_FrameSettings")); |
|||
} |
|||
|
|||
public void Update() |
|||
{ |
|||
serializedObject.Update(); |
|||
serializedAdditionalDataObject.Update(); |
|||
|
|||
// Be sure legacy HDR option is disable on camera as it cause banding in SceneView. Yes, it is a contradiction, but well, Unity...
|
|||
// When HDR option is enabled, Unity render in FP16 then convert to 8bit with a stretch copy (this cause banding as it should be convert to sRGB (or other color appropriate color space)), then do a final shader with sRGB conversion
|
|||
// When LDR, unity render in 8bitSRGB, then do a final shader with sRGB conversion
|
|||
// What should be done is just in our Post process we convert to sRGB and store in a linear 10bit, but require C++ change...
|
|||
HDR.boolValue = false; |
|||
} |
|||
|
|||
public void Apply() |
|||
{ |
|||
serializedObject.ApplyModifiedProperties(); |
|||
serializedAdditionalDataObject.ApplyModifiedProperties(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: dd7e7dd92935baf419c0d25a37bbb971 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 2cf892864fc4f87428d021b8cf317f05 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Reflection; |
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEngine; |
|||
using UnityEngine.Assertions; |
|||
using UnityEngine.Events; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
using _ = CoreEditorUtils; |
|||
using CED = CoreEditorDrawer<HDCameraUI, SerializedHDCamera>; |
|||
|
|||
class HDCameraUI : BaseUI<SerializedHDCamera> |
|||
{ |
|||
static HDCameraUI() |
|||
{ |
|||
Inspector = new [] |
|||
{ |
|||
SectionPrimarySettings, |
|||
SectionCaptureSettings, |
|||
SectionOutputSettings, |
|||
SectionXRSettings, |
|||
SectionRenderLoopSettings |
|||
}; |
|||
} |
|||
|
|||
public static readonly CED.IDrawer[] Inspector = null; |
|||
|
|||
public static readonly CED.IDrawer SectionPrimarySettings = CED.Group( |
|||
CED.Action(Drawer_FieldBackgroundColor), |
|||
CED.Action(Drawer_FieldCullingMask), |
|||
CED.Action(Drawer_FieldVolumeLayerMask), |
|||
CED.space, |
|||
CED.Action(Drawer_Projection), |
|||
CED.Action(Drawer_FieldClippingPlanes), |
|||
CED.space, |
|||
CED.Action(Drawer_CameraWarnings), |
|||
CED.Action(Drawer_FieldRenderingPath), |
|||
CED.space |
|||
); |
|||
|
|||
public static readonly CED.IDrawer SectionCaptureSettings = CED.FoldoutGroup( |
|||
"Capture Settings", |
|||
(s, p, o) => s.isSectionExpandedCaptureSettings, |
|||
true, |
|||
CED.Action(Drawer_FieldOcclusionCulling), |
|||
CED.Action(Drawer_FieldNormalizedViewPort)); |
|||
|
|||
public static readonly CED.IDrawer SectionOutputSettings = CED.FoldoutGroup( |
|||
"Output Settings", |
|||
(s, p, o) => s.isSectionExpandedOutputSettings, |
|||
true, |
|||
#if ENABLE_MULTIPLE_DISPLAYS
|
|||
CED.Action(Drawer_SectionMultiDisplay), |
|||
#endif
|
|||
CED.Action(Drawer_FieldDepth), |
|||
CED.Action(Drawer_FieldRenderTarget)); |
|||
|
|||
public static readonly CED.IDrawer SectionXRSettings = CED.FadeGroup( |
|||
(s, d, o, i) => s.isSectionAvailableXRSettings, |
|||
false, |
|||
CED.FoldoutGroup( |
|||
"XR Settings", |
|||
(s, p, o) => s.isSectionExpandedXRSettings, |
|||
true, |
|||
CED.Action(Drawer_FieldVR), |
|||
CED.Action(Drawer_FieldTargetEye))); |
|||
|
|||
public static readonly CED.IDrawer SectionRenderLoopSettings = CED.FadeGroup( |
|||
(s, d, o, i) => s.isSectionAvailableRenderLoopSettings, |
|||
false, |
|||
CED.Select( |
|||
(s, d, o) => s.frameSettingsUI, |
|||
(s, d, o) => d.frameSettings, |
|||
FrameSettingsUI.SectionRenderingPasses, |
|||
FrameSettingsUI.SectionRenderingSettings, |
|||
FrameSettingsUI.SectionLightingSettings), |
|||
CED.Select( |
|||
(s, d, o) => s.frameSettingsUI.lightLoopSettingsUI, |
|||
(s, d, o) => d.frameSettings.lightLoopSettings, |
|||
LightLoopSettingsUI.SectionLightLoopSettings)); |
|||
|
|||
enum ProjectionType { Perspective, Orthographic }; |
|||
|
|||
SerializedHDCamera m_SerializedHdCamera; |
|||
|
|||
public AnimBool isSectionExpandedOrthoOptions { get { return m_AnimBools[0]; } } |
|||
public AnimBool isSectionExpandedCaptureSettings { get { return m_AnimBools[1]; } } |
|||
public AnimBool isSectionExpandedOutputSettings { get { return m_AnimBools[2]; } } |
|||
public AnimBool isSectionAvailableRenderLoopSettings { get { return m_AnimBools[3]; } } |
|||
public AnimBool isSectionExpandedXRSettings { get { return m_AnimBools[4]; } } |
|||
public AnimBool isSectionAvailableXRSettings { get { return m_AnimBools[5]; } } |
|||
|
|||
public bool canOverrideRenderLoopSettings { get; set; } |
|||
|
|||
public FrameSettingsUI frameSettingsUI = new FrameSettingsUI(); |
|||
|
|||
public HDCameraUI() |
|||
: base(6) |
|||
{ |
|||
canOverrideRenderLoopSettings = false; |
|||
} |
|||
|
|||
public override void Reset(SerializedHDCamera data, UnityAction repaint) |
|||
{ |
|||
m_SerializedHdCamera = data; |
|||
frameSettingsUI.Reset(data.frameSettings, repaint); |
|||
|
|||
for (var i = 0; i < m_AnimBools.Length; ++i) |
|||
{ |
|||
m_AnimBools[i].valueChanged.RemoveAllListeners(); |
|||
m_AnimBools[i].valueChanged.AddListener(repaint); |
|||
} |
|||
|
|||
Update(); |
|||
} |
|||
|
|||
public override void Update() |
|||
{ |
|||
base.Update(); |
|||
|
|||
var renderingPath = (HDAdditionalCameraData.RenderingPath)m_SerializedHdCamera.renderingPath.intValue; |
|||
canOverrideRenderLoopSettings = renderingPath == HDAdditionalCameraData.RenderingPath.Custom; |
|||
|
|||
isSectionExpandedOrthoOptions.target = !m_SerializedHdCamera.orthographic.hasMultipleDifferentValues && m_SerializedHdCamera.orthographic.boolValue; |
|||
isSectionAvailableXRSettings.target = PlayerSettings.virtualRealitySupported; |
|||
// SRP settings are available only if the rendering path is not the Default one (configured by the SRP asset)
|
|||
isSectionAvailableRenderLoopSettings.target = canOverrideRenderLoopSettings; |
|||
|
|||
frameSettingsUI.Update(); |
|||
} |
|||
|
|||
static void Drawer_FieldBackgroundColor(HDCameraUI s, SerializedHDCamera p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.backgroundColor, _.GetContent("Background Color|The Camera clears the screen to this color before rendering.")); |
|||
} |
|||
|
|||
static void Drawer_FieldVolumeLayerMask(HDCameraUI s, SerializedHDCamera p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.volumeLayerMask, _.GetContent("Volume Layer Mask")); |
|||
} |
|||
|
|||
static void Drawer_FieldCullingMask(HDCameraUI s, SerializedHDCamera p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.cullingMask, _.GetContent("Culling Mask")); |
|||
} |
|||
|
|||
static void Drawer_Projection(HDCameraUI s, SerializedHDCamera p, Editor owner) |
|||
{ |
|||
ProjectionType projectionType = p.orthographic.boolValue ? ProjectionType.Orthographic : ProjectionType.Perspective; |
|||
EditorGUI.BeginChangeCheck(); |
|||
EditorGUI.showMixedValue = p.orthographic.hasMultipleDifferentValues; |
|||
projectionType = (ProjectionType)EditorGUILayout.EnumPopup(_.GetContent("Projection|How the Camera renders perspective.\n\nChoose Perspective to render objects with perspective.\n\nChoose Orthographic to render objects uniformly, with no sense of perspective."), projectionType); |
|||
EditorGUI.showMixedValue = false; |
|||
if (EditorGUI.EndChangeCheck()) |
|||
p.orthographic.boolValue = (projectionType == ProjectionType.Orthographic); |
|||
|
|||
if (!p.orthographic.hasMultipleDifferentValues) |
|||
{ |
|||
if (projectionType == ProjectionType.Orthographic) |
|||
EditorGUILayout.PropertyField(p.orthographicSize, _.GetContent("Size")); |
|||
else |
|||
EditorGUILayout.Slider(p.fieldOfView, 1f, 179f, _.GetContent("Field of View|The width of the Camera’s view angle, measured in degrees along the local Y axis.")); |
|||
} |
|||
} |
|||
|
|||
static void Drawer_FieldClippingPlanes(HDCameraUI s, SerializedHDCamera p, Editor owner) |
|||
{ |
|||
GUILayout.BeginHorizontal(); |
|||
EditorGUILayout.PrefixLabel(_.GetContent("Clipping Planes")); |
|||
GUILayout.BeginVertical(); |
|||
var labelWidth = EditorGUIUtility.labelWidth; |
|||
EditorGUIUtility.labelWidth = 45; |
|||
EditorGUILayout.PropertyField(p.nearClippingPlane, _.GetContent("Near|The closest point relative to the camera that drawing will occur.")); |
|||
EditorGUILayout.PropertyField(p.farClippingPlane, _.GetContent("Far|The furthest point relative to the camera that drawing will occur.\n")); |
|||
GUILayout.EndVertical(); |
|||
GUILayout.EndHorizontal(); |
|||
EditorGUIUtility.labelWidth = labelWidth; |
|||
} |
|||
|
|||
static void Drawer_FieldNormalizedViewPort(HDCameraUI s, SerializedHDCamera p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.normalizedViewPortRect, _.GetContent("Viewport Rect|Four values that indicate where on the screen this camera view will be drawn. Measured in Viewport Coordinates (values 0–1).")); |
|||
} |
|||
|
|||
static void Drawer_FieldDepth(HDCameraUI s, SerializedHDCamera p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.depth, _.GetContent("Depth")); |
|||
} |
|||
|
|||
static void Drawer_FieldRenderingPath(HDCameraUI s, SerializedHDCamera p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.renderingPath, _.GetContent("Rendering Path")); |
|||
} |
|||
|
|||
static void Drawer_FieldRenderTarget(HDCameraUI s, SerializedHDCamera p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.targetTexture); |
|||
|
|||
// show warning if we have deferred but manual MSAA set
|
|||
// only do this if the m_TargetTexture has the same values across all target cameras
|
|||
if (!p.targetTexture.hasMultipleDifferentValues) |
|||
{ |
|||
var targetTexture = p.targetTexture.objectReferenceValue as RenderTexture; |
|||
if (targetTexture |
|||
&& targetTexture.antiAliasing > 1 |
|||
&& !p.frameSettings.enableForwardRenderingOnly.boolValue) |
|||
{ |
|||
EditorGUILayout.HelpBox("Manual MSAA target set with deferred rendering. This will lead to undefined behavior.", MessageType.Warning, true); |
|||
} |
|||
} |
|||
} |
|||
|
|||
static void Drawer_FieldOcclusionCulling(HDCameraUI s, SerializedHDCamera p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.occlusionCulling, _.GetContent("Occlusion Culling")); |
|||
} |
|||
|
|||
static void Drawer_CameraWarnings(HDCameraUI s, SerializedHDCamera p, Editor owner) |
|||
{ |
|||
foreach (Camera camera in p.serializedObject.targetObjects) |
|||
{ |
|||
var warnings = GetCameraBufferWarnings(camera); |
|||
if (warnings.Length > 0) |
|||
EditorGUILayout.HelpBox(string.Join("\n\n", warnings), MessageType.Warning, true); |
|||
} |
|||
} |
|||
|
|||
static void Drawer_FieldVR(HDCameraUI s, SerializedHDCamera p, Editor owner) |
|||
{ |
|||
if (s.canOverrideRenderLoopSettings) |
|||
EditorGUILayout.PropertyField(p.frameSettings.enableStereo, _.GetContent("Enable Stereo")); |
|||
else |
|||
{ |
|||
var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset; |
|||
Assert.IsNotNull(hdrp, "This Editor is valid only for HDRP"); |
|||
var enableStereo = hdrp.GetFrameSettings().enableStereo; |
|||
GUI.enabled = false; |
|||
EditorGUILayout.Toggle(_.GetContent("Enable Stereo (Set by HDRP)"), enableStereo); |
|||
GUI.enabled = true; |
|||
} |
|||
EditorGUILayout.PropertyField(p.stereoSeparation, _.GetContent("Stereo Separation")); |
|||
EditorGUILayout.PropertyField(p.stereoConvergence, _.GetContent("Stereo Convergence")); |
|||
} |
|||
|
|||
#if ENABLE_MULTIPLE_DISPLAYS
|
|||
static void Drawer_SectionMultiDisplay(HDCameraUI s, SerializedHDCamera p, Editor owner) |
|||
{ |
|||
if (ModuleManager_ShouldShowMultiDisplayOption()) |
|||
{ |
|||
var prevDisplay = p.targetDisplay.intValue; |
|||
EditorGUILayout.IntPopup(p.targetDisplay, DisplayUtility_GetDisplayNames(), DisplayUtility_GetDisplayIndices(), _.GetContent("Target Display")); |
|||
if (prevDisplay != p.targetDisplay.intValue) |
|||
UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); |
|||
} |
|||
} |
|||
#endif
|
|||
|
|||
static readonly int[] k_TargetEyeValues = { (int)StereoTargetEyeMask.Both, (int)StereoTargetEyeMask.Left, (int)StereoTargetEyeMask.Right, (int)StereoTargetEyeMask.None }; |
|||
static readonly GUIContent[] k_TargetEyes = |
|||
{ |
|||
new GUIContent("Both"), |
|||
new GUIContent("Left"), |
|||
new GUIContent("Right"), |
|||
new GUIContent("None (Main Display)"), |
|||
}; |
|||
static void Drawer_FieldTargetEye(HDCameraUI s, SerializedHDCamera p, Editor owner) |
|||
{ |
|||
EditorGUILayout.IntPopup(p.targetEye, k_TargetEyes, k_TargetEyeValues, _.GetContent("Target Eye")); |
|||
} |
|||
|
|||
static MethodInfo k_DisplayUtility_GetDisplayIndices = Type.GetType("UnityEditor.DisplayUtility,UnityEditor") |
|||
.GetMethod("GetDisplayIndices"); |
|||
static int[] DisplayUtility_GetDisplayIndices() |
|||
{ |
|||
return (int[])k_DisplayUtility_GetDisplayIndices.Invoke(null, null); |
|||
} |
|||
|
|||
static MethodInfo k_DisplayUtility_GetDisplayNames = Type.GetType("UnityEditor.DisplayUtility,UnityEditor") |
|||
.GetMethod("GetDisplayNames"); |
|||
static GUIContent[] DisplayUtility_GetDisplayNames() |
|||
{ |
|||
return (GUIContent[])k_DisplayUtility_GetDisplayNames.Invoke(null, null); |
|||
} |
|||
|
|||
static MethodInfo k_ModuleManager_ShouldShowMultiDisplayOption = Type.GetType("UnityEditor.Modules.ModuleManager,UnityEditor") |
|||
.GetMethod("ShouldShowMultiDisplayOption", BindingFlags.Static | BindingFlags.NonPublic); |
|||
static bool ModuleManager_ShouldShowMultiDisplayOption() |
|||
{ |
|||
return (bool)k_ModuleManager_ShouldShowMultiDisplayOption.Invoke(null, null); |
|||
} |
|||
|
|||
static readonly MethodInfo k_Camera_GetCameraBufferWarnings = typeof(Camera).GetMethod("GetCameraBufferWarnings", BindingFlags.Instance | BindingFlags.NonPublic); |
|||
static string[] GetCameraBufferWarnings(Camera camera) |
|||
{ |
|||
return (string[])k_Camera_GetCameraBufferWarnings.Invoke(camera, null); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8387cedc79c31c64399b2dd76cca7a80 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Reflection; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering.PostProcessing; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
using _ = CoreEditorUtils; |
|||
|
|||
partial class HDCameraEditor |
|||
{ |
|||
void OnSceneGUI() |
|||
{ |
|||
var c = (Camera)target; |
|||
|
|||
if (!CameraEditorUtils.IsViewPortRectValidToRender(c.rect)) |
|||
return; |
|||
|
|||
SceneViewOverlay_Window(_.GetContent("Camera Preview"), OnOverlayGUI, -100, target); |
|||
|
|||
CameraEditorUtils.HandleFrustrum(c); |
|||
} |
|||
|
|||
void OnOverlayGUI(Object target, SceneView sceneView) |
|||
{ |
|||
CameraEditorUtils.DrawCameraSceneViewOverlay(target, sceneView, InitializePreviewCamera); |
|||
} |
|||
|
|||
Camera InitializePreviewCamera(Camera c, Vector2 previewSize) |
|||
{ |
|||
m_PreviewCamera.CopyFrom(c); |
|||
EditorUtility.CopySerialized(c, m_PreviewCamera); |
|||
EditorUtility.CopySerialized(c.GetComponent<HDAdditionalCameraData>(), m_PreviewAdditionalCameraData); |
|||
var layer = c.GetComponent<PostProcessLayer>() ?? Assets.ScriptableRenderLoop.PostProcessing.PostProcessing.Runtime.Utils.ComponentSingleton<PostProcessLayer>.instance; |
|||
EditorUtility.CopySerialized(layer, m_PreviewPostProcessLayer); |
|||
m_PreviewCamera.cameraType = CameraType.SceneView; |
|||
m_PreviewHDCamera.Update(m_PreviewPostProcessLayer, m_PreviewAdditionalCameraData.GetFrameSettings()); |
|||
|
|||
var previewTexture = GetPreviewTextureWithSize((int)previewSize.x, (int)previewSize.y); |
|||
m_PreviewCamera.targetTexture = previewTexture; |
|||
m_PreviewCamera.pixelRect = new Rect(0, 0, previewSize.x, previewSize.y); |
|||
|
|||
return m_PreviewCamera; |
|||
} |
|||
|
|||
static Type k_SceneViewOverlay_WindowFunction = Type.GetType("UnityEditor.SceneViewOverlay+WindowFunction,UnityEditor"); |
|||
static Type k_SceneViewOverlay_WindowDisplayOption = Type.GetType("UnityEditor.SceneViewOverlay+WindowDisplayOption,UnityEditor"); |
|||
static MethodInfo k_SceneViewOverlay_Window = Type.GetType("UnityEditor.SceneViewOverlay,UnityEditor") |
|||
.GetMethod( |
|||
"Window", |
|||
BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public, |
|||
null, |
|||
CallingConventions.Any, |
|||
new[] { typeof(GUIContent), k_SceneViewOverlay_WindowFunction, typeof(int), typeof(Object), k_SceneViewOverlay_WindowDisplayOption }, |
|||
null); |
|||
static void SceneViewOverlay_Window(GUIContent title, Action<Object, SceneView> sceneViewFunc, int order, Object target) |
|||
{ |
|||
k_SceneViewOverlay_Window.Invoke(null, new[] |
|||
{ |
|||
title, DelegateUtility.Cast(sceneViewFunc, k_SceneViewOverlay_WindowFunction), |
|||
order, |
|||
target, |
|||
Enum.ToObject(k_SceneViewOverlay_WindowDisplayOption, 1) |
|||
}); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
using UnityEngine.Rendering.PostProcessing; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
[CustomEditorForRenderPipeline(typeof(Camera), typeof(HDRenderPipelineAsset))] |
|||
[CanEditMultipleObjects] |
|||
partial class HDCameraEditor : Editor |
|||
{ |
|||
SerializedHDCamera m_SerializedCamera; |
|||
HDCameraUI m_UIState = new HDCameraUI(); |
|||
|
|||
RenderTexture m_PreviewTexture; |
|||
Camera m_PreviewCamera; |
|||
HDAdditionalCameraData m_PreviewAdditionalCameraData; |
|||
PostProcessLayer m_PreviewPostProcessLayer; |
|||
HDCamera m_PreviewHDCamera; |
|||
|
|||
void OnEnable() |
|||
{ |
|||
m_SerializedCamera = new SerializedHDCamera(serializedObject); |
|||
m_UIState.Reset(m_SerializedCamera, Repaint); |
|||
|
|||
m_PreviewCamera = EditorUtility.CreateGameObjectWithHideFlags("Preview Camera", HideFlags.HideAndDontSave, typeof(Camera)).GetComponent<Camera>(); |
|||
m_PreviewAdditionalCameraData = m_PreviewCamera.gameObject.AddComponent<HDAdditionalCameraData>(); |
|||
m_PreviewPostProcessLayer = m_PreviewCamera.gameObject.AddComponent<PostProcessLayer>(); |
|||
m_PreviewCamera.enabled = false; |
|||
m_PreviewHDCamera = new HDCamera(m_PreviewCamera); |
|||
m_PreviewHDCamera.Update(m_PreviewPostProcessLayer, m_PreviewAdditionalCameraData.GetFrameSettings()); |
|||
} |
|||
|
|||
void OnDisable() |
|||
{ |
|||
if (m_PreviewTexture != null) |
|||
{ |
|||
m_PreviewTexture.Release(); |
|||
m_PreviewTexture = null; |
|||
} |
|||
DestroyImmediate(m_PreviewCamera.gameObject); |
|||
m_PreviewCamera = null; |
|||
} |
|||
|
|||
public override void OnInspectorGUI() |
|||
{ |
|||
var s = m_UIState; |
|||
var d = m_SerializedCamera; |
|||
|
|||
d.Update(); |
|||
s.Update(); |
|||
|
|||
HDCameraUI.Inspector.Draw(s, d, this); |
|||
|
|||
d.Apply(); |
|||
} |
|||
|
|||
RenderTexture GetPreviewTextureWithSize(int width, int height) |
|||
{ |
|||
if (m_PreviewTexture == null || m_PreviewTexture.width != width || m_PreviewTexture.height != height) |
|||
{ |
|||
if (m_PreviewTexture != null) |
|||
m_PreviewTexture.Release(); |
|||
|
|||
var baseDesc = m_PreviewHDCamera.renderTextureDesc; |
|||
baseDesc.width = width; |
|||
baseDesc.height = height; |
|||
CoreUtils.UpdateRenderTextureDescriptor(ref baseDesc, 0, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear, 1, true); |
|||
m_PreviewTexture = new RenderTexture(baseDesc); |
|||
} |
|||
return m_PreviewTexture; |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
class SerializedFrameSettings |
|||
{ |
|||
public SerializedProperty root; |
|||
|
|||
public SerializedProperty enableShadow; |
|||
public SerializedProperty enableSSR; |
|||
public SerializedProperty enableSSAO; |
|||
public SerializedProperty enableSSSAndTransmission; |
|||
|
|||
public SerializedProperty diffuseGlobalDimmer; |
|||
public SerializedProperty specularGlobalDimmer; |
|||
|
|||
public SerializedProperty enableForwardRenderingOnly; |
|||
public SerializedProperty enableDepthPrepassWithDeferredRendering; |
|||
public SerializedProperty enableAlphaTestOnlyInDeferredPrepass; |
|||
|
|||
public SerializedProperty enableTransparentPrepass; |
|||
public SerializedProperty enableMotionVectors; |
|||
public SerializedProperty enableObjectMotionVectors; |
|||
public SerializedProperty enableDBuffer; |
|||
public SerializedProperty enableAtmosphericScattering; |
|||
public SerializedProperty enableRoughRefraction; |
|||
public SerializedProperty enableTransparentPostpass; |
|||
public SerializedProperty enableDistortion; |
|||
public SerializedProperty enablePostprocess; |
|||
|
|||
public SerializedProperty enableStereo; |
|||
public SerializedProperty enableAsyncCompute; |
|||
|
|||
public SerializedProperty enableOpaqueObjects; |
|||
public SerializedProperty enableTransparentObjects; |
|||
|
|||
public SerializedProperty enableMSAA; |
|||
|
|||
public SerializedProperty enableShadowMask; |
|||
|
|||
public SerializedLightLoopSettings lightLoopSettings; |
|||
|
|||
|
|||
public SerializedFrameSettings(SerializedProperty root) |
|||
{ |
|||
this.root = root; |
|||
|
|||
enableShadow = root.Find((FrameSettings d) => d.enableShadow); |
|||
enableSSR = root.Find((FrameSettings d) => d.enableSSR); |
|||
enableSSAO = root.Find((FrameSettings d) => d.enableSSAO); |
|||
enableSSSAndTransmission = root.Find((FrameSettings d) => d.enableSSSAndTransmission); |
|||
diffuseGlobalDimmer = root.Find((FrameSettings d) => d.diffuseGlobalDimmer); |
|||
specularGlobalDimmer = root.Find((FrameSettings d) => d.specularGlobalDimmer); |
|||
enableForwardRenderingOnly = root.Find((FrameSettings d) => d.enableForwardRenderingOnly); |
|||
enableDepthPrepassWithDeferredRendering = root.Find((FrameSettings d) => d.enableDepthPrepassWithDeferredRendering); |
|||
enableAlphaTestOnlyInDeferredPrepass = root.Find((FrameSettings d) => d.enableAlphaTestOnlyInDeferredPrepass); |
|||
enableTransparentPrepass = root.Find((FrameSettings d) => d.enableTransparentPrepass); |
|||
enableMotionVectors = root.Find((FrameSettings d) => d.enableMotionVectors); |
|||
enableObjectMotionVectors = root.Find((FrameSettings d) => d.enableObjectMotionVectors); |
|||
enableDBuffer = root.Find((FrameSettings d) => d.enableDBuffer); |
|||
enableAtmosphericScattering = root.Find((FrameSettings d) => d.enableAtmosphericScattering); |
|||
enableRoughRefraction = root.Find((FrameSettings d) => d.enableRoughRefraction); |
|||
enableTransparentPostpass = root.Find((FrameSettings d) => d.enableTransparentPostpass); |
|||
enableDistortion = root.Find((FrameSettings d) => d.enableDistortion); |
|||
enablePostprocess = root.Find((FrameSettings d) => d.enablePostprocess); |
|||
enableStereo = root.Find((FrameSettings d) => d.enableStereo); |
|||
enableAsyncCompute = root.Find((FrameSettings d) => d.enableAsyncCompute); |
|||
enableOpaqueObjects = root.Find((FrameSettings d) => d.enableOpaqueObjects); |
|||
enableTransparentObjects = root.Find((FrameSettings d) => d.enableTransparentObjects); |
|||
enableMSAA = root.Find((FrameSettings d) => d.enableMSAA); |
|||
enableShadowMask = root.Find((FrameSettings d) => d.enableShadowMask); |
|||
|
|||
lightLoopSettings = new SerializedLightLoopSettings(root.Find((FrameSettings d) => d.lightLoopSettings)); |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
class SerializedLightLoopSettings |
|||
{ |
|||
public SerializedProperty root; |
|||
|
|||
public SerializedProperty enableTileAndCluster; |
|||
public SerializedProperty enableComputeLightEvaluation; |
|||
public SerializedProperty enableComputeLightVariants; |
|||
public SerializedProperty enableComputeMaterialVariants; |
|||
public SerializedProperty enableFptlForForwardOpaque; |
|||
public SerializedProperty enableBigTilePrepass; |
|||
public SerializedProperty isFptlEnabled; |
|||
|
|||
public SerializedLightLoopSettings(SerializedProperty root) |
|||
{ |
|||
this.root = root; |
|||
|
|||
enableTileAndCluster = root.Find((LightLoopSettings l) => l.enableTileAndCluster); |
|||
enableComputeLightEvaluation = root.Find((LightLoopSettings l) => l.enableComputeLightEvaluation); |
|||
enableComputeLightVariants = root.Find((LightLoopSettings l) => l.enableComputeLightVariants); |
|||
enableComputeMaterialVariants = root.Find((LightLoopSettings l) => l.enableComputeMaterialVariants); |
|||
enableFptlForForwardOpaque = root.Find((LightLoopSettings l) => l.enableFptlForForwardOpaque); |
|||
enableBigTilePrepass = root.Find((LightLoopSettings l) => l.enableBigTilePrepass); |
|||
isFptlEnabled = root.Find((LightLoopSettings l) => l.isFptlEnabled); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ec542dbaaa88b6d4b9a90540fc168fb5 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8cdd8583a8ae931479505ea608afe6de |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEngine.Events; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
using _ = CoreEditorUtils; |
|||
using CED = CoreEditorDrawer<FrameSettingsUI, SerializedFrameSettings>; |
|||
|
|||
class FrameSettingsUI : BaseUI<SerializedFrameSettings> |
|||
{ |
|||
public static CED.IDrawer SectionRenderingPasses = CED.FoldoutGroup( |
|||
"Rendering Passes", |
|||
(s, p, o) => s.isSectionExpandedRenderingPasses, |
|||
true, |
|||
CED.Action(Drawer_SectionRenderingPasses)); |
|||
|
|||
public static CED.IDrawer SectionRenderingSettings = CED.FoldoutGroup( |
|||
"Rendering Settings", |
|||
(s, p, o) => s.isSectionExpandedRenderingSettings, |
|||
true, |
|||
CED.Action(Drawer_FieldForwardRenderingOnly), |
|||
CED.FadeGroup( |
|||
(s, d, o, i) => s.isSectionExpandedUseForwardOnly, |
|||
false, |
|||
CED.Action(Drawer_FieldUseDepthPrepassWithDefferedRendering), |
|||
CED.FadeGroup( |
|||
(s, d, o, i) => s.isSectionExpandedUseDepthPrepass, |
|||
true, |
|||
CED.Action(Drawer_FieldRenderAlphaTestOnlyInDeferredPrepass))), |
|||
CED.Action(Drawer_SectionOtherRenderingSettings)); |
|||
|
|||
public static CED.IDrawer SectionXRSettings = CED.FadeGroup( |
|||
(s, d, o, i) => s.isSectionExpandedXRSupported, |
|||
false, |
|||
CED.FoldoutGroup( |
|||
"XR Settings", |
|||
(s, p, o) => s.isSectionExpandedXRSettings, |
|||
true, |
|||
CED.Action(Drawer_FieldStereoEnabled))); |
|||
|
|||
public static CED.IDrawer SectionLightingSettings = CED.FoldoutGroup( |
|||
"Lighting Settings", |
|||
(s, p, o) => s.isSectionExpandedLightingSettings, |
|||
true, |
|||
CED.Action(Drawer_SectionLightingSettings)); |
|||
|
|||
public AnimBool isSectionExpandedRenderingPasses { get { return m_AnimBools[0]; } } |
|||
public AnimBool isSectionExpandedLightingSettings { get { return m_AnimBools[1]; } } |
|||
public AnimBool isSectionExpandedRenderingSettings { get { return m_AnimBools[2]; } } |
|||
public AnimBool isSectionExpandedXRSettings { get { return m_AnimBools[3]; } } |
|||
public AnimBool isSectionExpandedXRSupported { get { return m_AnimBools[4]; } } |
|||
public AnimBool isSectionExpandedUseForwardOnly { get { return m_AnimBools[5]; } } |
|||
public AnimBool isSectionExpandedUseDepthPrepass { get { return m_AnimBools[6]; } } |
|||
|
|||
public LightLoopSettingsUI lightLoopSettingsUI = new LightLoopSettingsUI(); |
|||
|
|||
public FrameSettingsUI() |
|||
: base(7) |
|||
{ |
|||
} |
|||
|
|||
public override void Reset(SerializedFrameSettings data, UnityAction repaint) |
|||
{ |
|||
lightLoopSettingsUI.Reset(data.lightLoopSettings, repaint); |
|||
base.Reset(data, repaint); |
|||
} |
|||
|
|||
public override void Update() |
|||
{ |
|||
isSectionExpandedXRSupported.target = PlayerSettings.virtualRealitySupported; |
|||
isSectionExpandedUseForwardOnly.target = !data.enableForwardRenderingOnly.boolValue; |
|||
isSectionExpandedUseDepthPrepass.target = data.enableDepthPrepassWithDeferredRendering.boolValue; |
|||
lightLoopSettingsUI.Update(); |
|||
} |
|||
|
|||
static void Drawer_SectionRenderingPasses(FrameSettingsUI s, SerializedFrameSettings p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.enableTransparentPrepass, _.GetContent("Enable Transparent Prepass")); |
|||
EditorGUILayout.PropertyField(p.enableTransparentPostpass, _.GetContent("Enable Transparent Postpass")); |
|||
EditorGUILayout.PropertyField(p.enableMotionVectors, _.GetContent("Enable Motion Vectors")); |
|||
EditorGUILayout.PropertyField(p.enableObjectMotionVectors, _.GetContent("Enable Object Motion Vectors")); |
|||
EditorGUILayout.PropertyField(p.enableDBuffer, _.GetContent("Enable DBuffer")); |
|||
EditorGUILayout.PropertyField(p.enableAtmosphericScattering, _.GetContent("Enable Atmospheric Scattering")); |
|||
EditorGUILayout.PropertyField(p.enableRoughRefraction, _.GetContent("Enable Rough Refraction")); |
|||
EditorGUILayout.PropertyField(p.enableDistortion, _.GetContent("Enable Distortion")); |
|||
EditorGUILayout.PropertyField(p.enablePostprocess, _.GetContent("Enable Postprocess")); |
|||
} |
|||
|
|||
static void Drawer_SectionRenderingSettings(FrameSettingsUI s, SerializedFrameSettings p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.enableForwardRenderingOnly, _.GetContent("Enable Forward Rendering Only")); |
|||
EditorGUILayout.PropertyField(p.enableDepthPrepassWithDeferredRendering, _.GetContent("Enable Depth Prepass With Deferred Rendering")); |
|||
EditorGUILayout.PropertyField(p.enableAlphaTestOnlyInDeferredPrepass, _.GetContent("Enable Alpha Test Only In Deferred Prepass")); |
|||
|
|||
EditorGUILayout.PropertyField(p.enableAsyncCompute, _.GetContent("Enable Async Compute")); |
|||
|
|||
EditorGUILayout.PropertyField(p.enableOpaqueObjects, _.GetContent("Enable Opaque Objects")); |
|||
EditorGUILayout.PropertyField(p.enableTransparentObjects, _.GetContent("Enable Transparent Objects")); |
|||
|
|||
EditorGUILayout.PropertyField(p.enableMSAA, _.GetContent("Enable MSAA")); |
|||
} |
|||
|
|||
static void Drawer_FieldForwardRenderingOnly(FrameSettingsUI s, SerializedFrameSettings p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.enableForwardRenderingOnly, _.GetContent("Enable Forward Rendering Only")); |
|||
} |
|||
|
|||
static void Drawer_FieldUseDepthPrepassWithDefferedRendering(FrameSettingsUI s, SerializedFrameSettings p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.enableDepthPrepassWithDeferredRendering, _.GetContent("Enable Depth Prepass With Deferred Rendering")); |
|||
} |
|||
|
|||
static void Drawer_FieldRenderAlphaTestOnlyInDeferredPrepass(FrameSettingsUI s, SerializedFrameSettings p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.enableAlphaTestOnlyInDeferredPrepass, _.GetContent("Enable Alpha Test Only In Deferred Prepass")); |
|||
} |
|||
|
|||
static void Drawer_SectionOtherRenderingSettings(FrameSettingsUI s, SerializedFrameSettings p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.enableAsyncCompute, _.GetContent("Enable Async Compute")); |
|||
|
|||
EditorGUILayout.PropertyField(p.enableOpaqueObjects, _.GetContent("Enable Opaque Objects")); |
|||
EditorGUILayout.PropertyField(p.enableTransparentObjects, _.GetContent("Enable Transparent Objects")); |
|||
|
|||
EditorGUILayout.PropertyField(p.enableMSAA, _.GetContent("Enable MSAA")); |
|||
} |
|||
|
|||
static void Drawer_FieldStereoEnabled(FrameSettingsUI s, SerializedFrameSettings p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.enableStereo, _.GetContent("Enable Stereo")); |
|||
} |
|||
|
|||
static void Drawer_SectionLightingSettings(FrameSettingsUI s, SerializedFrameSettings p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.enableSSR, _.GetContent("Enable SSR")); |
|||
EditorGUILayout.PropertyField(p.enableSSAO, _.GetContent("Enable SSAO")); |
|||
EditorGUILayout.PropertyField(p.enableSSSAndTransmission, _.GetContent("Enable SSS And Transmission")); |
|||
EditorGUILayout.PropertyField(p.enableShadow, _.GetContent("Enable Shadow")); |
|||
EditorGUILayout.PropertyField(p.enableShadowMask, _.GetContent("Enable Shadow Masks")); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 283afa8b170709446893205550b2980f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEditor.AnimatedValues; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
using _ = CoreEditorUtils; |
|||
using CED = CoreEditorDrawer<LightLoopSettingsUI, SerializedLightLoopSettings>; |
|||
|
|||
class LightLoopSettingsUI : BaseUI<SerializedLightLoopSettings> |
|||
{ |
|||
public static CED.IDrawer SectionLightLoopSettings = CED.FoldoutGroup( |
|||
"Light Loop Settings", |
|||
(s, p, o) => s.isSectionExpandedLightLoopSettings, |
|||
true, |
|||
CED.Action(Drawer_SectionLightLoopSettings)); |
|||
|
|||
public AnimBool isSectionExpandedLightLoopSettings { get { return m_AnimBools[0]; } } |
|||
public AnimBool isSectionExpandedEnableTileAndCluster { get { return m_AnimBools[1]; } } |
|||
public AnimBool isSectionExpandedComputeLightEvaluation { get { return m_AnimBools[2]; } } |
|||
|
|||
public LightLoopSettingsUI() |
|||
: base(3) |
|||
{ |
|||
} |
|||
|
|||
public override void Update() |
|||
{ |
|||
isSectionExpandedEnableTileAndCluster.target = data.enableTileAndCluster.boolValue; |
|||
isSectionExpandedComputeLightEvaluation.target = data.enableComputeLightEvaluation.boolValue; |
|||
base.Update(); |
|||
} |
|||
|
|||
static void Drawer_SectionLightLoopSettings(LightLoopSettingsUI s, SerializedLightLoopSettings p, Editor owner) |
|||
{ |
|||
EditorGUILayout.PropertyField(p.enableTileAndCluster, _.GetContent("Enable Tile And Cluster")); |
|||
GUILayout.BeginVertical(); |
|||
if (EditorGUILayout.BeginFadeGroup(s.isSectionExpandedEnableTileAndCluster.faded)) |
|||
{ |
|||
EditorGUI.indentLevel++; |
|||
EditorGUILayout.PropertyField(p.enableBigTilePrepass, _.GetContent("Enable Big Tile Prepass")); |
|||
// Allow to disable cluster for forward opaque when in forward only (option have no effect when MSAA is enabled)
|
|||
// Deferred opaque are always tiled
|
|||
EditorGUILayout.PropertyField(p.enableFptlForForwardOpaque, _.GetContent("Enable FPTL For Forward Opaque")); |
|||
EditorGUILayout.PropertyField(p.enableComputeLightEvaluation, _.GetContent("Enable Compute Light Evaluation")); |
|||
GUILayout.BeginVertical(); |
|||
if (EditorGUILayout.BeginFadeGroup(s.isSectionExpandedComputeLightEvaluation.faded)) |
|||
{ |
|||
EditorGUI.indentLevel++; |
|||
EditorGUILayout.PropertyField(p.enableComputeLightVariants, _.GetContent("Enable Compute Light Variants")); |
|||
EditorGUILayout.PropertyField(p.enableComputeMaterialVariants, _.GetContent("Enable Compute Material Variants")); |
|||
EditorGUI.indentLevel--; |
|||
} |
|||
EditorGUILayout.EndFadeGroup(); |
|||
GUILayout.EndVertical(); |
|||
EditorGUI.indentLevel--; |
|||
} |
|||
EditorGUILayout.EndFadeGroup(); |
|||
GUILayout.EndVertical(); |
|||
|
|||
EditorGUILayout.PropertyField(p.isFptlEnabled, _.GetContent("Enable FPTL")); |
|||
EditorGUILayout.PropertyField(p.enableFptlForForwardOpaque, _.GetContent("Enable FPTL For Forward Opaque")); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2217e0c644f08a649b62591c43a0ff35 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
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_ModeSettingsDisplays = new AnimBool[Enum.GetValues(typeof(ReflectionProbeMode)).Length]; |
|||
AnimBool[] m_InfluenceShapeDisplays = new AnimBool[Enum.GetValues(typeof(ReflectionInfluenceShape)).Length]; |
|||
|
|||
Editor owner { get; set; } |
|||
Operation operations { get; set; } |
|||
public AnimBool useSeparateProjectionVolumeDisplay { get; private 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 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_ModeSettingsDisplays.Length; i++) |
|||
m_ModeSettingsDisplays[i] = new AnimBool(); |
|||
for (var i = 0; i < m_InfluenceShapeDisplays.Length; i++) |
|||
m_InfluenceShapeDisplays[i] = new AnimBool(); |
|||
useSeparateProjectionVolumeDisplay = new AnimBool(); |
|||
} |
|||
|
|||
internal void Reset( |
|||
Editor owner, |
|||
UnityAction repaint, |
|||
SerializedReflectionProbe p) |
|||
{ |
|||
this.owner = owner; |
|||
operations = 0; |
|||
|
|||
for (var i = 0; i < m_ModeSettingsDisplays.Length; i++) |
|||
{ |
|||
m_ModeSettingsDisplays[i].valueChanged.RemoveAllListeners(); |
|||
m_ModeSettingsDisplays[i].valueChanged.AddListener(repaint); |
|||
m_ModeSettingsDisplays[i].value = p.mode.intValue == i; |
|||
} |
|||
|
|||
for (var i = 0; i < m_InfluenceShapeDisplays.Length; i++) |
|||
{ |
|||
m_InfluenceShapeDisplays[i].valueChanged.RemoveAllListeners(); |
|||
m_InfluenceShapeDisplays[i].valueChanged.AddListener(repaint); |
|||
m_InfluenceShapeDisplays[i].value = p.influenceShape.intValue == i; |
|||
} |
|||
|
|||
useSeparateProjectionVolumeDisplay.valueChanged.RemoveAllListeners(); |
|||
useSeparateProjectionVolumeDisplay.valueChanged.AddListener(repaint); |
|||
useSeparateProjectionVolumeDisplay.value = p.useSeparateProjectionVolume.boolValue; |
|||
} |
|||
|
|||
public float GetModeFaded(ReflectionProbeMode mode) |
|||
{ |
|||
return m_ModeSettingsDisplays[(int)mode].faded; |
|||
} |
|||
|
|||
public void SetModeTarget(int value) |
|||
{ |
|||
for (var i = 0; i < m_ModeSettingsDisplays.Length; i++) |
|||
m_ModeSettingsDisplays[i].target = i == value; |
|||
} |
|||
|
|||
public float GetShapeFaded(ReflectionInfluenceShape value) |
|||
{ |
|||
return m_InfluenceShapeDisplays[(int)value].faded; |
|||
} |
|||
|
|||
public void SetShapeTarget(int value) |
|||
{ |
|||
for (var i = 0; i < m_InfluenceShapeDisplays.Length; i++) |
|||
m_InfluenceShapeDisplays[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.GetModeFaded((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) => p.blendDistancePositive, |
|||
true, |
|||
CED.FadeGroup( |
|||
(s, p, o, i) => s.GetShapeFaded((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.useSeparateProjectionVolumeDisplay.faded, |
|||
false, |
|||
CED.FoldoutGroup( |
|||
"Reprojection volume settings", |
|||
(s, p, o) => p.useSeparateProjectionVolume, |
|||
true, |
|||
CED.FadeGroup( |
|||
(s, p, o, i) => s.GetShapeFaded((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) => p.shadowDistance, |
|||
true, |
|||
CED.Action(Drawer_CaptureSettings) |
|||
); |
|||
|
|||
static readonly CED.IDrawer k_AdditionalSection = CED.FoldoutGroup( |
|||
"Additional settings", |
|||
(s, p, o) => p.dimmer, |
|||
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.useSeparateProjectionVolumeDisplay.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