示例#1
0
        public void TextureTransformTest()
        {
            var tex0 = new Texture2D(128, 128)
            {
                wrapMode   = TextureWrapMode.Repeat,
                filterMode = FilterMode.Bilinear,
            };

            var textureManager = new TextureExporter();
            var srcMaterial    = new Material(Shader.Find("VRM/MToon"));

            var offset = new Vector2(0.3f, 0.2f);
            var scale  = new Vector2(0.5f, 0.6f);

            srcMaterial.mainTexture       = tex0;
            srcMaterial.mainTextureOffset = offset;
            srcMaterial.mainTextureScale  = scale;

            var materialExporter = new VRMMaterialExporter();
            var vrmMaterial      = VRMMaterialExporter.CreateFromMaterial(srcMaterial, textureManager);

            Assert.AreEqual(vrmMaterial.vectorProperties["_MainTex"], new float[] { 0.3f, 0.2f, 0.5f, 0.6f });

            var materialImporter = new VRMMaterialImporter(new System.Collections.Generic.List <glTF_VRM_Material> {
                vrmMaterial
            });
        }
示例#2
0
        public void MaterialImporterTest()
        {
            var parser = new GltfParser();

            parser.ParsePath(AliciaPath);
            var vrmImporter   = new VRMImporterContext(parser, null);
            var materialParam = new VRMMaterialImporter(vrmImporter.VRM).GetMaterialParam(parser, 0);

            Assert.AreEqual("VRM/MToon", materialParam.ShaderName);
            Assert.AreEqual("Alicia_body", materialParam.TextureSlots["_MainTex"].UnityObjectName);

            var(key, value) = materialParam.EnumerateSubAssetKeyValue().First();
            Assert.AreEqual(new SubAssetKey(typeof(Texture2D), "Alicia_body"), key);
        }
示例#3
0
        public void MToonMaterialParamTest()
        {
            if (!VRMTestAssets.TryGetPath("Models/VRoid/VictoriaRubin/VictoriaRubin.vrm", out string path))
            {
                return;
            }

            var parser = new GltfParser();

            parser.ParsePath(path);

            var importer = new VRMImporterContext(parser, null);

            var materialImporter = new VRMMaterialImporter(importer.VRM);

            Assert.AreEqual(73, parser.GLTF.materials.Count);
            Assert.True(materialImporter.TryCreateParam(parser, 0, out MaterialImportParam param));
        }
示例#4
0
 public void TextureEnumerationTest()
 {
     {
         var parser = new GltfParser
         {
             GLTF = new glTF
             {
                 images = new List <glTFImage>
                 {
                     new glTFImage {
                         mimeType = "image/png",
                     }
                 },
                 textures = new List <glTFTexture>
                 {
                     new glTFTexture {
                         name   = "texture0",
                         source = 0,
                     }
                 },
                 materials = new List <glTFMaterial>
                 {
                     new glTFMaterial {
                         pbrMetallicRoughness = new glTFPbrMetallicRoughness {
                             baseColorTexture = new glTFMaterialBaseColorTextureInfo {
                                 index = 0,
                             }
                         }
                     },
                     new glTFMaterial {
                         pbrMetallicRoughness = new glTFPbrMetallicRoughness {
                             baseColorTexture = new glTFMaterialBaseColorTextureInfo {
                                 index = 0,
                             }
                         }
                     },
                 }
             }
         };
         var vrm = new glTF_VRM_extensions
         {
             materialProperties = new List <glTF_VRM_Material>
             {
                 new glTF_VRM_Material
                 {
                     textureProperties = new Dictionary <string, int>
                     {
                         { "_MainTex", 0 },
                     }
                 },
                 new glTF_VRM_Material
                 {
                     textureProperties = new Dictionary <string, int>
                     {
                         { "_MainTex", 0 },
                     }
                 },
             }
         };
         var items = new VRMMaterialImporter(vrm).EnumerateAllTexturesDistinct(parser).ToArray();
         Assert.AreEqual(1, items.Length);
     }
 }