Esempio n. 1
0
        void Summary()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox);

            long totalMemorySize            = 0;
            int  lightmapCount              = 0;
            Dictionary <Vector2, int> sizes = new Dictionary <Vector2, int>();
            bool directionalLightmapsMode   = false;
            bool shadowmaskMode             = false;

            foreach (LightmapData ld in LightmapSettings.lightmaps)
            {
                if (ld.lightmapColor == null)
                {
                    continue;
                }
                lightmapCount++;

                Vector2 texSize = new Vector2(ld.lightmapColor.width, ld.lightmapColor.height);
                if (sizes.ContainsKey(texSize))
                {
                    sizes[texSize]++;
                }
                else
                {
                    sizes.Add(texSize, 1);
                }

                totalMemorySize += TextureUtil.GetStorageMemorySizeLong(ld.lightmapColor);
                if (ld.lightmapDir)
                {
                    totalMemorySize         += TextureUtil.GetStorageMemorySizeLong(ld.lightmapDir);
                    directionalLightmapsMode = true;
                }
                if (ld.shadowMask)
                {
                    totalMemorySize += TextureUtil.GetStorageMemorySizeLong(ld.shadowMask);
                    shadowmaskMode   = true;
                }
            }
            StringBuilder sizesString = new StringBuilder();

            sizesString.Append(lightmapCount);
            sizesString.Append((directionalLightmapsMode ? " Directional" : " Non-Directional"));
            sizesString.Append(" Lightmap");
            if (lightmapCount != 1)
            {
                sizesString.Append("s");
            }
            if (shadowmaskMode)
            {
                sizesString.Append(" with Shadowmask");
                if (lightmapCount != 1)
                {
                    sizesString.Append("s");
                }
            }

            bool first = true;

            foreach (var s in sizes)
            {
                sizesString.Append(first ? ": " : ", ");
                first = false;
                if (s.Value > 1)
                {
                    sizesString.Append(s.Value);
                    sizesString.Append("x");
                }
                sizesString.Append(s.Key.x.ToString(CultureInfo.InvariantCulture.NumberFormat));
                sizesString.Append("x");
                sizesString.Append(s.Key.y.ToString(CultureInfo.InvariantCulture.NumberFormat));
                sizesString.Append("px");
            }
            sizesString.Append(" ");

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();
            GUILayout.Label(sizesString.ToString(), Styles.LabelStyle);
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            GUILayout.Label(EditorUtility.FormatBytes(totalMemorySize), Styles.LabelStyle);
            GUILayout.Label((lightmapCount == 0 ? "No Lightmaps" : ""), Styles.LabelStyle);
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            if (LightmapEditorSettings.lightmapper != LightmapEditorSettings.Lightmapper.Enlighten)
            {
                GUILayout.BeginVertical();
                GUILayout.Label("Occupied Texels: " + InternalEditorUtility.CountToString(Lightmapping.occupiedTexelCount), Styles.LabelStyle);
                if (Lightmapping.isRunning)
                {
                    int numLightmapsInView             = 0;
                    int numConvergedLightmapsInView    = 0;
                    int numNotConvergedLightmapsInView = 0;

                    int numLightmapsNotInView             = 0;
                    int numConvergedLightmapsNotInView    = 0;
                    int numNotConvergedLightmapsNotInView = 0;

                    int numLightmaps = LightmapSettings.lightmaps.Length;
                    for (int i = 0; i < numLightmaps; ++i)
                    {
                        LightmapConvergence lc = Lightmapping.GetLightmapConvergence(i);
                        if (!lc.IsValid())
                        {
                            continue;
                        }

                        if (Lightmapping.GetVisibleTexelCount(i) > 0)
                        {
                            numLightmapsInView++;
                            if (lc.IsConverged())
                            {
                                numConvergedLightmapsInView++;
                            }
                            else
                            {
                                numNotConvergedLightmapsInView++;
                            }
                        }
                        else
                        {
                            numLightmapsNotInView++;
                            if (lc.IsConverged())
                            {
                                numConvergedLightmapsNotInView++;
                            }
                            else
                            {
                                numNotConvergedLightmapsNotInView++;
                            }
                        }
                    }
                    if (Lightmapping.atlasCount > 0)
                    {
                        int convergedMaps = numConvergedLightmapsInView + numConvergedLightmapsNotInView;
                        GUILayout.Label("Lightmap convergence: (" + convergedMaps + "/" + Lightmapping.atlasCount + ")", Styles.LabelStyle);
                    }
                    EditorGUILayout.LabelField("Lightmaps in view: " + numLightmapsInView, Styles.LabelStyle);
                    EditorGUI.indentLevel += 1;
                    EditorGUILayout.LabelField("Converged: " + numConvergedLightmapsInView, Styles.LabelStyle);
                    EditorGUILayout.LabelField("Not Converged: " + numNotConvergedLightmapsInView, Styles.LabelStyle);
                    EditorGUI.indentLevel -= 1;
                    EditorGUILayout.LabelField("Lightmaps not in view: " + numLightmapsNotInView, Styles.LabelStyle);
                    EditorGUI.indentLevel += 1;
                    EditorGUILayout.LabelField("Converged: " + numConvergedLightmapsNotInView, Styles.LabelStyle);
                    EditorGUILayout.LabelField("Not Converged: " + numNotConvergedLightmapsNotInView, Styles.LabelStyle);
                    EditorGUI.indentLevel -= 1;

                    LightProbesConvergence lpc = Lightmapping.GetLightProbesConvergence();
                    if (lpc.IsValid() && lpc.probeSetCount > 0)
                    {
                        GUILayout.Label("Light Probes convergence: (" + lpc.convergedProbeSetCount + "/" + lpc.probeSetCount + ")", Styles.LabelStyle);
                    }
                }
                float bakeTime    = Lightmapping.GetLightmapBakeTimeTotal();
                float mraysPerSec = Lightmapping.GetLightmapBakePerformanceTotal();
                if (mraysPerSec >= 0.0)
                {
                    GUILayout.Label("Bake Performance: " + mraysPerSec.ToString("0.00", CultureInfo.InvariantCulture.NumberFormat) + " mrays/sec", Styles.LabelStyle);
                }
                if (!Lightmapping.isRunning)
                {
                    float bakeTimeRaw = Lightmapping.GetLightmapBakeTimeRaw();
                    if (bakeTime >= 0.0)
                    {
                        int time  = (int)bakeTime;
                        int timeH = time / 3600;
                        time -= 3600 * timeH;
                        int timeM = time / 60;
                        time -= 60 * timeM;
                        int timeS = time;

                        int timeRaw  = (int)bakeTimeRaw;
                        int timeRawH = timeRaw / 3600;
                        timeRaw -= 3600 * timeRawH;
                        int timeRawM = timeRaw / 60;
                        timeRaw -= 60 * timeRawM;
                        int timeRawS = timeRaw;

                        int oHeadTime  = Math.Max(0, (int)(bakeTime - bakeTimeRaw));
                        int oHeadTimeH = oHeadTime / 3600;
                        oHeadTime -= 3600 * oHeadTimeH;
                        int oHeadTimeM = oHeadTime / 60;
                        oHeadTime -= 60 * oHeadTimeM;
                        int oHeadTimeS = oHeadTime;


                        GUILayout.Label("Total Bake Time: " + timeH.ToString("0") + ":" + timeM.ToString("00") + ":" + timeS.ToString("00"), Styles.LabelStyle);
                        if (Unsupported.IsDeveloperBuild())
                        {
                            GUILayout.Label("(Raw Bake Time: " + timeRawH.ToString("0") + ":" + timeRawM.ToString("00") + ":" + timeRawS.ToString("00") + ", Overhead: " + oHeadTimeH.ToString("0") + ":" + oHeadTimeM.ToString("00") + ":" + oHeadTimeS.ToString("00") + ")", Styles.LabelStyle);
                        }
                    }
                }
                string deviceName = Lightmapping.GetLightmapBakeGPUDeviceName();
                if (deviceName.Length > 0)
                {
                    GUILayout.Label("Baking device: " + deviceName, Styles.LabelStyle);
                }
                GUILayout.EndVertical();
            }

            GUILayout.EndVertical();
        }
