Пример #1
0
        public void TextureTransformTest()
        {
            var tex0 = new Texture2D(128, 128)
            {
                wrapMode   = TextureWrapMode.Repeat,
                filterMode = FilterMode.Bilinear,
            };

            var textureManager = new TextureExporter(AssetTextureUtil.IsTextureEditorAsset);
            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 VRMMtoonMaterialImporter(new glTF_VRM_extensions
            {
                materialProperties = new System.Collections.Generic.List <glTF_VRM_Material> {
                    vrmMaterial
                }
            });
        }
Пример #2
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 {
                         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 VRMMtoonMaterialImporter(vrm).EnumerateAllTexturesDistinct(parser).ToArray();
         Assert.AreEqual(1, items.Length);
     }
 }