Beispiel #1
0
        public static void LoadCommonParams(this Material self, VrmProtobuf.Material material, List <Texture> textures)
        {
            var pbr = material.PbrMetallicRoughness;

            if (pbr.BaseColorFactor.Count > 0)
            {
                self.BaseColorFactor = LinearColor.FromLiner(
                    pbr.BaseColorFactor[0],
                    pbr.BaseColorFactor[1],
                    pbr.BaseColorFactor[2],
                    pbr.BaseColorFactor[3]);
            }
            var baseColorTexture = pbr.BaseColorTexture;

            if (baseColorTexture != null && baseColorTexture.Index.TryGetValidIndex(textures.Count, out int index))
            {
                self.BaseColorTexture = new TextureInfo(textures[index]);
            }

            self.AlphaMode   = EnumUtil.Cast <VrmLib.AlphaModeType>(material.AlphaMode);
            self.AlphaCutoff = material.AlphaCutoff.HasValue
                ? material.AlphaCutoff.Value
                : 0.5f // gltf default
            ;
            self.DoubleSided = material.DoubleSided.HasValue
                ? material.DoubleSided.Value
                : false // gltf default
            ;
        }
Beispiel #2
0
        static void LoadCommonParams(this Material self, GltfMaterial material, List <Texture> textures)
        {
            var pbr = material.pbrMetallicRoughness;

            if (pbr != null)
            {
                if (pbr.baseColorFactor != null)
                {
                    self.BaseColorFactor = LinearColor.FromLiner(
                        pbr.baseColorFactor[0],
                        pbr.baseColorFactor[1],
                        pbr.baseColorFactor[2],
                        pbr.baseColorFactor[3]);
                }
                var baseColorTexture = pbr.baseColorTexture;
                if (baseColorTexture != null)
                {
                    self.BaseColorTexture = new TextureInfo(textures[baseColorTexture.index]);
                }
            }

            self.AlphaMode   = (VrmLib.AlphaModeType)material.alphaMode;
            self.AlphaCutoff = material.alphaCutoff;
            self.DoubleSided = material.doubleSided;
        }
        private static LinearColor ToLinear(GltfFormat.VrmMaterial material, string propertyName)
        {
            // TODO
            var color = material.GetColor(propertyName);

            return(LinearColor.FromLiner(color.X, color.Y, color.Z, color.W));
        }
Beispiel #4
0
        public static void LoadCommonParams(this Material self, glTFMaterial material, List <Texture> textures)
        {
            var pbr = material.pbrMetallicRoughness;

            if (pbr.baseColorFactor != null)
            {
                self.BaseColorFactor = LinearColor.FromLiner(pbr.baseColorFactor);
            }
            var baseColorTexture = pbr.baseColorTexture;

            if (baseColorTexture != null && baseColorTexture.index.TryGetValidIndex(textures.Count, out int index))
            {
                self.BaseColorTexture = new TextureInfo(textures[index]);
            }

            self.AlphaMode   = EnumUtil.Parse <VrmLib.AlphaModeType>(material.alphaMode);
            self.AlphaCutoff = material.alphaCutoff;
            self.DoubleSided = material.doubleSided;
        }