Esempio n. 2
0
        public override string GetInfoString()
        {
            Texture         texture         = base.target as Texture;
            Texture2D       texture2D       = base.target as Texture2D;
            TextureImporter textureImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(texture)) as TextureImporter;
            string          text            = texture.width.ToString() + "x" + texture.height.ToString();

            if (QualitySettings.desiredColorSpace == ColorSpace.Linear)
            {
                text = text + " " + TextureUtil.GetTextureColorSpaceString(texture);
            }
            bool          flag          = textureImporter && textureImporter.qualifiesForSpritePacking;
            bool          flag2         = TextureInspector.IsNormalMap(texture);
            bool          flag3         = TextureUtil.DoesTextureStillNeedToBeCompressed(AssetDatabase.GetAssetPath(texture));
            bool          flag4         = texture2D != null && TextureUtil.IsNonPowerOfTwo(texture2D);
            TextureFormat textureFormat = TextureUtil.GetTextureFormat(texture);
            bool          flag5         = !flag3;

            if (flag4)
            {
                text += " (NPOT)";
            }
            if (flag3)
            {
                text += " (Not yet compressed)";
            }
            else if (flag2)
            {
                switch (textureFormat)
                {
                case TextureFormat.ARGB4444:
                    text += "  Nm 16 bit";
                    goto IL_176;

                case TextureFormat.RGB24:
IL_11D:
                    if (textureFormat != TextureFormat.DXT5)
                    {
                        text = text + "  " + TextureUtil.GetTextureFormatString(textureFormat);
                        goto IL_176;
                    }
                    text += "  DXTnm";
                    goto IL_176;

                case TextureFormat.RGBA32:
                case TextureFormat.ARGB32:
                    text += "  Nm 32 bit";
                    goto IL_176;
                }
                goto IL_11D;
                IL_176 :;
            }
            else if (flag)
            {
                TextureFormat format;
                ColorSpace    colorSpace;
                int           num;
                textureImporter.ReadTextureImportInstructions(EditorUserBuildSettings.activeBuildTarget, out format, out colorSpace, out num);
                string text2 = text;
                text = string.Concat(new string[]
                {
                    text2,
                    "\n ",
                    TextureUtil.GetTextureFormatString(textureFormat),
                    "(Original) ",
                    TextureUtil.GetTextureFormatString(format),
                    "(Atlas)"
                });
            }
            else
            {
                text = text + "  " + TextureUtil.GetTextureFormatString(textureFormat);
            }
            if (flag5)
            {
                text = text + "\n" + EditorUtility.FormatBytes(TextureUtil.GetStorageMemorySizeLong(texture));
            }
            if (TextureUtil.GetUsageMode(texture) == TextureUsageMode.AlwaysPadded)
            {
                int gPUWidth  = TextureUtil.GetGPUWidth(texture);
                int gPUHeight = TextureUtil.GetGPUHeight(texture);
                if (texture.width != gPUWidth || texture.height != gPUHeight)
                {
                    text += string.Format("\nPadded to {0}x{1}", gPUWidth, gPUHeight);
                }
            }
            return(text);
        }
