private static void UpdateMaterialSpecularSource(Material material) { SpecularSource specSource = (SpecularSource)material.GetFloat("_SpecSource"); if (specSource == SpecularSource.NoSpecular) { LightweightShaderHelper.SetKeyword(material, "_SPECGLOSSMAP", false); LightweightShaderHelper.SetKeyword(material, "_SPECGLOSSMAP_BASE_ALPHA", false); LightweightShaderHelper.SetKeyword(material, "_SPECULAR_COLOR", false); } else if (specSource == SpecularSource.SpecularTextureAndColor && material.GetTexture("_SpecGlossMap")) { GlossinessSource glossSource = (GlossinessSource)material.GetFloat("_GlossinessSource"); if (glossSource == GlossinessSource.BaseAlpha) { LightweightShaderHelper.SetKeyword(material, "_SPECGLOSSMAP", false); LightweightShaderHelper.SetKeyword(material, "_SPECGLOSSMAP_BASE_ALPHA", true); } else { LightweightShaderHelper.SetKeyword(material, "_SPECGLOSSMAP", true); LightweightShaderHelper.SetKeyword(material, "_SPECGLOSSMAP_BASE_ALPHA", false); } LightweightShaderHelper.SetKeyword(material, "_SPECULAR_COLOR", false); } else { LightweightShaderHelper.SetKeyword(material, "_SPECGLOSSMAP", false); LightweightShaderHelper.SetKeyword(material, "_SPECGLOSSMAP_BASE_ALPHA", false); LightweightShaderHelper.SetKeyword(material, "_SPECULAR_COLOR", true); } }
private void UpdateMaterialSpecularSource(Material material) { SpecularSource specSource = (SpecularSource)material.GetFloat("_SpecSource"); if (specSource == SpecularSource.NoSpecular) { CoreUtils.SetKeyword(material, "_SPECGLOSSMAP", false); CoreUtils.SetKeyword(material, "_SPECULAR_COLOR", false); CoreUtils.SetKeyword(material, "_GLOSSINESS_FROM_BASE_ALPHA", false); } else { GlossinessSource glossSource = (GlossinessSource)material.GetFloat("_GlossinessSource"); bool hasGlossMap = material.GetTexture("_SpecGlossMap"); CoreUtils.SetKeyword(material, "_SPECGLOSSMAP", hasGlossMap); CoreUtils.SetKeyword(material, "_SPECULAR_COLOR", !hasGlossMap); CoreUtils.SetKeyword(material, "_GLOSSINESS_FROM_BASE_ALPHA", glossSource == GlossinessSource.BaseAlpha); } }