Exemple #1
0
        static VrmProtobuf.Material ToGltf(this VrmLib.Material src, string name, List <Texture> textures)
        {
            var material = new VrmProtobuf.Material
            {
                Name       = name,
                Extensions = new VrmProtobuf.Material.Types.Extensions
                {
                    KHRMaterialsUnlit = new VrmProtobuf.KHR_materials_unlit(),
                },
                PbrMetallicRoughness = new VrmProtobuf.MaterialPbrMetallicRoughness
                {
                },
                AlphaMode   = src.AlphaMode.ToString(),
                AlphaCutoff = src.AlphaCutoff,
                DoubleSided = src.DoubleSided,
            };

            src.BaseColorFactor.ToProtobuf(material.PbrMetallicRoughness.BaseColorFactor.Add, true);
            if (src.BaseColorTexture != null)
            {
                material.PbrMetallicRoughness.BaseColorTexture = new VrmProtobuf.TextureInfo
                {
                    Index = textures.IndexOfNullable(src.BaseColorTexture.Texture),
                };
            }
            return(material);
        }
Exemple #2
0
        static VrmProtobuf.Material ToGltf(this VrmLib.Material src, List <Texture> textures)
        {
            var material = new VrmProtobuf.Material
            {
                Name = src.Name,
                PbrMetallicRoughness = new VrmProtobuf.MaterialPBRMetallicRoughness
                {
                },
                AlphaMode   = EnumUtil.Cast <VrmProtobuf.Material.Types.alphaModeType>(src.AlphaMode),
                AlphaCutoff = src.AlphaCutoff,
                DoubleSided = src.DoubleSided,
            };

            src.BaseColorFactor.ToProtobuf(material.PbrMetallicRoughness.BaseColorFactor.Add, true);
            if (src.BaseColorTexture != null)
            {
                material.PbrMetallicRoughness.BaseColorTexture = new VrmProtobuf.TextureInfo
                {
                    Index = textures.IndexOfNullable(src.BaseColorTexture.Texture),
                };
            }
            return(material);
        }
Exemple #3
0
        static glTFMaterial ToGltf(this VrmLib.Material src, List <Texture> textures)
        {
            var material = new glTFMaterial
            {
                name = src.Name,
                pbrMetallicRoughness = new glTFPbrMetallicRoughness
                {
                    baseColorFactor = src.BaseColorFactor.ToFloat4(),
                },
                alphaMode   = CastAlphaMode(src.AlphaMode),
                alphaCutoff = src.AlphaCutoff,
                doubleSided = src.DoubleSided,
            };

            if (src.BaseColorTexture != null)
            {
                material.pbrMetallicRoughness.baseColorTexture = new glTFMaterialBaseColorTextureInfo
                {
                    index = textures.IndexOfNullable(src.BaseColorTexture.Texture).Value,
                };
            }
            return(material);
        }