Ejemplo n.º 1
0
        public static Material WithPBRMetallicRoughness(
            this Material material,
            Vector4 baseColor,
            string baseColorImageFilePath,
            string metallicImageFilePath = null,
            float metallicFactor         = 1,
            float roughnessFactor        = 1
            )
        {
            material.WithPBRMetallicRoughness();

            material.WithChannelParameter("BaseColor", baseColor);
            material.WithChannelParameter("MetallicRoughness", new Vector4(metallicFactor, roughnessFactor, 0, 0));

            if (!string.IsNullOrWhiteSpace(baseColorImageFilePath))
            {
                material.WithChannelTexture("BaseColor", 0, baseColorImageFilePath);
            }
            if (!string.IsNullOrWhiteSpace(metallicImageFilePath))
            {
                material.WithChannelTexture("Metallic", 0, baseColorImageFilePath);
            }

            return(material);
        }
Ejemplo n.º 2
0
        public static Material WithPBRMetallicRoughness(
            this Material material,
            Vector4 baseColorFactor, string baseColorImageFilePath,
            float metallicFactor  = 1, string metallicImageFilePath   = null,
            float roughnessFactor = 1, string roughtnessImageFilePath = null
            )
        {
            material.WithPBRMetallicRoughness();

            if (!string.IsNullOrWhiteSpace(baseColorImageFilePath))
            {
                material.WithChannelTexture("BaseColor", 0, baseColorImageFilePath);
            }
            if (!string.IsNullOrWhiteSpace(metallicImageFilePath))
            {
                material.WithChannelTexture("Metallic", 0, baseColorImageFilePath);
            }
            if (!string.IsNullOrWhiteSpace(roughtnessImageFilePath))
            {
                material.WithChannelTexture("Roughness", 0, baseColorImageFilePath);
            }

            material.FindChannel("BaseColor").SetFactor(baseColorFactor);
            material.FindChannel("Metallic").SetFactor(metallicFactor);
            material.FindChannel("Roughness").SetFactor(roughnessFactor);

            return(material);
        }
Ejemplo n.º 3
0
        public static Material WithPBRMetallicRoughness(
            this Material material,
            Vector4 baseColor,
            string baseColorImageFilePath,
            string metallicImageFilePath = null,
            float metallicFactor         = 1,
            float roughnessFactor        = 1
            )
        {
            Guard.NotNull(material, nameof(material));

            material
            .WithPBRMetallicRoughness()
            .WithChannelColor("BaseColor", baseColor)
            .WithChannelFactor("MetallicRoughness", "MetallicFactor", metallicFactor)
            .WithChannelFactor("MetallicRoughness", "RoughnessFactor", roughnessFactor);

            if (!string.IsNullOrWhiteSpace(baseColorImageFilePath))
            {
                material.WithChannelTexture("BaseColor", 0, baseColorImageFilePath);
            }
            if (!string.IsNullOrWhiteSpace(metallicImageFilePath))
            {
                material.WithChannelTexture("Metallic", 0, baseColorImageFilePath);
            }

            return(material);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes this <see cref="Material"/> instance with default material attributes.
        /// </summary>
        /// <param name="material">The <see cref="Material"/> instance to set.</param>
        /// <param name="diffuseColor">A <see cref="Vector4"/> color where X=Red, Y=Green, Z=Blue, W=Alpha.</param>
        /// <returns>This <see cref="Material"/> instance.</returns>
        public static Material WithDefault(this Material material, Vector4 diffuseColor)
        {
            var ch = material.WithPBRMetallicRoughness().FindChannel("BaseColor").Value;

            ch.Parameter = diffuseColor;

            return(material);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes this <see cref="Material"/> instance with default material attributes.
        /// </summary>
        /// <param name="material">The <see cref="Material"/> instance to set.</param>
        /// <param name="diffuseColor">A <see cref="Vector4"/> color where X=Red, Y=Green, Z=Blue, W=Alpha.</param>
        /// <returns>This <see cref="Material"/> instance.</returns>
        public static Material WithDefault(this Material material, Vector4 diffuseColor)
        {
            material.WithPBRMetallicRoughness()
            .FindChannel("BaseColor")
            .SetFactor(diffuseColor);

            return(material);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes this <see cref="Material"/> instance with default material attributes.
        /// </summary>
        /// <param name="material">The <see cref="Material"/> instance to set.</param>
        /// <param name="diffuseColor">A <see cref="Vector4"/> color where X=Red, Y=Green, Z=Blue, W=Alpha.</param>
        /// <returns>This <see cref="Material"/> instance.</returns>
        public static Material WithDefault(this Material material, Vector4 diffuseColor)
        {
            Guard.NotNull(material, nameof(material));

            var ch = material.WithPBRMetallicRoughness().FindChannel("BaseColor").Value;

            ch.Color = diffuseColor;

            return(material);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes this <see cref="Material"/> instance with default material attributes.
        /// </summary>
        /// <param name="material">The <see cref="Material"/> instance to set.</param>
        /// <returns>This <see cref="Material"/> instance.</returns>
        public static Material WithDefault(this Material material)
        {
            Guard.NotNull(material, nameof(material));

            return(material.WithPBRMetallicRoughness());
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes this <see cref="Material"/> instance with default material attributes.
 /// </summary>
 /// <param name="material">The <see cref="Material"/> instance to set.</param>
 /// <returns>This <see cref="Material"/> instance.</returns>
 public static Material WithDefault(this Material material)
 {
     return(material.WithPBRMetallicRoughness());
 }