Esempio n. 1
0
        void LightmapRow(int index, LightmapData[] lightmaps, bool showDirLightmap, bool showShadowMask, GlobalMapsViewType viewType)
        {
            int   statsLineCount    = (viewType == GlobalMapsViewType.Performance) ? 5 : 7;
            float lightmapFieldSize =
                2 * EditorStyles.miniLabel.margin.top +
                (statsLineCount - 1) * Mathf.Max(EditorStyles.miniLabel.margin.top, EditorStyles.miniLabel.margin.bottom) +
                2 * EditorStyles.miniLabel.padding.top +
                (statsLineCount - 1) * EditorStyles.miniLabel.padding.vertical +
                (statsLineCount - 1) * EditorStyles.miniLabel.lineHeight +
                EditorStyles.miniLabel.font.fontSize;

            GUILayout.Space(5);

            GUILayout.BeginHorizontal();

            GUILayout.Space(20);
            lightmaps[index].lightmapColor = LightmapField(lightmaps[index].lightmapColor, index, lightmapFieldSize);

            if (showDirLightmap)
            {
                GUILayout.Space(5);
                lightmaps[index].lightmapDir = LightmapField(lightmaps[index].lightmapDir, index, lightmapFieldSize);
            }

            if (showShadowMask)
            {
                GUILayout.Space(5);
                lightmaps[index].shadowMask = LightmapField(lightmaps[index].shadowMask, index, lightmapFieldSize);
            }

            GUILayout.Space(5);
            if (viewType == GlobalMapsViewType.Performance)
            {
                LightmapPerformanceStats(index);
            }
            else
            {
                LightmapMemoryStats(index);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
Esempio n. 2
0
        void MemoryCentricView(LightmapData[] lightmaps, bool showDirLightmap, bool showShadowMask, GlobalMapsViewType viewType)
        {
            Lightmapping.ResetExplicitlyShownMemLabels();

            Dictionary <Hash128, SortedList <int, int> > gbufferHashToLightmapIndices = new Dictionary <Hash128, SortedList <int, int> >();

            for (int i = 0; i < lightmaps.Length; i++)
            {
                Hash128 gbufferHash;
                if (Lightmapping.GetGBufferHash(i, out gbufferHash))
                {
                    if (!gbufferHashToLightmapIndices.ContainsKey(gbufferHash))
                    {
                        gbufferHashToLightmapIndices.Add(gbufferHash, new SortedList <int, int>());
                    }

                    gbufferHashToLightmapIndices[gbufferHash].Add(i, i);
                }
            }

            float totalGBuffersSize  = 0.0f;
            float totalLightmapsSize = 0.0f;

            foreach (var entry in gbufferHashToLightmapIndices)
            {
                Hash128 gbufferHash     = entry.Key;
                float   gbufferDataSize = Lightmapping.GetGBufferMemory(ref gbufferHash);
                totalGBuffersSize += gbufferDataSize;

                SortedList <int, int> lightmapIndices = entry.Value;
                foreach (var i in lightmapIndices)
                {
                    LightmapMemory lightmapMemory = Lightmapping.GetLightmapMemory(i.Value);
                    totalLightmapsSize += lightmapMemory.lightmapDataSize;
                    totalLightmapsSize += lightmapMemory.lightmapTexturesSize;
                }
            }

            if (gbufferHashToLightmapIndices.Count > 0)
            {
                const bool toggleOnLabelClick = true;
                string     foldoutNameFull    = String.Format(
                    "G-buffers ({0}) | Lightmaps ({1})",
                    SizeString(totalGBuffersSize),
                    SizeString(totalLightmapsSize));
                bool showDetailsOld = EditorPrefs.GetBool(kEditorPrefsGBuffersLightmapsAlbedoEmissive, true);

                bool showDetails = EditorGUILayout.Foldout(showDetailsOld, foldoutNameFull, toggleOnLabelClick, s_Styles.boldFoldout);

                if (showDetails != showDetailsOld)
                {
                    EditorPrefs.SetBool(kEditorPrefsGBuffersLightmapsAlbedoEmissive, showDetails);
                }

                if (showDetails)
                {
                    foreach (var entry in gbufferHashToLightmapIndices)
                    {
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Space(15);
                            GUILayout.BeginVertical();
                            {
                                Hash128 gbufferHash     = entry.Key;
                                float   gbufferDataSize = Lightmapping.GetGBufferMemory(ref gbufferHash);
                                GUILayout.Label(EditorGUIUtility.TrTextContent("G-buffer: " + gbufferDataSize.ToString("0.0") + " MB", gbufferHash.ToString()), EditorStyles.miniLabel, GUILayout.ExpandWidth(false));

                                SortedList <int, int> lightmapIndices = entry.Value;
                                foreach (var i in lightmapIndices)
                                {
                                    LightmapRow(i.Value, lightmaps, showDirLightmap, showShadowMask, viewType);
                                }
                            }
                            GUILayout.EndVertical();
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.Space(10);
                    }
                }
            }

            System.UInt64[] dummyCounts = new System.UInt64[0];
            {
                MemLabels labels = Lightmapping.GetTransmissionTexturesMemLabels();
                ShowObjectNamesSizesAndCounts("Transmission textures", kEditorPrefsTransmissionTextures, labels.labels, labels.sizes, dummyCounts, Precision.Tenths);
            }

            {
                MemLabels labels = Lightmapping.GetMaterialTexturesMemLabels();
                ShowObjectNamesSizesAndCounts("Albedo/emissive textures", kEditorPrefsMaterialTextures, labels.labels, labels.sizes, dummyCounts, Precision.Hundredths);
            }

            {
                string[]        objectNames;
                float[]         sizes;
                System.UInt64[] triCounts;
                Lightmapping.GetGeometryMemory(out objectNames, out sizes, out triCounts);
                ShowObjectNamesSizesAndCounts("Geometry data", kEditorPrefsGeometryData, objectNames, sizes, triCounts, Precision.Hundredths);
            }

            {
                MemLabels labels = Lightmapping.GetNotShownMemLabels();
                string    remainingEntriesFoldoutName = Lightmapping.isProgressiveLightmapperDone ? "Leaks" : "In-flight";
                ShowObjectNamesSizesAndCounts(remainingEntriesFoldoutName, kEditorPrefsInFlight, labels.labels, labels.sizes, dummyCounts, Precision.Tenths);
            }
        }
Esempio n. 3
0
 void PerformanceCentricView(LightmapData[] lightmaps, bool showDirLightmap, bool showShadowMask, GlobalMapsViewType viewType)
 {
     for (int i = 0; i < lightmaps.Length; i++)
     {
         LightmapRow(i, lightmaps, showDirLightmap, showShadowMask, viewType);
     }
 }
Esempio n. 4
0
        public void Maps()
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            GUI.changed = false;

            if (Lightmapping.giWorkflowMode == Lightmapping.GIWorkflowMode.OnDemand)
            {
                SerializedObject   so = new SerializedObject(LightmapEditorSettings.GetLightmapSettings());
                SerializedProperty LightingDataAsset = so.FindProperty("m_LightingDataAsset");
                EditorGUILayout.PropertyField(LightingDataAsset, s_Styles.LightingDataAsset);
                so.ApplyModifiedProperties();
            }

            GUILayout.Space(10);

            GlobalMapsViewType viewType = GlobalMapsViewType.Performance;

            if (EditorPrefs.GetBool("DeveloperMode", false))
            {
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                viewType = (GlobalMapsViewType)EditorPrefs.GetInt("LightingWindowGlobalMapsViewType", (int)viewType);

                EditorGUI.BeginChangeCheck();
                {
                    viewType = (GlobalMapsViewType)GUILayout.Toolbar((int)viewType, new string[] { "Performance", "Memory" }, EditorStyles.miniButton, GUILayout.ExpandWidth(false));
                }
                if (EditorGUI.EndChangeCheck())
                {
                    EditorPrefs.SetInt("LightingWindowGlobalMapsViewType", (int)viewType);
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }

            LightmapData[] lightmaps = LightmapSettings.lightmaps;

            m_ScrollPositionMaps = GUILayout.BeginScrollView(m_ScrollPositionMaps);
            {
                bool showDirLightmap = false;
                bool showShadowMask  = false;
                foreach (LightmapData lightmapData in lightmaps)
                {
                    if (lightmapData.lightmapDir != null)
                    {
                        showDirLightmap = true;
                    }
                    if (lightmapData.shadowMask != null)
                    {
                        showShadowMask = true;
                    }
                }

                if (viewType == GlobalMapsViewType.Performance)
                {
                    PerformanceCentricView(lightmaps, showDirLightmap, showShadowMask, viewType);
                }
                else
                {
                    MemoryCentricView(lightmaps, showDirLightmap, showShadowMask, viewType);
                }
            }
            GUILayout.EndScrollView();
        }