ShouldEmissionBeEnabled() приватный статический Метод

private static ShouldEmissionBeEnabled ( Material mat, Color color ) : bool
mat UnityEngine.Material
color Color
Результат bool
        private static void SetMaterialKeywords(Material material, StandardShaderGUI.WorkflowMode workflowMode)
        {
            StandardShaderGUI.SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap") || material.GetTexture("_DetailNormalMap"));
            if (workflowMode == StandardShaderGUI.WorkflowMode.Specular)
            {
                StandardShaderGUI.SetKeyword(material, "_SPECGLOSSMAP", material.GetTexture("_SpecGlossMap"));
            }
            else if (workflowMode == StandardShaderGUI.WorkflowMode.Metallic)
            {
                StandardShaderGUI.SetKeyword(material, "_METALLICGLOSSMAP", material.GetTexture("_MetallicGlossMap"));
            }
            StandardShaderGUI.SetKeyword(material, "_PARALLAXMAP", material.GetTexture("_ParallaxMap"));
            StandardShaderGUI.SetKeyword(material, "_DETAIL_MULX2", material.GetTexture("_DetailAlbedoMap") || material.GetTexture("_DetailNormalMap"));
            bool flag = StandardShaderGUI.ShouldEmissionBeEnabled(material, material.GetColor("_EmissionColor"));

            StandardShaderGUI.SetKeyword(material, "_EMISSION", flag);
            if (material.HasProperty("_SmoothnessTextureChannel"))
            {
                StandardShaderGUI.SetKeyword(material, "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", StandardShaderGUI.GetSmoothnessMapChannel(material) == StandardShaderGUI.SmoothnessMapChannel.AlbedoAlpha);
            }
            MaterialGlobalIlluminationFlags materialGlobalIlluminationFlags = material.globalIlluminationFlags;

            if ((materialGlobalIlluminationFlags & (MaterialGlobalIlluminationFlags.RealtimeEmissive | MaterialGlobalIlluminationFlags.BakedEmissive)) != MaterialGlobalIlluminationFlags.None)
            {
                materialGlobalIlluminationFlags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
                if (!flag)
                {
                    materialGlobalIlluminationFlags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack;
                }
                material.globalIlluminationFlags = materialGlobalIlluminationFlags;
            }
        }
Пример #2
0
        private static void SetMaterialKeywords(Material material, StandardShaderGUI.WorkflowMode workflowMode)
        {
            StandardShaderGUI.SetKeyword(material, "_NORMALMAP", (bool)((UnityEngine.Object)material.GetTexture("_BumpMap")) || (bool)((UnityEngine.Object)material.GetTexture("_DetailNormalMap")));
            if (workflowMode == StandardShaderGUI.WorkflowMode.Specular)
            {
                StandardShaderGUI.SetKeyword(material, "_SPECGLOSSMAP", (bool)((UnityEngine.Object)material.GetTexture("_SpecGlossMap")));
            }
            else if (workflowMode == StandardShaderGUI.WorkflowMode.Metallic)
            {
                StandardShaderGUI.SetKeyword(material, "_METALLICGLOSSMAP", (bool)((UnityEngine.Object)material.GetTexture("_MetallicGlossMap")));
            }
            StandardShaderGUI.SetKeyword(material, "_PARALLAXMAP", (bool)((UnityEngine.Object)material.GetTexture("_ParallaxMap")));
            StandardShaderGUI.SetKeyword(material, "_DETAIL_MULX2", (bool)((UnityEngine.Object)material.GetTexture("_DetailAlbedoMap")) || (bool)((UnityEngine.Object)material.GetTexture("_DetailNormalMap")));
            bool state = StandardShaderGUI.ShouldEmissionBeEnabled(material.GetColor("_EmissionColor"));

            StandardShaderGUI.SetKeyword(material, "_EMISSION", state);
            MaterialGlobalIlluminationFlags illuminationFlags1 = material.globalIlluminationFlags;

            if ((illuminationFlags1 & (MaterialGlobalIlluminationFlags.RealtimeEmissive | MaterialGlobalIlluminationFlags.BakedEmissive)) == MaterialGlobalIlluminationFlags.None)
            {
                return;
            }
            MaterialGlobalIlluminationFlags illuminationFlags2 = illuminationFlags1 & ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;

            if (!state)
            {
                illuminationFlags2 |= MaterialGlobalIlluminationFlags.EmissiveIsBlack;
            }
            material.globalIlluminationFlags = illuminationFlags2;
        }
