|
|
|
|
|
|
using System; |
|
|
|
using UnityEditor.Experimental.Rendering.LightweightPipeline; |
|
|
|
using UnityEngine; |
|
|
|
|
|
|
|
namespace UnityEditor |
|
|
|
|
|
|
{ |
|
|
|
// Note: keywords must be based on Material value not on MaterialProperty due to multi-edit & material animation
|
|
|
|
// (MaterialProperty value might come from renderer material property block)
|
|
|
|
SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap") || material.GetTexture("_DetailNormalMap")); |
|
|
|
LightweightShaderHelper.SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap") || material.GetTexture("_DetailNormalMap")); |
|
|
|
SetKeyword(material, "_SPECULAR_SETUP", workflowMode == WorkflowMode.Specular); |
|
|
|
SetKeyword(material, "_METALLIC_SETUP", workflowMode == WorkflowMode.Metallic); |
|
|
|
SetKeyword(material, "_PARALLAXMAP", material.GetTexture("_ParallaxMap")); |
|
|
|
SetKeyword(material, "_DETAIL_MULX2", material.GetTexture("_DetailAlbedoMap") || material.GetTexture("_DetailNormalMap")); |
|
|
|
LightweightShaderHelper.SetKeyword(material, "_SPECULAR_SETUP", workflowMode == WorkflowMode.Specular); |
|
|
|
LightweightShaderHelper.SetKeyword(material, "_METALLIC_SETUP", workflowMode == WorkflowMode.Metallic); |
|
|
|
LightweightShaderHelper.SetKeyword(material, "_METALLICSPECGLOSSMAP", material.GetTexture("_MetallicSpecGlossMap") != null); |
|
|
|
LightweightShaderHelper.SetKeyword(material, "_PARALLAXMAP", material.GetTexture("_ParallaxMap")); |
|
|
|
LightweightShaderHelper.SetKeyword(material, "_DETAIL_MULX2", material.GetTexture("_DetailAlbedoMap") || material.GetTexture("_DetailNormalMap")); |
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
|
|
SetKeyword(material, "_EMISSION", shouldEmissionBeEnabled); |
|
|
|
LightweightShaderHelper.SetKeyword(material, "_EMISSION", shouldEmissionBeEnabled); |
|
|
|
SetKeyword(material, "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", GetSmoothnessMapChannel(material) == SmoothnessMapChannel.AlbedoAlpha); |
|
|
|
LightweightShaderHelper.SetKeyword(material, "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", GetSmoothnessMapChannel(material) == SmoothnessMapChannel.AlbedoAlpha); |
|
|
|
material.shaderKeywords = null; |
|
|
|
|
|
|
|
static void SetKeyword(Material m, string keyword, bool state) |
|
|
|
{ |
|
|
|
if (state) |
|
|
|
m.EnableKeyword(keyword); |
|
|
|
else |
|
|
|
m.DisableKeyword(keyword); |
|
|
|
} |
|
|
|
} // namespace UnityEditor
|
|
|
|
} |