Example #1
0
 // Token: 0x06005013 RID: 20499 RVA: 0x001B60C0 File Offset: 0x001B44C0
 public static void MaterialChanged(Material material)
 {
     if (material.HasProperty("_Mode"))
     {
         StandardShaderHack.SetupMaterialWithBlendMode(material, (StandardShaderHack.BlendMode)material.GetInt("_Mode"));
     }
     StandardShaderHack.SetMaterialKeywords(material, StandardShaderHack.DetermineWorkflow(material));
 }
Example #2
0
        // Token: 0x06005012 RID: 20498 RVA: 0x001B5F4C File Offset: 0x001B434C
        private static void SetMaterialKeywords(Material material, StandardShaderHack.WorkflowMode workflowMode)
        {
            Texture texture = null;

            if (material.HasProperty("_BumpMap"))
            {
                texture = material.GetTexture("_BumpMap");
            }
            else if (material.HasProperty("_DetailNormalMap"))
            {
                texture = material.GetTexture("_DetailNormalMap");
            }
            if (texture != null)
            {
                StandardShaderHack.SetKeyword(material, "_NORMALMAP", texture);
            }
            if (workflowMode == StandardShaderHack.WorkflowMode.Specular)
            {
                StandardShaderHack.SetKeyword(material, "_SPECGLOSSMAP", material.GetTexture("_SpecGlossMap"));
            }
            else if (workflowMode == StandardShaderHack.WorkflowMode.Metallic)
            {
                StandardShaderHack.SetKeyword(material, "_METALLICGLOSSMAP", material.GetTexture("_MetallicGlossMap"));
            }
            if (material.HasProperty("_ParallaxMap"))
            {
                StandardShaderHack.SetKeyword(material, "_PARALLAXMAP", material.GetTexture("_ParallaxMap"));
            }
            texture = null;
            if (material.HasProperty("_DetailAlbedoMap"))
            {
                texture = material.GetTexture("_DetailAlbedoMap");
            }
            else if (material.HasProperty("_DetailNormalMap"))
            {
                texture = material.GetTexture("_DetailNormalMap");
            }
            if (texture != null)
            {
                StandardShaderHack.SetKeyword(material, "_DETAIL_MULX2", texture);
            }
            bool state = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == MaterialGlobalIlluminationFlags.None;

            StandardShaderHack.SetKeyword(material, "_EMISSION", state);
            if (material.HasProperty("_SmoothnessTextureChannel"))
            {
                StandardShaderHack.SetKeyword(material, "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", StandardShaderHack.GetSmoothnessMapChannel(material) == StandardShaderHack.SmoothnessMapChannel.AlbedoAlpha);
            }
        }
Example #3
0
 // Token: 0x06005030 RID: 20528 RVA: 0x001B6A10 File Offset: 0x001B4E10
 private Material FixMaterial(Material material, int layer = 0)
 {
     if (material == null)
     {
         return(material);
     }
     try
     {
         Shader shader = material.shader;
         material.shader = this.FixShader(material.shader, layer);
         if (this.StandardShaders.Any((Shader s) => s.name == material.shader.name))
         {
             StandardShaderHack.MaterialChanged(material);
         }
     }
     catch (Exception ex)
     {
         Debug.LogError("Encountered an exception when fixing material " + material.name + ":\n" + ex.ToString());
     }
     return(material);
 }