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); } }
public static void UpdateStandardSpecularMaterialKeywords(Material material) { material.SetFloat("_WorkflowMode", 0.0f); LightweightShaderHelper.SetKeyword(material, "_OCCLUSIONMAP", material.GetTexture("_OcclusionMap")); LightweightShaderHelper.SetKeyword(material, "_METALLICSPECGLOSSMAP", material.GetTexture("_SpecGlossMap")); LightweightShaderHelper.SetKeyword(material, "_SPECULAR_SETUP", true); }
public static void UpdateMaterialKeywords(Material material) { LightweightShaderHelper.SetMaterialBlendMode(material); UpdateMaterialSpecularSource(material); UpdateMaterialReflectionSource(material); LightweightShaderHelper.SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap")); LightweightShaderHelper.SetKeyword(material, "_CUBEMAP_REFLECTION", material.GetTexture("_Cube")); LightweightShaderHelper.SetKeyword(material, "_EMISSION", material.GetTexture("_EmissionMap")); }
public static void UpdateMaterialKeywords(Material material) { material.shaderKeywords = null; LightweightShaderHelper.SetMaterialBlendMode(material); UpdateMaterialSpecularSource(material); LightweightShaderHelper.SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap")); // A material's GI flag internally keeps track of whether emission is enabled at all, it's enabled but has no effect // or is enabled and may be modified at runtime. This state depends on the values of the current flag and emissive color. // The fixup routine makes sure that the material is in the correct state if/when changes are made to the mode or color. MaterialEditor.FixupEmissiveFlag(material); bool shouldEmissionBeEnabled = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == 0; LightweightShaderHelper.SetKeyword(material, "_EMISSION", shouldEmissionBeEnabled); }
private static void UpdateMaterialReflectionSource(Material material) { LightweightShaderHelper.SetKeyword(material, "_REFLECTION_CUBEMAP", false); LightweightShaderHelper.SetKeyword(material, "_REFLECTION_PROBE", false); ReflectionSource reflectionSource = (ReflectionSource)material.GetFloat("_ReflectionSource"); if (reflectionSource == ReflectionSource.Cubemap && material.GetTexture("_Cube")) { LightweightShaderHelper.SetKeyword(material, "_REFLECTION_CUBEMAP", true); } else if (reflectionSource == ReflectionSource.ReflectionProbe) { LightweightShaderHelper.SetKeyword(material, "_REFLECTION_PROBE", true); } }
private static void UpdateMaterialSpecularSource(Material material) { SpecularSource specSource = (SpecularSource)material.GetFloat("_SpecSource"); if (specSource == SpecularSource.NoSpecular) { LightweightShaderHelper.SetKeyword(material, "_SPECGLOSSMAP", false); LightweightShaderHelper.SetKeyword(material, "_SPECULAR_COLOR", false); LightweightShaderHelper.SetKeyword(material, "_GLOSSINESS_FROM_BASE_ALPHA", false); } else { GlossinessSource glossSource = (GlossinessSource)material.GetFloat("_GlossinessSource"); bool hasGlossMap = material.GetTexture("_SpecGlossMap"); LightweightShaderHelper.SetKeyword(material, "_SPECGLOSSMAP", hasGlossMap); LightweightShaderHelper.SetKeyword(material, "_SPECULAR_COLOR", !hasGlossMap); LightweightShaderHelper.SetKeyword(material, "_GLOSSINESS_FROM_BASE_ALPHA", glossSource == GlossinessSource.BaseAlpha); } }
public static void UpdateStandardMaterialKeywords(Material material) { material.SetFloat("_WorkflowMode", 1.0f); LightweightShaderHelper.SetKeyword(material, "_OCCLUSIONMAP", material.GetTexture("_OcclusionMap")); LightweightShaderHelper.SetKeyword(material, "_METALLICSPECGLOSSMAP", material.GetTexture("_MetallicGlossMap")); }