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

            var textureExporter = new TextureExporter(new EditorTextureSerializer());
            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, textureExporter);

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

            var materialImporter = new VRMMaterialDescriptorGenerator(new glTF_VRM_extensions
            {
                materialProperties = new System.Collections.Generic.List <glTF_VRM_Material> {
                    vrmMaterial
                }
            });
        }
Esempio n. 2
0
        public void MaterialImporterTest()
        {
            var path          = AliciaPath;
            var data          = new GlbFileParser(path).Parse();
            var vrmImporter   = new VRMImporterContext(data, null);
            var materialParam = new VRMMaterialDescriptorGenerator(vrmImporter.VRM).Get(data, 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(Texture), "Alicia_body"), key);
        }
Esempio n. 3
0
 public VRMImporterContext(
     GltfData data,
     IReadOnlyDictionary <SubAssetKey, Object> externalObjectMap = null,
     ITextureDeserializer textureDeserializer = null)
     : base(data, externalObjectMap, textureDeserializer)
 {
     // parse VRM part
     if (glTF_VRM_extensions.TryDeserialize(GLTF.extensions, out glTF_VRM_extensions vrm))
     {
         VRM = vrm;
         TextureDescriptorGenerator  = new VrmTextureDescriptorGenerator(Data, VRM);
         MaterialDescriptorGenerator = new VRMMaterialDescriptorGenerator(VRM);
     }
     else
     {
         throw new NotVrm0Exception();
     }
 }