/// <summary> /// Initializes a new instance of the <see cref="UFLT.Utils.IntermediateMaterial"/> class. /// </summary> /// <param name='bank'>Material bank, used for finding materials.</param> /// <param name='mp'>Material palette or null.</param> /// <param name='main'>Main texture or null.</param> /// <param name='detail'>Detail texture or null.</param> /// <param name='transparancy'>Transparancy</param> /// <param name='lm'>Light mode.</param> public IntermediateMaterial(MaterialBank bank, MaterialPalette mp, TexturePalette main, TexturePalette detail, ushort transparancy, LightMode lm) { MaterialBank = bank; Palette = mp; MainTexture = main; DetailTexture = detail; Transparency = transparancy; LightMode = lm; }
/// <summary> /// Creates the unity material. /// </summary> protected virtual Material CreateUnityMaterial() { Material mat = new Material(Shader.Find("Universal Render Pipeline/Simple Lit")); mat.SetColor("_BaseColor", Color.white); Texture2D texture = null; if (MainTexture != null) { texture = MaterialBank.FindOrCreateTexture(MainTexture); } bool textureTransparent = texture != null && (texture.format == TextureFormat.Alpha8 || texture.format == TextureFormat.ARGB32 || texture.format == TextureFormat.ARGB4444 || texture.format == TextureFormat.RGBA32 || texture.format == TextureFormat.RGBA4444 || texture.format == TextureFormat.DXT5 || texture.format == TextureFormat.DXT5Crunched); if (textureTransparent) { mat.EnableKeyword("_ALPHATEST_ON"); } if (Palette != null) { mat.color = Palette.Diffuse; if (mat.HasProperty("_Emissive")) // Emissive color of a material (used in vertexlit shaders). { mat.SetColor("_Emissive", Palette.Emissive); } if (mat.HasProperty("_SpecColor")) { mat.SetColor("_SpecColor", Palette.Specular); } if (mat.HasProperty("_Shininess")) { mat.SetFloat("_Shininess", Palette.Shininess / 128f); } } if (mat.HasProperty("_BaseMap")) { if (texture != null) { mat.SetTexture("_BaseMap", texture); mat.name = texture.name; } else if (MainTexture != null) { mat.name = MainTexture.FileName; } } // DuckbearLab: FIX! It is not used now :D /*if (Palette != null) * { * mat.name = Palette.ID; * }*/ return(mat); }