/// <summary> /// Displays a depth write warning and fix button if depth buffer sharing is enabled. /// </summary> /// <param name="materialEditor">The material editor to display the warning in.</param> /// <param name="dialogTitle">The title of the dialog window to display when the user selects the fix button.</param> /// <param name="dialogMessage">The message in the dialog window when the user selects the fix button.</param> /// <returns>True if the user opted to fix the warning, false otherwise.</returns> public static bool DisplayDepthWriteWarning(MaterialEditor materialEditor, string dialogTitle = "Depth Write", string dialogMessage = "Change this material to write to the depth buffer?") { bool dialogConfirmed = false; if (MixedRealityOptimizeUtils.IsDepthBufferSharingEnabled()) { var defaultValue = EditorStyles.helpBox.richText; EditorStyles.helpBox.richText = true; if (materialEditor.HelpBoxWithButton(Styles.DepthWriteWarning, Styles.DepthWriteFixNowButton)) { if (EditorUtility.DisplayDialog(dialogTitle, dialogMessage, "Yes", "No")) { dialogConfirmed = true; } } EditorStyles.helpBox.richText = defaultValue; } return dialogConfirmed; }
private void RenderSettingOptimizations() { GUILayout.BeginVertical("Box"); EditorGUILayout.LabelField(this.ToolbarTitles[(int)ToolbarSection.Settings], MixedRealityStylesUtility.BoldLargeTitleStyle); using (new EditorGUI.IndentLevelScope()) { bool isSinglePassInstancedEnabled = PlayerSettings.stereoRenderingPath == StereoRenderingPath.Instancing; BuildSection("Single Pass Instanced Rendering", SinglePassInstanced_URL, GetTitleIcon(isSinglePassInstancedEnabled), () => { EditorGUILayout.LabelField("Single Pass Instanced Rendering is an option in the Unity graphics pipeline to more efficiently render your scene and optimize CPU & GPU work."); EditorGUILayout.HelpBox("This rendering configuration requires shaders to be written to support GPU instancing which is automatic in all Unity & MRTK shaders.Click the \"Documentation\" button for instruction to update your custom shaders to support instancing.", MessageType.Info); using (new GUIEnabledWrapper(!isSinglePassInstancedEnabled)) { if (InspectorUIUtility.RenderIndentedButton("Enable Single Pass Instanced rendering")) { PlayerSettings.stereoRenderingPath = StereoRenderingPath.Instancing; } } }); // TODO: Put in Quality settings section bool isDepthBufferSharingEnabled = MixedRealityOptimizeUtils.IsDepthBufferSharingEnabled(); BuildSection("Depth Buffer Sharing", DepthBufferSharing_URL, GetTitleIcon(isDepthBufferSharingEnabled), () => { EditorGUILayout.LabelField("This option shares the application's depth buffer with the running platform which allows the platform to more accurately stabilize holograms and content.", EditorStyles.wordWrappedLabel); EditorGUILayout.HelpBox("Depth buffer sharing requires that a valid depth buffer is submitted to the platform. Click the \"Documentation\" button for instructions to ensure that transparent & text gameobjects write to depth.", MessageType.Info); using (new GUIEnabledWrapper(!isDepthBufferSharingEnabled)) { if (InspectorUIUtility.RenderIndentedButton("Enable Depth Buffer Sharing")) { MixedRealityOptimizeUtils.SetDepthBufferSharing(true); } } }); bool is16BitDepthFormat = MixedRealityOptimizeUtils.IsWMRDepthBufferFormat16bit(); BuildSection("Depth Buffer Format", DepthBufferFormat_URL, GetTitleIcon(is16BitDepthFormat), () => { EditorGUILayout.LabelField("If sharing the depth buffer with the underlying mixed reality platform, it is generally recommended to utilize a 16-bit depth format buffer to save on performance.", EditorStyles.wordWrappedLabel); EditorGUILayout.HelpBox("Although 16-bit depth format is better performing, it can result in z-fighting if the far clip plane is too far. Click the \"Documentation\" button to learn more", MessageType.Info); using (new GUIEnabledWrapper(!is16BitDepthFormat)) { if (InspectorUIUtility.RenderIndentedButton("Enable 16-bit depth format")) { MixedRealityOptimizeUtils.SetDepthBufferFormat(true); } } }); bool isGIEnabled = MixedRealityOptimizeUtils.IsRealtimeGlobalIlluminationEnabled(); BuildSection("Real-time Global Illumination", GlobalIllumination_URL, GetTitleIcon(!isGIEnabled), () => { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Real-time Global Illumination can produce great visual results but at great expense. It is recommended to disable this feature in lighting settings.", EditorStyles.wordWrappedLabel); if (GUILayout.Button(new GUIContent("View Lighting Settings", "Open Lighting Settings"), EditorStyles.miniButton, GUILayout.Width(160f))) { EditorApplication.ExecuteMenuItem("Window/Rendering/Lighting Settings"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.HelpBox("Note: Real-time Global Illumination is a per-scene setting.", MessageType.Info); using (new GUIEnabledWrapper(isGIEnabled)) { if (InspectorUIUtility.RenderIndentedButton("Disable Real-time Global Illumination")) { MixedRealityOptimizeUtils.SetRealtimeGlobalIlluminationEnabled(false); } } }); } GUILayout.EndVertical(); }