Esempio n. 1
0
        public bool DoubleSidedGIField()
        {
            #pragma warning disable 618
            bool isEnlightenLightMapper = Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper == LightingSettings.Lightmapper.Enlighten;
            #pragma warning restore 618

            Rect r = GetControlRectForSingleLine();
            if (isPrefabAsset || !isEnlightenLightMapper)
            {
                BeginProperty(r, MaterialSerializedProperty.DoubleSidedGI, targets);

                EditorGUI.BeginChangeCheck();
                bool doubleSidedGI = EditorGUI.Toggle(r, Styles.doubleSidedGILabel, (targets[0] as Material).doubleSidedGI);
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (Material material in targets)
                    {
                        material.doubleSidedGI = doubleSidedGI;
                    }
                }

                EndProperty();
                return(true);
            }

            using (new EditorGUI.DisabledScope(isEnlightenLightMapper))
                EditorGUI.Toggle(r, Styles.doubleSidedGILabel, false);

            return(false);
        }
Esempio n. 2
0
        private void DisplayMeshWarning()
        {
            Mesh mesh = GetSharedMesh(m_Renderers[0]);

            var  settings = Lightmapping.GetLightingSettingsOrDefaultsFallback();
            bool showEnlightenSettings = isPrefabAsset || settings.realtimeGI || (settings.bakedGI && settings.lightmapper == LightingSettings.Lightmapper.Enlighten);

            if (!HasSupportedTopologyForGI(mesh))
            {
                EditorGUILayout.HelpBox(Styles.unsupportedTopology.text, MessageType.Warning);
                return;
            }

            if (!HasVertices(mesh))
            {
                EditorGUILayout.HelpBox(Styles.noVerticesNoLightmapping.text, MessageType.Warning);
                return;
            }

            if (!HasNormals(mesh))
            {
                EditorGUILayout.HelpBox(Styles.noNormalsNoLightmapping.text, MessageType.Warning);
                return;
            }

            if (showEnlightenSettings)
            {
                if (Lightmapping.HasZeroAreaMesh(m_Renderers[0]))
                {
                    EditorGUILayout.HelpBox(Styles.zeroAreaPackingMesh.text, MessageType.Warning);
                }
            }
        }
Esempio n. 3
0
        void ShowBakePerformanceWarning(Terrain terrain)
        {
            var terrainWidth       = terrain.terrainData.size.x;
            var terrainHeight      = terrain.terrainData.size.z;
            var lightmapParameters = (LightmapParameters)m_LightmapParameters.objectReferenceValue ?? new LightmapParameters();
            var indirectResolution = Lightmapping.GetLightingSettingsOrDefaultsFallback().indirectResolution;

            var       terrainSystemTexelsInWidth  = terrainWidth * lightmapParameters.resolution * indirectResolution;
            var       terrainSystemTexelsInHeight = terrainHeight * lightmapParameters.resolution * indirectResolution;
            const int kTerrainTexelsThreshold     = 64 * 8;

            if (terrainSystemTexelsInWidth > kTerrainTexelsThreshold || terrainSystemTexelsInHeight > kTerrainTexelsThreshold)
            {
                EditorGUILayout.HelpBox(Styles.resolutionTooHighWarning.text, MessageType.Warning);
            }

            var         terrainClustersInWidth             = terrainSystemTexelsInWidth * lightmapParameters.clusterResolution;
            var         terrainClustersInHeight            = terrainSystemTexelsInHeight * lightmapParameters.clusterResolution;
            var         terrainTrisPerClusterInWidth       = terrain.terrainData.heightmapResolution / terrainClustersInWidth;
            var         terrainTrisPerClusterInHeight      = terrain.terrainData.heightmapResolution / terrainClustersInHeight;
            const float kTerrainClusterTriDensityThreshold = 256.0f / 5.0f;

            if (terrainTrisPerClusterInWidth > kTerrainClusterTriDensityThreshold || terrainTrisPerClusterInHeight > kTerrainClusterTriDensityThreshold)
            {
                EditorGUILayout.HelpBox(Styles.resolutionTooLowWarning.text, MessageType.Warning);
            }
        }
        private void LightmapListGUI(LightmapData[] lightmaps, VisualisationGITexture[] realtimeLightmaps)
        {
            m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition);

            if (!Lightmapping.GetLightingSettingsOrDefaultsFallback().autoGenerate&& !isRealtimeLightmap)
            {
                EditorGUILayout.PropertyField(m_LightingDataAsset, Styles.LightingDataAsset);
                m_LightmapSettings.ApplyModifiedProperties();
                GUILayout.Space(10);
            }
            else
            {
                GUILayout.Space(30);
            }

            DebugInfoSection(lightmaps);

            int length = isRealtimeLightmap ? realtimeLightmaps.Length : lightmaps.Length;

            if (m_SelectedLightmapIndex >= length)
            {
                m_SelectedLightmapIndex = 0;
            }

            for (int i = 0; i < length; i++)
            {
                Texture2D texture = isRealtimeLightmap ? realtimeLightmaps[i].texture : lightmaps[i].lightmapColor;

                if (texture != null)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(10);

                    Hash128 hash = isRealtimeLightmap ? realtimeLightmaps[i].hash : new Hash128();

                    LightmapField(texture, i, hash);

                    GUILayout.Space(5);
                    GUILayout.BeginVertical();
                    GUILayout.Label("Index: " + i, EditorStyles.miniBoldLabel);
                    GUILayout.Label("Size: " + texture.width + "x" + texture.height, EditorStyles.miniBoldLabel);
                    GUILayout.Label("Format: " + texture.format, EditorStyles.miniBoldLabel);

                    if (!isRealtimeLightmap)
                    {
                        GUILayout.Label("Compressed: " + (Lightmapping.GetLightingSettingsOrDefaultsFallback().compressLightmaps ? "Compressed" : "None"), EditorStyles.miniBoldLabel);
                    }

                    GUILayout.EndVertical();
                    LightmapDebugInfo(i);
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                    GUILayout.Space(5);
                }
            }

            GUILayout.EndScrollView();
        }