Esempio n. 3
0
        private void Summary()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]);
            long num  = 0L;
            int  num2 = 0;
            Dictionary <Vector2, int> dictionary = new Dictionary <Vector2, int>();
            bool flag  = false;
            bool flag2 = false;

            LightmapData[] lightmaps = LightmapSettings.lightmaps;
            for (int i = 0; i < lightmaps.Length; i++)
            {
                LightmapData lightmapData = lightmaps[i];
                if (!(lightmapData.lightmapColor == null))
                {
                    num2++;
                    Vector2 vector = new Vector2((float)lightmapData.lightmapColor.width, (float)lightmapData.lightmapColor.height);
                    if (dictionary.ContainsKey(vector))
                    {
                        Dictionary <Vector2, int> dictionary2;
                        Vector2 key;
                        (dictionary2 = dictionary)[key = vector] = dictionary2[key] + 1;
                    }
                    else
                    {
                        dictionary.Add(vector, 1);
                    }
                    num += TextureUtil.GetStorageMemorySizeLong(lightmapData.lightmapColor);
                    if (lightmapData.lightmapDir)
                    {
                        num += TextureUtil.GetStorageMemorySizeLong(lightmapData.lightmapDir);
                        flag = true;
                    }
                    if (lightmapData.shadowMask)
                    {
                        num  += TextureUtil.GetStorageMemorySizeLong(lightmapData.shadowMask);
                        flag2 = true;
                    }
                }
            }
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(num2);
            stringBuilder.Append((!flag) ? " non-directional" : " directional");
            stringBuilder.Append(" lightmap");
            if (num2 != 1)
            {
                stringBuilder.Append("s");
            }
            if (flag2)
            {
                stringBuilder.Append(" with shadowmask");
                if (num2 != 1)
                {
                    stringBuilder.Append("s");
                }
            }
            bool flag3 = true;

            foreach (KeyValuePair <Vector2, int> current in dictionary)
            {
                stringBuilder.Append((!flag3) ? ", " : ": ");
                flag3 = false;
                if (current.Value > 1)
                {
                    stringBuilder.Append(current.Value);
                    stringBuilder.Append("x");
                }
                stringBuilder.Append(current.Key.x);
                stringBuilder.Append("x");
                stringBuilder.Append(current.Key.y);
                stringBuilder.Append("px");
            }
            stringBuilder.Append(" ");
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label(stringBuilder.ToString(), LightingWindow.Styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label(EditorUtility.FormatBytes(num), LightingWindow.Styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.Label((num2 != 0) ? "" : "No Lightmaps", LightingWindow.Styles.labelStyle, new GUILayoutOption[0]);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            if (LightmapEditorSettings.giBakeBackend == LightmapEditorSettings.GIBakeBackend.PathTracer)
            {
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                GUILayout.Label("Occupied texels: " + InternalEditorUtility.CountToString(Lightmapping.occupiedTexelCount), LightingWindow.Styles.labelStyle, new GUILayoutOption[0]);
                if (Lightmapping.isRunning)
                {
                    int num3  = 0;
                    int num4  = 0;
                    int num5  = 0;
                    int num6  = 0;
                    int num7  = 0;
                    int num8  = 0;
                    int num9  = 0;
                    int num10 = LightmapSettings.lightmaps.Length;
                    for (int j = 0; j < num10; j++)
                    {
                        LightmapConvergence lightmapConvergence = Lightmapping.GetLightmapConvergence(j);
                        if (!lightmapConvergence.IsValid())
                        {
                            num9++;
                        }
                        else if (Lightmapping.GetVisibleTexelCount(j) > 0uL)
                        {
                            num3++;
                            if (lightmapConvergence.IsConverged())
                            {
                                num4++;
                            }
                            else
                            {
                                num5++;
                            }
                        }
                        else
                        {
                            num6++;
                            if (lightmapConvergence.IsConverged())
                            {
                                num7++;
                            }
                            else
                            {
                                num8++;
                            }
                        }
                    }
                    EditorGUILayout.LabelField("Lightmaps in view: " + num3, LightingWindow.Styles.labelStyle, new GUILayoutOption[0]);
                    EditorGUI.indentLevel++;
                    EditorGUILayout.LabelField("converged: " + num4, LightingWindow.Styles.labelStyle, new GUILayoutOption[0]);
                    EditorGUILayout.LabelField("not converged: " + num5, LightingWindow.Styles.labelStyle, new GUILayoutOption[0]);
                    EditorGUI.indentLevel--;
                    EditorGUILayout.LabelField("Lightmaps out of view: " + num6, LightingWindow.Styles.labelStyle, new GUILayoutOption[0]);
                    EditorGUI.indentLevel++;
                    EditorGUILayout.LabelField("converged: " + num7, LightingWindow.Styles.labelStyle, new GUILayoutOption[0]);
                    EditorGUILayout.LabelField("not converged: " + num8, LightingWindow.Styles.labelStyle, new GUILayoutOption[0]);
                    EditorGUI.indentLevel--;
                }
                float lightmapBakeTimeTotal        = Lightmapping.GetLightmapBakeTimeTotal();
                float lightmapBakePerformanceTotal = Lightmapping.GetLightmapBakePerformanceTotal();
                if ((double)lightmapBakePerformanceTotal >= 0.0)
                {
                    GUILayout.Label("Bake performance: " + lightmapBakePerformanceTotal.ToString("0.00") + " mrays/sec", LightingWindow.Styles.labelStyle, new GUILayoutOption[0]);
                }
                if (!Lightmapping.isRunning)
                {
                    float lightmapBakeTimeRaw = Lightmapping.GetLightmapBakeTimeRaw();
                    if ((double)lightmapBakeTimeTotal >= 0.0)
                    {
                        int num11 = (int)lightmapBakeTimeTotal;
                        int num12 = num11 / 3600;
                        num11 -= 3600 * num12;
                        int num13 = num11 / 60;
                        num11 -= 60 * num13;
                        int num14 = num11;
                        int num15 = (int)lightmapBakeTimeRaw;
                        int num16 = num15 / 3600;
                        num15 -= 3600 * num16;
                        int num17 = num15 / 60;
                        num15 -= 60 * num17;
                        int num18 = num15;
                        int num19 = Math.Max(0, (int)(lightmapBakeTimeTotal - lightmapBakeTimeRaw));
                        int num20 = num19 / 3600;
                        num19 -= 3600 * num20;
                        int num21 = num19 / 60;
                        num19 -= 60 * num21;
                        int num22 = num19;
                        GUILayout.Label(string.Concat(new string[]
                        {
                            "Total bake time: ",
                            num12.ToString("0"),
                            ":",
                            num13.ToString("00"),
                            ":",
                            num14.ToString("00")
                        }), LightingWindow.Styles.labelStyle, new GUILayoutOption[0]);
                        if (Unsupported.IsDeveloperBuild())
                        {
                            GUILayout.Label(string.Concat(new string[]
                            {
                                "(Raw bake time: ",
                                num16.ToString("0"),
                                ":",
                                num17.ToString("00"),
                                ":",
                                num18.ToString("00"),
                                ", overhead:",
                                num20.ToString("0"),
                                ":",
                                num21.ToString("00"),
                                ":",
                                num22.ToString("00"),
                                ")"
                            }), LightingWindow.Styles.labelStyle, new GUILayoutOption[0]);
                        }
                    }
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndVertical();
        }
        public override string GetInfoString()
        {
            // TextureInspector code is reused for RenderTexture and Cubemap inspectors.
            // Make sure we can handle the situation where target is just a Texture and
            // not a Texture2D.
            Texture         t  = target as Texture;
            Texture2D       t2 = target as Texture2D;
            TextureImporter textureImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(t)) as TextureImporter;
            string          info            = t.width + "x" + t.height;

            bool           showSize              = true;
            bool           isPackedSprite        = textureImporter && textureImporter.qualifiesForSpritePacking;
            bool           isNormalmap           = IsNormalMap(t);
            bool           stillNeedsCompression = TextureUtil.DoesTextureStillNeedToBeCompressed(AssetDatabase.GetAssetPath(t));
            bool           isNPOT = t2 != null && TextureUtil.IsNonPowerOfTwo(t2);
            GraphicsFormat format = t.graphicsFormat;

            showSize = !stillNeedsCompression;
            if (isNPOT)
            {
                info += " (NPOT)";
            }
            if (stillNeedsCompression)
            {
                info += " (Not yet compressed)";
            }
            else
            {
                if (isNormalmap)
                {
                    switch (format)
                    {
                    case GraphicsFormat.RGBA_DXT5_SRGB:
                    case GraphicsFormat.RGBA_DXT5_UNorm:
                        info += "  DXTnm";
                        break;

                    case GraphicsFormat.R8G8B8A8_SRGB:
                    case GraphicsFormat.R8G8B8A8_UNorm:
                    case GraphicsFormat.B8G8R8A8_SRGB:
                    case GraphicsFormat.B8G8R8A8_UNorm:
                        info += "  Nm 32 bit";
                        break;

                    case GraphicsFormat.R4G4B4A4_UNormPack16:
                    case GraphicsFormat.B4G4R4A4_UNormPack16:
                        info += "  Nm 16 bit";
                        break;

                    default:
                        info += "  " + GraphicsFormatUtility.GetFormatString(format);
                        break;
                    }
                }
                else if (isPackedSprite)
                {
                    TextureFormat desiredFormat;
                    ColorSpace    dummyColorSpace;
                    int           dummyComressionQuality;
                    textureImporter.ReadTextureImportInstructions(EditorUserBuildSettings.activeBuildTarget, out desiredFormat, out dummyColorSpace, out dummyComressionQuality);

                    info += "\n " + GraphicsFormatUtility.GetFormatString(format) + "(Original) " + TextureUtil.GetTextureFormatString(desiredFormat) + "(Atlas)";
                }
                else
                {
                    info += "  " + GraphicsFormatUtility.GetFormatString(format);
                }
            }

            if (showSize)
            {
                info += "\n" + EditorUtility.FormatBytes(TextureUtil.GetStorageMemorySizeLong(t));
            }

            if (TextureUtil.GetUsageMode(t) == TextureUsageMode.AlwaysPadded)
            {
                var glWidth  = TextureUtil.GetGPUWidth(t);
                var glHeight = TextureUtil.GetGPUHeight(t);
                if (t.width != glWidth || t.height != glHeight)
                {
                    info += UnityString.Format("\nPadded to {0}x{1}", glWidth, glHeight);
                }
            }
            else if (TextureUtil.GetUsageMode(t) == TextureUsageMode.BakedLightmapRGBM ||
                     TextureUtil.GetUsageMode(t) == TextureUsageMode.RealtimeLightmapRGBM ||
                     TextureUtil.GetUsageMode(t) == TextureUsageMode.RGBMEncoded)
            {
                info += "\nRGBM encoded";
            }
            else if (TextureUtil.GetUsageMode(t) == TextureUsageMode.DoubleLDR ||
                     TextureUtil.GetUsageMode(t) == TextureUsageMode.BakedLightmapDoubleLDR)
            {
                info += "\ndLDR encoded";
            }

            return(info);
        }
Esempio n. 5
0
 public static int GetStorageMemorySize(Texture t)
 {
     return((int)TextureUtil.GetStorageMemorySizeLong(t));
 }