Пример #3
0
        private static void SetMaterialKeywords(Material material, StandardShaderGUI.WorkflowMode workflowMode)
        {
            StandardShaderGUI.SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap") || material.GetTexture("_DetailNormalMap"));
            if (workflowMode == StandardShaderGUI.WorkflowMode.Specular)
            {
                StandardShaderGUI.SetKeyword(material, "_SPECGLOSSMAP", material.GetTexture("_SpecGlossMap"));
            }
            else
            {
                if (workflowMode == StandardShaderGUI.WorkflowMode.Metallic)
                {
                    StandardShaderGUI.SetKeyword(material, "_METALLICGLOSSMAP", material.GetTexture("_MetallicGlossMap"));
                }
            }
            StandardShaderGUI.SetKeyword(material, "_PARALLAXMAP", material.GetTexture("_ParallaxMap"));
            StandardShaderGUI.SetKeyword(material, "_DETAIL_MULX2", material.GetTexture("_DetailAlbedoMap") || material.GetTexture("_DetailNormalMap"));
            bool flag = StandardShaderGUI.ShouldEmissionBeEnabled(material.GetColor("_EmissionColor"));

            StandardShaderGUI.SetKeyword(material, "_EMISSION", flag);
            MaterialGlobalIlluminationFlags materialGlobalIlluminationFlags = material.globalIlluminationFlags;

            if ((materialGlobalIlluminationFlags & (MaterialGlobalIlluminationFlags.RealtimeEmissive | MaterialGlobalIlluminationFlags.BakedEmissive)) != MaterialGlobalIlluminationFlags.None)
            {
                materialGlobalIlluminationFlags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
                if (!flag)
                {
                    materialGlobalIlluminationFlags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack;
                }
                material.globalIlluminationFlags = materialGlobalIlluminationFlags;
            }
        }
Пример #4
0
        private void DoEmissionArea(Material material)
        {
            bool flag  = this.emissionScaleUI.floatValue > 0f;
            bool flag2 = this.emissionMap.textureValue != null;

            this.m_MaterialEditor.TexturePropertySingleLine(StandardShaderGUI.Styles.emissionText, this.emissionMap, (!flag) ? null : this.emissionColorUI, this.emissionScaleUI);
            if (this.emissionMap.textureValue != null && !flag2 && this.emissionScaleUI.floatValue <= 0f)
            {
                this.emissionScaleUI.floatValue = 1f;
            }
            if (flag)
            {
                bool flag3 = StandardShaderGUI.ShouldEmissionBeEnabled(StandardShaderGUI.EvalFinalEmissionColor(material));
                EditorGUI.BeginDisabledGroup(!flag3);
                this.m_MaterialEditor.LightmapEmissionProperty(3);
                EditorGUI.EndDisabledGroup();
            }
            if (!this.HasValidEmissiveKeyword(material))
            {
                EditorGUILayout.HelpBox(StandardShaderGUI.Styles.emissiveWarning.text, MessageType.Warning);
            }
        }
Пример #5
0
        private void DoEmissionArea(Material material)
        {
            float maxColorComponent = this.emissionColorForRendering.colorValue.maxColorComponent;
            bool  flag1             = !this.HasValidEmissiveKeyword(material);
            bool  flag2             = (double)maxColorComponent > 0.0;
            bool  flag3             = (UnityEngine.Object) this.emissionMap.textureValue != (UnityEngine.Object)null;

            this.m_MaterialEditor.TexturePropertyWithHDRColor(StandardShaderGUI.Styles.emissionText, this.emissionMap, this.emissionColorForRendering, this.m_ColorPickerHDRConfig, false);
            if ((UnityEngine.Object) this.emissionMap.textureValue != (UnityEngine.Object)null && !flag3 && (double)maxColorComponent <= 0.0)
            {
                this.emissionColorForRendering.colorValue = Color.white;
            }
            if (flag2)
            {
                EditorGUI.BeginDisabledGroup(!StandardShaderGUI.ShouldEmissionBeEnabled(this.emissionColorForRendering.colorValue));
                this.m_MaterialEditor.LightmapEmissionProperty(3);
                EditorGUI.EndDisabledGroup();
            }
            if (!flag1)
            {
                return;
            }
            EditorGUILayout.HelpBox(StandardShaderGUI.Styles.emissiveWarning.text, MessageType.Warning);
        }
 private bool HasValidEmissiveKeyword(Material material)
 {
     return(material.IsKeywordEnabled("_EMISSION") || !StandardShaderGUI.ShouldEmissionBeEnabled(material, this.emissionColorForRendering.colorValue));
 }