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")); MaterialEditor.FixupEmissiveFlag(material); bool state = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == MaterialGlobalIlluminationFlags.None; StandardShaderGUI.SetKeyword(material, "_EMISSION", state); if (material.HasProperty("_SmoothnessTextureChannel")) { StandardShaderGUI.SetKeyword(material, "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", StandardShaderGUI.GetSmoothnessMapChannel(material) == StandardShaderGUI.SmoothnessMapChannel.AlbedoAlpha); } }
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; } }