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

            var textureManager = new TextureExportManager(new Texture[] { tex0 });
            var srcMaterial    = new Material(Shader.Find("Standard"));

            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 MaterialExporter();
            var gltfMaterial     = materialExporter.ExportMaterial(srcMaterial, textureManager);

            var shaderStore      = new ShaderStore(null);
            var materialImporter = new MaterialImporter(shaderStore, (int index) => { return(null); });
            var dstMaterial      = materialImporter.CreateMaterial(0, gltfMaterial, false);

            Assert.AreEqual(dstMaterial.mainTextureOffset.x, offset.x, 0.001f);
            Assert.AreEqual(dstMaterial.mainTextureOffset.y, offset.y, 0.001f);
            Assert.AreEqual(dstMaterial.mainTextureScale.x, scale.x, 0.001f);
            Assert.AreEqual(dstMaterial.mainTextureScale.y, scale.y, 0.001f);
        }
Ejemplo n.º 2
0
        public void MaterialImportTest()
        {
            var shaderStore      = new ShaderStore(null);
            var materialImporter = new MaterialImporter(shaderStore, null);

            {
                var material = materialImporter.CreateMaterial(0, new glTFMaterial {
                }, false);
                Assert.AreEqual("Standard", material.shader.name);
            }
        }
Ejemplo n.º 3
0
 IEnumerator LoadMaterials()
 {
     using (MeasureTime("LoadMaterials"))
     {
         if (GLTF.materials == null || !GLTF.materials.Any())
         {
             AddMaterial(MaterialImporter.CreateMaterial(0, null, false));
         }
         else
         {
             for (int i = 0; i < GLTF.materials.Count; ++i)
             {
                 AddMaterial(MaterialImporter.CreateMaterial(i, GLTF.materials[i], GLTF.MaterialHasVertexColor(i)));
             }
         }
     }
     yield return(null);
 }