Esempio n. 5
0
        private bool?GetBakeMode()
        {
            if (!showBakeMode)
            {
                return(null);
            }

            return(Lightmapping.GetLightingSettingsOrDefaultsFallback().autoGenerate);
        }
Esempio n. 6
0
        private string GetBakeModeString()
        {
            if (!showBakeMode)
            {
                return("");
            }

            return("Auto Generate Lighting " + (Lightmapping.GetLightingSettingsOrDefaultsFallback().autoGenerate ? "On" : "Off"));
        }
Esempio n. 7
0
        void ShowClampedSizeInLightmapGUI(float lightmapScale, float cachedSurfaceArea, bool isSSD)
        {
            float sizeInLightmap = Mathf.Sqrt(cachedSurfaceArea) * Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapResolution *lightmapScale;

            if (sizeInLightmap > Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapMaxSize)
            {
                EditorGUILayout.HelpBox(Styles.clampedSize.text, MessageType.Info);
            }
        }
        protected void UvsGUI()
        {
            EditorGUILayout.PropertyField(m_SwapUVChannels, Styles.SwapUVChannels);
            EditorGUILayout.PropertyField(m_GenerateSecondaryUV, Styles.GenerateSecondaryUV);
            if (m_GenerateSecondaryUV.boolValue)
            {
                m_SecondaryUVAdvancedOptions = EditorGUILayout.Foldout(m_SecondaryUVAdvancedOptions, Styles.GenerateSecondaryUVAdvanced, true, EditorStyles.foldout);
                if (m_SecondaryUVAdvancedOptions)
                {
                    using (new EditorGUI.IndentLevelScope())
                    {
                        EditorGUI.BeginChangeCheck();

                        EditorGUILayout.Slider(m_SecondaryUVHardAngle, 0, 180, Styles.secondaryUVHardAngle);
                        EditorGUILayout.Slider(m_SecondaryUVAngleDistortion, 1, 75, Styles.secondaryUVAngleDistortion);
                        EditorGUILayout.Slider(m_SecondaryUVAreaDistortion, 1, 75, Styles.secondaryUVAreaDistortion);

                        using (var horizontal = new EditorGUILayout.HorizontalScope())
                        {
                            using (var prop = new EditorGUI.PropertyScope(horizontal.rect, Styles.secondaryUVMarginMethod, m_SecondaryUVMarginMethod))
                            {
                                EditorGUI.BeginChangeCheck();
                                var newValue = (int)(ModelImporterSecondaryUVMarginMethod)EditorGUILayout.EnumPopup(prop.content, (ModelImporterSecondaryUVMarginMethod)m_SecondaryUVMarginMethod.intValue);
                                if (EditorGUI.EndChangeCheck())
                                {
                                    m_SecondaryUVMarginMethod.intValue = newValue;
                                }
                            }
                        }
                        if (m_SecondaryUVMarginMethod.intValue == (int)ModelImporterSecondaryUVMarginMethod.Calculate)
                        {
                            EditorGUILayout.PropertyField(m_SecondaryUVMinLightmapResolution, Styles.secondaryUVMinLightmapResolution);
                            if (Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapResolution < m_SecondaryUVMinLightmapResolution.floatValue)
                            {
                                EditorGUILayout.HelpBox(Styles.secondaryUVMinLightmapResolutionNotice);
                            }

                            EditorGUILayout.PropertyField(m_SecondaryUVMinObjectScale, Styles.secondaryUVMinObjectScale);
                        }
                        else
                        {
                            EditorGUILayout.Slider(m_SecondaryUVPackMargin, 1, 64, Styles.secondaryUVPackMargin);
                        }

                        if (EditorGUI.EndChangeCheck())
                        {
                            m_SecondaryUVHardAngle.floatValue             = Mathf.Round(m_SecondaryUVHardAngle.floatValue);
                            m_SecondaryUVPackMargin.floatValue            = Mathf.Round(m_SecondaryUVPackMargin.floatValue);
                            m_SecondaryUVMinLightmapResolution.floatValue = Mathf.Round(m_SecondaryUVMinLightmapResolution.floatValue);
                            m_SecondaryUVMinObjectScale.floatValue        = m_SecondaryUVMinObjectScale.floatValue;
                            m_SecondaryUVAngleDistortion.floatValue       = Mathf.Round(m_SecondaryUVAngleDistortion.floatValue);
                            m_SecondaryUVAreaDistortion.floatValue        = Mathf.Round(m_SecondaryUVAreaDistortion.floatValue);
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            GUILayout.Label(Styles.precomputedRealtimeGIContent, EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(m_Resolution, Styles.resolutionContent);
            EditorGUILayout.Slider(m_ClusterResolution, 0.1F, 1.0F, Styles.clusterResolutionContent);
            EditorGUILayout.IntSlider(m_IrradianceBudget, 32, 2048, Styles.irradianceBudgetContent);
            EditorGUILayout.IntSlider(m_IrradianceQuality, 512, 131072, Styles.irradianceQualityContent);
            EditorGUILayout.Slider(m_ModellingTolerance, 0.0f, 1.0f, Styles.modellingToleranceContent);
            EditorGUILayout.PropertyField(m_EdgeStitching, Styles.edgeStitchingContent);
            EditorGUILayout.PropertyField(m_IsTransparent, Styles.isTransparent);
            EditorGUILayout.PropertyField(m_SystemTag, Styles.systemTagContent);
            EditorGUILayout.Space();

            bool usesPathTracerBakeBackend = Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper != LightingSettings.Lightmapper.Enlighten;
            bool usesEnlightenBackend      = Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper == LightingSettings.Lightmapper.Enlighten;

            GUILayout.Label(Styles.bakedGIContent, EditorStyles.boldLabel);
            using (new EditorGUI.DisabledScope(usesPathTracerBakeBackend))
            {
                EditorGUILayout.PropertyField(m_BlurRadius, Styles.blurRadiusContent);
            }
            EditorGUILayout.PropertyField(m_AntiAliasingSamples, Styles.antiAliasingSamplesContent);
            using (new EditorGUI.DisabledScope(usesPathTracerBakeBackend))
            {
                EditorGUILayout.PropertyField(m_DirectLightQuality, Styles.directLightQualityContent);
            }
            EditorGUILayout.Slider(m_Pushoff, 0.0f, 1.0f, Styles.pushoffContent);
            EditorGUILayout.PropertyField(m_BakedLightmapTag, Styles.bakedLightmapTagContent);
            using (new EditorGUI.DisabledScope(usesEnlightenBackend))
            {
                m_LimitLightmapCount.boolValue = EditorGUILayout.Toggle(Styles.limitLightmapCount, m_LimitLightmapCount.boolValue);
                if (m_LimitLightmapCount.boolValue)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(m_LightmapMaxCount, Styles.lightmapMaxCount);
                    EditorGUI.indentLevel--;
                }
            }
            EditorGUILayout.Space();

            using (new EditorGUI.DisabledScope(usesPathTracerBakeBackend))
            {
                GUILayout.Label(Styles.bakedAOContent, EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(m_AOQuality, Styles.aoQualityContent);
                EditorGUILayout.PropertyField(m_AOAntiAliasingSamples, Styles.aoAntiAliasingSamplesContent);
            }

            GUILayout.Label(Styles.generalGIContent, EditorStyles.boldLabel);
            EditorGUILayout.Slider(m_BackFaceTolerance, 0.0f, 1.0f, Styles.backFaceToleranceContent);

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 10
0
        void DoBakeButton()
        {
            if (reflectionProbeTarget.mode == ReflectionProbeMode.Realtime)
            {
                EditorGUILayout.HelpBox("Baking 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 (reflectionProbeTarget.mode == ReflectionProbeMode.Baked && Lightmapping.GetLightingSettingsOrDefaultsFallback().autoGenerate)
            {
                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;
            }

            GUILayout.BeginHorizontal();

            GUILayout.Space(EditorGUIUtility.labelWidth);
            switch (reflectionProbeMode)
            {
            case ReflectionProbeMode.Custom:
                if (EditorGUI.ButtonWithDropdownList(Styles.bakeCustomButtonText, Styles.bakeCustomOptionText, OnBakeCustomButton))
                {
                    BakeCustomReflectionProbe(reflectionProbeTarget, true);
                    GUIUtility.ExitGUI();
                }
                break;

            case ReflectionProbeMode.Baked:
                using (new EditorGUI.DisabledScope(!reflectionProbeTarget.enabled))
                {
                    // Bake button in non-continous mode
                    if (EditorGUI.ButtonWithDropdownList(Styles.bakeButtonText, Styles.bakeButtonsText, OnBakeButton))
                    {
                        Lightmapping.BakeReflectionProbeSnapshot(reflectionProbeTarget);
                        GUIUtility.ExitGUI();
                    }
                }

                break;

            case ReflectionProbeMode.Realtime:
                // Not showing bake button in realtime
                break;
            }

            GUILayout.EndHorizontal();
        }
Esempio n. 11
0
        static public bool LightmapParametersGUI(SerializedProperty prop, GUIContent content)
        {
            EditorGUILayout.BeginHorizontal();

            EditorGUIInternal.AssetPopup <LightmapParameters>(prop, content, "giparams", "Scene Default Parameters");

            string label = "Edit...";

            if (isBuiltIn(prop))
            {
                label = "View";
            }

            bool editClicked = false;

            // If object is null, then get the scene parameter setting and view this instead.
            if (prop.objectReferenceValue == null)
            {
                SerializedObject   so = new SerializedObject(Lightmapping.GetLightingSettingsOrDefaultsFallback());
                SerializedProperty lightmapParameters = so.FindProperty("m_LightmapParameters");

                using (new EditorGUI.DisabledScope(lightmapParameters == null))
                {
                    if (isBuiltIn(lightmapParameters))
                    {
                        label = "View";
                    }
                    else
                    {
                        label = "Edit...";
                    }

                    if (GUILayout.Button(label, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                    {
                        Selection.activeObject = lightmapParameters.objectReferenceValue;
                        editClicked            = true;
                    }
                }
            }
            else
            {
                if (GUILayout.Button(label, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                {
                    Selection.activeObject = prop.objectReferenceValue;
                    editClicked            = true;
                }
            }

            EditorGUILayout.EndHorizontal();

            return(editClicked);
        }
Esempio n. 12
0
        static public void LightmapParametersGUI(SerializedProperty prop, GUIContent content)
        {
            EditorGUILayout.BeginHorizontal();

            var rect = EditorGUILayout.GetControlRect();

            EditorGUI.BeginProperty(rect, content, prop);

            rect = EditorGUI.PrefixLabel(rect, content);

            GUIContent buttonContent = prop.hasMultipleDifferentValues ? EditorGUI.mixedValueContent : (prop.objectReferenceValue != null ? GUIContent.Temp(prop.objectReferenceStringValue) : Styles.lightmapParametersDefault);

            if (EditorGUI.DropdownButton(rect, buttonContent, FocusType.Passive, EditorStyles.popup))
            {
                AssetPopupBackend.ShowAssetsPopupMenu <LightmapParameters>(rect, prop.objectReferenceTypeString, prop, "giparams", Styles.lightmapParametersDefault.text);
            }

            string label = isBuiltIn(prop) ? "View" : "Edit...";

            // If object is null, then get the scene parameter setting and view this instead.
            using (new EditorGUI.DisabledScope(prop.hasMultipleDifferentValues))
            {
                if (prop.objectReferenceValue == null)
                {
                    SerializedObject   so = new SerializedObject(Lightmapping.GetLightingSettingsOrDefaultsFallback());
                    SerializedProperty lightmapParameters = so.FindProperty("m_LightmapParameters");

                    using (new EditorGUI.DisabledScope(lightmapParameters == null))
                    {
                        label = isBuiltIn(lightmapParameters) ? "View" : "Edit...";

                        if (GUILayout.Button(label, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                        {
                            Selection.activeObject = lightmapParameters.objectReferenceValue;
                        }
                    }
                }
                else
                {
                    if (GUILayout.Button(label, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                    {
                        Selection.activeObject = prop.objectReferenceValue;
                    }
                }
            }

            EditorGUILayout.EndHorizontal();
            EditorGUI.EndProperty();
        }
Esempio n. 13
0
        void LightmapScaleGUI(bool isMeshRenderer, GUIContent title, bool isSSD)
        {
            // SSDs (with the exception of those being computed with Enlighten) do not end up in a lightmap,
            // therefore we do not show clamping information.
            if (isSSD && Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper != LightingSettings.Lightmapper.Enlighten)
            {
                return;
            }

            float lodScale      = CalcLODScale(isMeshRenderer);
            float lightmapScale = lodScale * m_LightmapScale.floatValue;

            Rect rect = EditorGUILayout.GetControlRect();

            EditorGUI.BeginProperty(rect, Styles.scaleInLightmap, m_LightmapScale);
            EditorGUI.BeginChangeCheck();
            lightmapScale = EditorGUI.FloatField(rect, title, lightmapScale);
            if (EditorGUI.EndChangeCheck())
            {
                m_LightmapScale.floatValue = Mathf.Max(lightmapScale / Mathf.Max(lodScale, float.Epsilon), 0.0f);
            }
            EditorGUI.EndProperty();

            float cachedSurfaceArea = 0.0f;

            if (isMeshRenderer)
            {
                if ((m_Renderers != null) && (m_Renderers.Length > 0))
                {
                    lightmapScale = lightmapScale * LightmapVisualization.GetLightmapLODLevelScale(m_Renderers[0]);

                    // tell the user if the object's size in lightmap has reached the max atlas size
                    cachedSurfaceArea = InternalMeshUtil.GetCachedMeshSurfaceArea((MeshRenderer)m_Renderers[0]);
                }
            }
            else //terrain
            {
                // tell the user if the object's size in lightmap has reached the max atlas size
                if ((m_Terrains != null) && (m_Terrains.Length > 0))
                {
                    var terrainData = m_Terrains[0].terrainData;
                    cachedSurfaceArea = terrainData != null ? terrainData.size.x * terrainData.size.z : 0.0f;
                }
            }

            ShowClampedSizeInLightmapGUI(lightmapScale, cachedSurfaceArea, isSSD);
        }
        public bool DoubleSidedGIField()
        {
            Rect r = GetControlRectForSingleLine();

            if (isPrefabAsset || Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper != LightingSettings.Lightmapper.Enlighten)
            {
                EditorGUI.PropertyField(r, m_DoubleSidedGI, Styles.doubleSidedGILabel);
                serializedObject.ApplyModifiedProperties();
                return(true);
            }
            else
            {
                using (new EditorGUI.DisabledScope(Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper == LightingSettings.Lightmapper.Enlighten))
                    EditorGUI.Toggle(r, Styles.doubleSidedGILabel, false);
            }
            return(false);
        }
Esempio n. 15
0
        void WorkflowSettingsGUI()
        {
            m_ShowWorkflowSettings.value = EditorGUILayout.FoldoutTitlebar(m_ShowWorkflowSettings.value, Styles.workflowSettings, true);

            if (m_ShowWorkflowSettings.value)
            {
                EditorGUI.indentLevel++;

                // GPU lightmapper device selection.
                if (Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper == LightingSettings.Lightmapper.ProgressiveGPU)
                {
                    DeviceAndPlatform[] devicesAndPlatforms = Lightmapping.GetLightmappingGpuDevices();
                    if (devicesAndPlatforms.Length > 0)
                    {
                        int[]        lightmappingDeviceIndices = Enumerable.Range(0, devicesAndPlatforms.Length).ToArray();
                        GUIContent[] lightmappingDeviceStrings = devicesAndPlatforms.Select(x => new GUIContent(x.name)).ToArray();

                        int    bakingDeviceAndPlatform = -1;
                        string configDeviceAndPlatform = EditorUserSettings.GetConfigValue(m_LightmappingDeviceIndex);
                        if (configDeviceAndPlatform != null)
                        {
                            bakingDeviceAndPlatform = Int32.Parse(configDeviceAndPlatform);
                            bakingDeviceAndPlatform = Mathf.Clamp(bakingDeviceAndPlatform, 0, devicesAndPlatforms.Length - 1); // Removing a GPU and rebooting invalidates the saved value.
                        }
                        else
                        {
                            bakingDeviceAndPlatform = Lightmapping.GetLightmapBakeGPUDeviceIndex();
                        }

                        Debug.Assert(bakingDeviceAndPlatform != -1);

                        EditorGUI.BeginChangeCheck();
                        using (new EditorGUI.DisabledScope(devicesAndPlatforms.Length < 2))
                        {
                            bakingDeviceAndPlatform = EditorGUILayout.IntPopup(Styles.progressiveGPUBakingDevice, bakingDeviceAndPlatform, lightmappingDeviceStrings, lightmappingDeviceIndices);
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (EditorUtility.DisplayDialog("Warning", Styles.progressiveGPUChangeWarning.text, "OK", "Cancel"))
                            {
                                EditorUserSettings.SetConfigValue(m_LightmappingDeviceIndex, bakingDeviceAndPlatform.ToString());
                                DeviceAndPlatform selectedDeviceAndPlatform = devicesAndPlatforms[bakingDeviceAndPlatform];
                                EditorApplication.CloseAndRelaunch(new string[] { "-OpenCL-PlatformAndDeviceIndices", selectedDeviceAndPlatform.platformId.ToString(), selectedDeviceAndPlatform.deviceId.ToString() });
                            }
                        }
                    }
                    else
                    {
                        // To show when we are still fetching info, so that the UI doesn't pop around too much for no reason
                        using (new EditorGUI.DisabledScope(true))
                        {
                            EditorGUILayout.IntPopup(Styles.progressiveGPUBakingDevice, 0, Styles.progressiveGPUUnknownDeviceStrings, Styles.progressiveGPUUnknownDeviceValues);
                        }

                        EditorGUILayout.HelpBox(Styles.progressiveGPUUnknownDeviceInfo.text, MessageType.Info);
                    }
                }

                m_ShowProbeDebugSettings.value = EditorGUILayout.Foldout(m_ShowProbeDebugSettings.value, Styles.lightProbeVisualization, true);

                if (m_ShowProbeDebugSettings.value)
                {
                    EditorGUI.BeginChangeCheck();

                    EditorGUI.indentLevel++;
                    LightProbeVisualization.lightProbeVisualizationMode = (LightProbeVisualization.LightProbeVisualizationMode)EditorGUILayout.EnumPopup(LightProbeVisualization.lightProbeVisualizationMode);
                    LightProbeVisualization.showInterpolationWeights    = EditorGUILayout.Toggle(Styles.displayWeights, LightProbeVisualization.showInterpolationWeights);
                    LightProbeVisualization.showOcclusions        = EditorGUILayout.Toggle(Styles.displayOcclusion, LightProbeVisualization.showOcclusions);
                    LightProbeVisualization.highlightInvalidCells = EditorGUILayout.Toggle(Styles.highlightInvalidCells, LightProbeVisualization.highlightInvalidCells);
                    EditorGUI.indentLevel--;

                    if (EditorGUI.EndChangeCheck())
                    {
                        EditorApplication.SetSceneRepaintDirty();
                    }
                }

                if (Unsupported.IsDeveloperMode())
                {
                    Lightmapping.concurrentJobsType = (Lightmapping.ConcurrentJobsType)EditorGUILayout.IntPopup(Styles.concurrentJobs, (int)Lightmapping.concurrentJobsType, Styles.concurrentJobsTypeStrings, Styles.concurrentJobsTypeValues);

                    if (GUILayout.Button("Clear disk cache", GUILayout.Width(Styles.buttonWidth)))
                    {
                        Lightmapping.Clear();
                        Lightmapping.ClearDiskCache();
                    }

                    if (GUILayout.Button("Print state to console", GUILayout.Width(Styles.buttonWidth)))
                    {
                        Lightmapping.PrintStateToConsole();
                    }

                    if (GUILayout.Button("Reset albedo/emissive", GUILayout.Width(Styles.buttonWidth)))
                    {
                        GIDebugVisualisation.ResetRuntimeInputTextures();
                    }

                    if (GUILayout.Button("Reset environment", GUILayout.Width(Styles.buttonWidth)))
                    {
                        DynamicGI.UpdateEnvironment();
                    }
                }

                EditorGUI.indentLevel--;
                EditorGUILayout.Space();
            }
        }
Esempio n. 16
0
        private void LightmapListGUI(LightmapData[] lightmaps, VisualisationGITexture[] realtimeLightmaps)
        {
            m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition);

            if (!Lightmapping.GetLightingSettingsOrDefaultsFallback().autoGenerate&& !isRealtimeLightmap)
            {
                EditorGUI.BeginChangeCheck();
                var lda = (LightingDataAsset)EditorGUILayout.ObjectField(Styles.LightingDataAsset, Lightmapping.lightingDataAsset, typeof(LightingDataAsset), true);
                if (EditorGUI.EndChangeCheck())
                {
                    Lightmapping.lightingDataAsset = lda;
                }
                GUILayout.Space(10);
            }
            else
            {
                GUILayout.Space(30);
            }

            DebugInfoSection(lightmaps);

            int length = isRealtimeLightmap ? realtimeLightmaps.Length : lightmaps.Length;

            if (m_SelectedLightmapIndex >= length)
            {
                m_SelectedLightmapIndex = 0;
            }

            for (int i = 0; i < length; i++)
            {
                Texture2D texture = isRealtimeLightmap ? realtimeLightmaps[i].texture : lightmaps[i].lightmapColor;

                if (texture != null)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(10);

                    Hash128 hash = isRealtimeLightmap ? realtimeLightmaps[i].hash : new Hash128();

                    LightmapField(texture, i, hash);

                    GUILayout.Space(5);
                    GUILayout.BeginVertical();
                    GUILayout.Label("Index: " + i, EditorStyles.miniBoldLabel);
                    GUILayout.Label("Size: " + texture.width + "x" + texture.height, EditorStyles.miniBoldLabel);

                    if (!isRealtimeLightmap)
                    {
                        GUILayout.Label("Format: " + texture.format + (Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapCompression == LightmapCompression.None ? " (uncompressed)" : " (compressed)"), EditorStyles.miniBoldLabel);
                    }
                    else
                    {
                        GUILayout.Label("Format: " + texture.format, EditorStyles.miniBoldLabel);
                    }

                    GUILayout.EndVertical();
                    LightmapDebugInfo(i);
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                    GUILayout.Space(5);
                }
            }

            GUILayout.EndScrollView();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // realtime settings
            if (SupportedRenderingFeatures.IsLightmapBakeTypeSupported(LightmapBakeType.Realtime))
            {
                GUILayout.Label(Styles.precomputedRealtimeGIContent, EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(m_Resolution, Styles.resolutionContent);
                EditorGUILayout.Slider(m_ClusterResolution, 0.1F, 1.0F, Styles.clusterResolutionContent);
                EditorGUILayout.IntSlider(m_IrradianceBudget, 32, 2048, Styles.irradianceBudgetContent);
                EditorGUILayout.IntSlider(m_IrradianceQuality, 512, 131072, Styles.irradianceQualityContent);
                EditorGUILayout.Slider(m_ModellingTolerance, 0.0f, 1.0f, Styles.modellingToleranceContent);
                EditorGUILayout.PropertyField(m_EdgeStitching, Styles.edgeStitchingContent);
                EditorGUILayout.PropertyField(m_IsTransparent, Styles.isTransparent);
                EditorGUILayout.PropertyField(m_SystemTag, Styles.systemTagContent);
                EditorGUILayout.Space();
            }

            // baked settings
            #pragma warning disable 618
            bool usesPathTracerBakeBackend = Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper != LightingSettings.Lightmapper.Enlighten;
            bool usesEnlightenBackend      = Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper == LightingSettings.Lightmapper.Enlighten;
            bool bakedEnlightenSupported   = SupportedRenderingFeatures.IsLightmapperSupported((int)LightingSettings.Lightmapper.Enlighten);
            #pragma warning restore 618

            GUILayout.Label(Styles.bakedGIContent, EditorStyles.boldLabel);

            if (bakedEnlightenSupported)
            {
                using (new EditorGUI.DisabledScope(usesPathTracerBakeBackend))
                {
                    EditorGUILayout.PropertyField(m_BlurRadius, Styles.blurRadiusContent);
                    EditorGUILayout.PropertyField(m_DirectLightQuality, Styles.directLightQualityContent);
                }
            }

            EditorGUILayout.PropertyField(m_AntiAliasingSamples, Styles.antiAliasingSamplesContent);
            const float minPushOff = 0.0001f; // Keep in sync with PLM_MIN_PUSHOFF
            EditorGUILayout.Slider(m_Pushoff, minPushOff, 1.0f, Styles.pushoffContent);
            EditorGUILayout.PropertyField(m_BakedLightmapTag, Styles.bakedLightmapTagContent);
            using (new EditorGUI.DisabledScope(usesEnlightenBackend))
            {
                m_LimitLightmapCount.boolValue = EditorGUILayout.Toggle(Styles.limitLightmapCount, m_LimitLightmapCount.boolValue);
                if (m_LimitLightmapCount.boolValue)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(m_LightmapMaxCount, Styles.lightmapMaxCount);
                    EditorGUI.indentLevel--;
                }
            }
            EditorGUILayout.Space();

            if (bakedEnlightenSupported)
            {
                using (new EditorGUI.DisabledScope(usesPathTracerBakeBackend))
                {
                    GUILayout.Label(Styles.bakedAOContent, EditorStyles.boldLabel);
                    EditorGUILayout.PropertyField(m_AOQuality, Styles.aoQualityContent);
                    EditorGUILayout.PropertyField(m_AOAntiAliasingSamples, Styles.aoAntiAliasingSamplesContent);
                }
            }

            GUILayout.Label(Styles.generalGIContent, EditorStyles.boldLabel);
            EditorGUILayout.Slider(m_BackFaceTolerance, 0.0f, 1.0f, Styles.backFaceToleranceContent);

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 18
0
        void ShowAtlasGUI(int instanceID, bool isMeshRenderer)
        {
            if (m_LightmapIndex == null)
            {
                return;
            }

            Hash128 contentHash = LightmapVisualizationUtility.GetBakedGITextureHash(m_LightmapIndex.intValue, 0, GITextureType.Baked);

            // if we need to fetch a new texture
            if (m_CachedBakedTexture.texture == null || m_CachedBakedTexture.contentHash != contentHash)
            {
                m_CachedBakedTexture = LightmapVisualizationUtility.GetBakedGITexture(m_LightmapIndex.intValue, 0, GITextureType.Baked);
            }

            if (m_CachedBakedTexture.texture == null)
            {
                return;
            }

            m_ShowBakedLM.value = EditorGUILayout.Foldout(m_ShowBakedLM.value, Styles.atlas, true);

            if (!m_ShowBakedLM.value)
            {
                return;
            }

            EditorGUI.indentLevel += 1;

            GUILayout.BeginHorizontal();

            DrawLightmapPreview(m_CachedBakedTexture.texture, false, instanceID);

            GUILayout.BeginVertical();

            GUILayout.Label(Styles.atlasIndex.text + ": " + m_LightmapIndex.intValue);
            GUILayout.Label(Styles.atlasTilingX.text + ": " + m_LightmapTilingOffsetX.floatValue.ToString(CultureInfo.InvariantCulture.NumberFormat));
            GUILayout.Label(Styles.atlasTilingY.text + ": " + m_LightmapTilingOffsetY.floatValue.ToString(CultureInfo.InvariantCulture.NumberFormat));
            GUILayout.Label(Styles.atlasOffsetX.text + ": " + m_LightmapTilingOffsetZ.floatValue.ToString(CultureInfo.InvariantCulture.NumberFormat));
            GUILayout.Label(Styles.atlasOffsetY.text + ": " + m_LightmapTilingOffsetW.floatValue.ToString(CultureInfo.InvariantCulture.NumberFormat));

            var settings = Lightmapping.GetLightingSettingsOrDefaultsFallback();

            float lightmapResolution = settings.lightmapResolution * CalcLODScale(isMeshRenderer) * m_LightmapScale.floatValue;

            if (isMeshRenderer && (m_Renderers != null) && (m_Renderers.Length > 0))
            {
                Transform transform           = m_Renderers[0].GetComponent <Transform>();
                float     lightmapObjectScale = System.Math.Min(System.Math.Min(transform.localScale.x, transform.localScale.y), transform.localScale.z);
                GUILayout.Label(Styles.lightmapResolution.text + ": " + lightmapResolution.ToString(CultureInfo.InvariantCulture.NumberFormat));
                GUILayout.Label(Styles.lightmapObjectScale.text + ": " + lightmapObjectScale.ToString(CultureInfo.InvariantCulture.NumberFormat));
            }

            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            bool showProgressiveInfo = isPrefabAsset || (settings.bakedGI && settings.lightmapper != LightingSettings.Lightmapper.Enlighten);

            if (showProgressiveInfo && Unsupported.IsDeveloperMode())
            {
                Hash128 instanceHash;
                Lightmapping.GetPVRInstanceHash(instanceID, out instanceHash);
                EditorGUILayout.LabelField(Styles.pvrInstanceHash, GUIContent.Temp(instanceHash.ToString()));

                Hash128 atlasHash;
                Lightmapping.GetPVRAtlasHash(instanceID, out atlasHash);
                EditorGUILayout.LabelField(Styles.pvrAtlasHash, GUIContent.Temp(atlasHash.ToString()));

                int atlasInstanceOffset;
                Lightmapping.GetPVRAtlasInstanceOffset(instanceID, out atlasInstanceOffset);
                EditorGUILayout.LabelField(Styles.pvrAtlasInstanceOffset, GUIContent.Temp(atlasInstanceOffset.ToString()));
            }
            EditorGUI.indentLevel -= 1;

            GUILayout.Space(5);
        }
Esempio n. 19
0
        void Buttons(bool showAutoToggle)
        {
            using (new EditorGUI.DisabledScope(EditorApplication.isPlayingOrWillChangePlaymode))
            {
                if (Lightmapping.lightingDataAsset && !Lightmapping.lightingDataAsset.isValid)
                {
                    EditorGUILayout.HelpBox(Lightmapping.lightingDataAsset.validityErrorMessage, MessageType.Warning);
                }

                EditorGUILayout.Space();
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                bool iterative = m_WorkflowMode.intValue == (int)Lightmapping.GIWorkflowMode.Iterative;
                Rect rect      = GUILayoutUtility.GetRect(Styles.continuousBakeLabel, GUIStyle.none);

                if (showAutoToggle)
                {
                    EditorGUI.BeginProperty(rect, Styles.continuousBakeLabel, m_WorkflowMode);

                    // Continous mode checkbox
                    EditorGUI.BeginChangeCheck();
                    using (new EditorGUI.DisabledScope(m_LightingSettingsReadOnlyMode))
                    {
                        iterative = GUILayout.Toggle(iterative, Styles.continuousBakeLabel);
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        m_WorkflowMode.intValue = (int)(iterative ? Lightmapping.GIWorkflowMode.Iterative : Lightmapping.GIWorkflowMode.OnDemand);
                    }

                    EditorGUI.EndProperty();
                }

                using (new EditorGUI.DisabledScope(iterative))
                {
                    // Bake button if we are not currently baking
                    bool showBakeButton = iterative || !Lightmapping.isRunning;
                    if (showBakeButton)
                    {
                        if (EditorGUI.ButtonWithDropdownList(Styles.buildLabel, Styles.BakeModeStrings, BakeDropDownCallback, GUILayout.Width(170)))
                        {
                            DoBake();

                            // DoBake could've spawned a save scene dialog. This breaks GUI on mac (Case 490388).
                            // We work around this with an ExitGUI here.
                            GUIUtility.ExitGUI();
                        }
                    }
                    // Cancel button if we are currently baking
                    else
                    {
                        var settings = Lightmapping.GetLightingSettingsOrDefaultsFallback();
                        // Only show Force Stop when using the PathTracer backend
                        if (settings.lightmapper != LightingSettings.Lightmapper.Enlighten && settings.bakedGI &&
                            GUILayout.Button("Force Stop", GUILayout.Width(Styles.ButtonWidth)))
                        {
                            Lightmapping.ForceStop();
                        }
                        if (GUILayout.Button("Cancel", GUILayout.Width(Styles.ButtonWidth)))
                        {
                            Lightmapping.Cancel();
                        }
                    }
                }

                GUILayout.EndHorizontal();
                EditorGUILayout.Space();
            }
        }
Esempio n. 20
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 (Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper != LightingSettings.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 numInvalidConvergenceLightmaps = 0;
                    int numLightmaps = LightmapSettings.lightmaps.Length;
                    for (int i = 0; i < numLightmaps; ++i)
                    {
                        LightmapConvergence lc = Lightmapping.GetLightmapConvergence(i);
                        if (!lc.IsValid())
                        {
                            numInvalidConvergenceLightmaps++;
                            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. 21
0
        public void RenderTerrainSettings()
        {
            if (m_SerializedObject == null || m_GameObjectsSerializedObject == null || m_GameObjectsSerializedObject.targetObjectsCount == 0)
            {
                return;
            }

            m_GameObjectsSerializedObject.Update();

            var  settings   = Lightmapping.GetLightingSettingsOrDefaultsFallback();
            bool bakedGI    = settings.bakedGI;
            bool realtimeGI = settings.realtimeGI;

            bool contributeGI = (m_StaticEditorFlags.intValue & (int)StaticEditorFlags.ContributeGI) != 0;

            m_ShowLightingSettings.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_ShowLightingSettings.value, Styles.lightingSettings);

            if (m_ShowLightingSettings.value)
            {
                EditorGUI.indentLevel += 1;

                contributeGI = ContributeGISettings();

                if (!(bakedGI || realtimeGI) && !isPrefabAsset && contributeGI)
                {
                    EditorGUILayout.HelpBox(Styles.giNotEnabledInfo.text, MessageType.Info);
                    EditorGUI.indentLevel -= 1;
                    return;
                }

                using (new EditorGUI.DisabledScope(true))
                {
                    EditorGUILayout.IntPopup(Styles.receiveGITitle, 1, Styles.receiveGILightmapStrings, Styles.receiveGILightmapValues);
                }

                EditorGUI.indentLevel -= 1;
            }

            EditorGUILayout.EndFoldoutHeaderGroup();
            EditorGUILayout.Space();

            if (contributeGI)
            {
                m_ShowLightmapSettings.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_ShowLightmapSettings.value, Styles.lightmapSettings);

                if (m_ShowLightmapSettings.value)
                {
                    EditorGUI.indentLevel += 1;

                    if (GUI.enabled)
                    {
                        ShowTerrainChunks(m_Terrains);
                    }

                    LightmapScaleGUI(false, Styles.scaleInLightmap, false);

                    LightmapParametersGUI(m_LightmapParameters, Styles.lightmapParameters);

                    if ((m_Terrains != null) && (m_Terrains.Length > 0))
                    {
                        if (GUI.enabled && m_Terrains.Length == 1 && m_Terrains[0].terrainData != null)
                        {
                            ShowBakePerformanceWarning(m_Terrains[0]);
                        }

                        ShowAtlasGUI(m_Terrains[0].GetInstanceID(), false);
                        ShowRealtimeLMGUI(m_Terrains[0]);
                    }

                    EditorGUI.indentLevel -= 1;
                }

                EditorGUILayout.EndFoldoutHeaderGroup();

                GUILayout.Space(10);
            }
        }
Esempio n. 22
0
        public void RenderSettings(bool showLightmapSettings)
        {
            if (m_SerializedObject == null || m_GameObjectsSerializedObject == null || m_GameObjectsSerializedObject.targetObjectsCount == 0)
            {
                return;
            }

            var  settings    = Lightmapping.GetLightingSettingsOrDefaultsFallback();
            var  lightmapper = settings.lightmapper;
            bool bakedGI     = settings.bakedGI;
            bool realtimeGI  = settings.realtimeGI;

            m_GameObjectsSerializedObject.Update();

            ReceiveGI receiveGI             = (ReceiveGI)m_ReceiveGI.intValue;
            bool      contributeGI          = (m_StaticEditorFlags.intValue & (int)StaticEditorFlags.ContributeGI) != 0;
            bool      showEnlightenSettings = isPrefabAsset || realtimeGI || (bakedGI && lightmapper == LightingSettings.Lightmapper.Enlighten);

            // m_ReceiveGI might still be set to Lightmaps, but LightProbes is shown in the inspector since the contributeGI if off.
            // In this case we still have to mark it as "multiple values" even though both have "Lightmaps" as the value, but one is showing a grayed out "Light Probes" in the UI
            bool showMixedGIValue = m_ReceiveGI.hasMultipleDifferentValues || ((m_StaticEditorFlags.hasMultipleDifferentValuesBitwise & (int)StaticEditorFlags.ContributeGI) != 0);

            m_ShowLightingSettings.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_ShowLightingSettings.value, Styles.lightingSettings);

            if (m_ShowLightingSettings.value)
            {
                EditorGUI.indentLevel += 1;

                EditorGUILayout.PropertyField(m_CastShadows, Styles.castShadows, true);
                bool isDeferredRenderingPath = SceneView.IsUsingDeferredRenderingPath();

                if (SupportedRenderingFeatures.active.receiveShadows)
                {
                    using (new EditorGUI.DisabledScope(isDeferredRenderingPath))
                        EditorGUILayout.PropertyField(m_ReceiveShadows, Styles.receiveShadows, true);
                }

                if (!showLightmapSettings)
                {
                    EditorGUI.indentLevel -= 1;

                    EditorGUILayout.EndFoldoutHeaderGroup();

                    return;
                }

                contributeGI = ContributeGISettings();

                if (!(bakedGI || realtimeGI) && !isPrefabAsset && contributeGI)
                {
                    EditorGUILayout.HelpBox(Styles.giNotEnabledInfo.text, MessageType.Info);
                    EditorGUI.indentLevel -= 1;

                    EditorGUILayout.EndFoldoutHeaderGroup();

                    return;
                }

                if (contributeGI)
                {
                    var rect = EditorGUILayout.GetControlRect();
                    EditorGUI.BeginProperty(rect, Styles.receiveGITitle, m_ReceiveGI);
                    EditorGUI.BeginChangeCheck();

                    receiveGI = (ReceiveGI)EditorGUI.IntPopup(rect, Styles.receiveGITitle, (int)receiveGI, Styles.receiveGILightmapStrings, Styles.receiveGILightmapValues);

                    if (EditorGUI.EndChangeCheck())
                    {
                        m_ReceiveGI.intValue = (int)receiveGI;
                    }

                    EditorGUI.EndProperty();

                    if (showEnlightenSettings)
                    {
                        EditorGUILayout.PropertyField(m_ImportantGI, Styles.importantGI);
                    }

                    if (receiveGI == ReceiveGI.LightProbes && !showMixedGIValue)
                    {
                        LightmapScaleGUI(true, Styles.albedoScale, true);
                    }
                }
                else
                {
                    using (new EditorGUI.DisabledScope(true))
                    {
                        EditorGUI.showMixedValue = showMixedGIValue;
                        receiveGI = (ReceiveGI)EditorGUILayout.IntPopup(Styles.receiveGITitle, (int)ReceiveGI.LightProbes, Styles.receiveGILightmapStrings, Styles.receiveGILightmapValues);
                        EditorGUI.showMixedValue = false;
                    }
                }

                EditorGUI.indentLevel -= 1;
            }

            EditorGUILayout.EndFoldoutHeaderGroup();

            if (showLightmapSettings && contributeGI && receiveGI == ReceiveGI.Lightmaps && !showMixedGIValue)
            {
                m_ShowLightmapSettings.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_ShowLightmapSettings.value, Styles.lightmapSettings);

                if (m_ShowLightmapSettings.value)
                {
                    EditorGUI.indentLevel += 1;

                    bool showProgressiveSettings = isPrefabAsset || (bakedGI && lightmapper != LightingSettings.Lightmapper.Enlighten);

                    LightmapScaleGUI(true, Styles.scaleInLightmap, false);

                    if (showProgressiveSettings)
                    {
                        EditorGUILayout.PropertyField(m_StitchLightmapSeams, Styles.stitchLightmapSeams);
                    }

                    LightmapParametersGUI(m_LightmapParameters, Styles.lightmapParameters);

                    if (showEnlightenSettings)
                    {
                        RendererUVSettings();
                    }

                    if ((m_Renderers != null) && (m_Renderers.Length > 0))
                    {
                        ShowAtlasGUI(m_Renderers[0].GetInstanceID(), true);
                        ShowRealtimeLMGUI(m_Renderers[0]);

                        if (Lightmapping.HasZeroAreaMesh(m_Renderers[0]))
                        {
                            EditorGUILayout.HelpBox(Styles.zeroAreaPackingMesh.text, MessageType.Warning);
                        }

                        DisplayMeshWarning();

                        if (showEnlightenSettings)
                        {
                            if (Lightmapping.HasClampedResolution(m_Renderers[0]))
                            {
                                EditorGUILayout.HelpBox(Styles.clampedPackingResolution.text, MessageType.Warning);
                            }
                        }

                        if (showProgressiveSettings)
                        {
                            if (Lightmapping.HasUVOverlaps(m_Renderers[0]))
                            {
                                EditorGUILayout.HelpBox(Styles.uvOverlap.text, MessageType.Warning);
                            }
                        }
                    }

                    EditorGUI.indentLevel -= 1;
                }

                EditorGUILayout.EndFoldoutHeaderGroup();
            }
        }