public static void SetMaterialKeywords(this Material material, Texture.TextureType texType, bool isMetal = false)
        {
            material.SetKeyword("_NORMALMAP", material.GetTexture("_BumpMap") || material.GetTexture("_DetailNormalMap"));
            if (texType == Texture.TextureType.Specular)
            {
                material.SetKeyword("_SPECGLOSSMAP", material.GetTexture("_SpecGlossMap"));
            }
            else if (texType == Texture.TextureType.Specular && isMetal)
            {
                material.SetKeyword("_METALLICGLOSSMAP", material.GetTexture("_MetallicGlossMap"));
            }

            material.SetKeyword("_PARALLAXMAP", material.GetTexture("_ParallaxMap"));
            material.SetKeyword("_DETAIL_MULX2", material.GetTexture("_DetailAlbedoMap") || material.GetTexture("_DetailNormalMap"));
            material.FixupEmissiveFlag();
            bool state = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == MaterialGlobalIlluminationFlags.None;

            material.SetKeyword("_EMISSION", state);
            if (material.HasProperty("_SmoothnessTextureChannel"))
            {
                material.SetKeyword("_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", material.GetSmoothnessMapChannel() == 1 /*SmoothnessMapChannel.AlbedoAlpha*/);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Method to add a texture to the set of textures of current material
 /// Note the texture type is used as an index into the array of textures
 /// </summary>
 /// <param name="type">The type of the texture</param>
 /// <param name="texture">The texture</param>
 public void SetTexture(Texture.TextureType type, Texture texture)
 {
     textures[(int)type] = texture;
 }