Esempio n. 1
0
        private void OptimizeProject()
        {
            if (singlePassInstanced)
            {
                PlayerSettings.stereoRenderingPath = StereoRenderingPath.Instancing;
            }

            if (enableDepthBufferSharing)
            {
                MixedRealityOptimizeUtils.SetDepthBufferSharing(enableDepthBufferSharing);
                // TODO: This value needs to be per-perf target
                //MixedRealityOptimizeUtils.SetDepthBufferFormat(enable16BitDepthBuffer);
            }
        }
Esempio n. 2
0
        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();
        }