public void FindProperties(MaterialProperty[] props) { this.blendMode = ShaderGUI.FindProperty("_Mode", props); this.albedoMap = ShaderGUI.FindProperty("_MainTex", props); this.albedoColor = ShaderGUI.FindProperty("_Color", props); this.alphaCutoff = ShaderGUI.FindProperty("_Cutoff", props); this.specularMap = ShaderGUI.FindProperty("_SpecGlossMap", props, false); this.specularColor = ShaderGUI.FindProperty("_SpecColor", props, false); this.metallicMap = ShaderGUI.FindProperty("_MetallicGlossMap", props, false); this.metallic = ShaderGUI.FindProperty("_Metallic", props, false); this.m_WorkflowMode = this.specularMap == null || this.specularColor == null ? (this.metallicMap == null || this.metallic == null ? StandardShaderGUI.WorkflowMode.Dielectric : StandardShaderGUI.WorkflowMode.Metallic) : StandardShaderGUI.WorkflowMode.Specular; this.smoothness = ShaderGUI.FindProperty("_Glossiness", props); this.bumpScale = ShaderGUI.FindProperty("_BumpScale", props); this.bumpMap = ShaderGUI.FindProperty("_BumpMap", props); this.heigtMapScale = ShaderGUI.FindProperty("_Parallax", props); this.heightMap = ShaderGUI.FindProperty("_ParallaxMap", props); this.occlusionStrength = ShaderGUI.FindProperty("_OcclusionStrength", props); this.occlusionMap = ShaderGUI.FindProperty("_OcclusionMap", props); this.emissionColorForRendering = ShaderGUI.FindProperty("_EmissionColor", props); this.emissionMap = ShaderGUI.FindProperty("_EmissionMap", props); this.detailMask = ShaderGUI.FindProperty("_DetailMask", props); this.detailAlbedoMap = ShaderGUI.FindProperty("_DetailAlbedoMap", props); this.detailNormalMapScale = ShaderGUI.FindProperty("_DetailNormalMapScale", props); this.detailNormalMap = ShaderGUI.FindProperty("_DetailNormalMap", props); this.uvSetSecondary = ShaderGUI.FindProperty("_UVSec", props); }
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; } }
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; }
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; } }
private static void MaterialChanged(Material material, StandardShaderGUI.WorkflowMode workflowMode) { if (material.GetFloat("_EmissionScaleUI") < 0f) { material.SetFloat("_EmissionScaleUI", 0f); } Color color = StandardShaderGUI.EvalFinalEmissionColor(material); material.SetColor("_EmissionColor", color); StandardShaderGUI.SetupMaterialWithBlendMode(material, (StandardShaderGUI.BlendMode)material.GetFloat("_Mode")); StandardShaderGUI.SetMaterialKeywords(material, workflowMode); }
internal void DetermineWorkflow(MaterialProperty[] props) { if (ShaderGUI.FindProperty("_SpecGlossMap", props, false) != null && ShaderGUI.FindProperty("_SpecColor", props, false) != null) { this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Specular; } else if (ShaderGUI.FindProperty("_MetallicGlossMap", props, false) != null && ShaderGUI.FindProperty("_Metallic", props, false) != null) { this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Metallic; } else { this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Dielectric; } }
public void FindProperties(MaterialProperty[] props) { this.blendMode = ShaderGUI.FindProperty("_Mode", props); this.albedoMap = ShaderGUI.FindProperty("_MainTex", props); this.albedoColor = ShaderGUI.FindProperty("_Color", props); this.alphaCutoff = ShaderGUI.FindProperty("_Cutoff", props); this.specularMap = ShaderGUI.FindProperty("_SpecGlossMap", props, false); this.specularColor = ShaderGUI.FindProperty("_SpecColor", props, false); this.metallicMap = ShaderGUI.FindProperty("_MetallicGlossMap", props, false); this.metallic = ShaderGUI.FindProperty("_Metallic", props, false); if (this.specularMap != null && this.specularColor != null) { this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Specular; } else if (this.metallicMap != null && this.metallic != null) { this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Metallic; } else { this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Dielectric; } this.smoothness = ShaderGUI.FindProperty("_Glossiness", props); this.smoothnessScale = ShaderGUI.FindProperty("_GlossMapScale", props, false); this.smoothnessMapChannel = ShaderGUI.FindProperty("_SmoothnessTextureChannel", props, false); this.highlights = ShaderGUI.FindProperty("_SpecularHighlights", props, false); this.reflections = ShaderGUI.FindProperty("_GlossyReflections", props, false); this.bumpScale = ShaderGUI.FindProperty("_BumpScale", props); this.bumpMap = ShaderGUI.FindProperty("_BumpMap", props); this.heigtMapScale = ShaderGUI.FindProperty("_Parallax", props); this.heightMap = ShaderGUI.FindProperty("_ParallaxMap", props); this.occlusionStrength = ShaderGUI.FindProperty("_OcclusionStrength", props); this.occlusionMap = ShaderGUI.FindProperty("_OcclusionMap", props); this.emissionColorForRendering = ShaderGUI.FindProperty("_EmissionColor", props); this.emissionMap = ShaderGUI.FindProperty("_EmissionMap", props); this.detailMask = ShaderGUI.FindProperty("_DetailMask", props); this.detailAlbedoMap = ShaderGUI.FindProperty("_DetailAlbedoMap", props); this.detailNormalMapScale = ShaderGUI.FindProperty("_DetailNormalMapScale", props); this.detailNormalMap = ShaderGUI.FindProperty("_DetailNormalMap", props); this.uvSetSecondary = ShaderGUI.FindProperty("_UVSec", props); }
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 MaterialChanged(Material material, StandardShaderGUI.WorkflowMode workflowMode) { StandardShaderGUI.SetupMaterialWithBlendMode(material, (StandardShaderGUI.BlendMode)material.GetFloat("_Mode")); StandardShaderGUI.SetMaterialKeywords(material, workflowMode); }
internal void DetermineWorkflow(MaterialProperty[] props) { if (ShaderGUI.FindProperty("_SpecGlossMap", props, false) != null && ShaderGUI.FindProperty("_SpecColor", props, false) != null) this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Specular; else if (ShaderGUI.FindProperty("_MetallicGlossMap", props, false) != null && ShaderGUI.FindProperty("_Metallic", props, false) != null) this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Metallic; else this.m_WorkflowMode = StandardShaderGUI.WorkflowMode.Dielectric; }