示例#1
0
        public void TextureEnumerationInUnknownShader()
        {
            using (var data = GltfData.CreateFromGltfDataForTest(
                       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,
                            }
                        }
                    },
                }
            },
                       default
                       ))
            {
                var vrm = new glTF_VRM_extensions
                {
                    materialProperties = new List <glTF_VRM_Material>
                    {
                        new glTF_VRM_Material
                        {
                            shader            = "UnknownShader",
                            textureProperties = new Dictionary <string, int>
                            {
                                { "_MainTex", 0 },
                            }
                        },
                    }
                };

                // 2系統ある?
                Assert.IsTrue(VRMMToonMaterialImporter.TryCreateParam(data, vrm, 0, out VRMShaders.MaterialDescriptor matDesc));
                Assert.AreEqual(1, matDesc.TextureSlots.Count);

                var items = new VrmTextureDescriptorGenerator(data, vrm).Get().GetEnumerable().ToArray();
                Assert.AreEqual(1, items.Length);
            }
        }
示例#2
0
        public void MToonMaterialParamTest()
        {
            if (!VRMTestAssets.TryGetPath("Models/VRoid/VictoriaRubin/VictoriaRubin.vrm", out string path))
            {
                return;
            }

            var data = new GlbFileParser(path).Parse();

            var importer = new VRMImporterContext(data, null);

            Assert.AreEqual(73, data.GLTF.materials.Count);
            Assert.True(VRMMToonMaterialImporter.TryCreateParam(data, importer.VRM, 0, out MaterialDescriptor matDesc));
        }
示例#3
0
        public MaterialDescriptor Get(GltfData data, int i)
        {
            // mtoon
            if (!VRMMToonMaterialImporter.TryCreateParam(data, m_vrm, i, out MaterialDescriptor matDesc))
            {
                // unlit
                if (!GltfUnlitMaterialImporter.TryCreateParam(data, i, out matDesc))
                {
                    // pbr
                    if (!GltfPbrMaterialImporter.TryCreateParam(data, i, out matDesc))
                    {
                        // fallback
#if VRM_DEVELOP
                        Debug.LogWarning($"material: {i} out of range. fallback");
#endif
                        return(new MaterialDescriptor(GltfMaterialDescriptorGenerator.GetMaterialName(i, null), GltfPbrMaterialImporter.ShaderName));
                    }
                }
            }
            return(matDesc);
        }
示例#4
0
        public MaterialDescriptor Get(GltfData data, int i)
        {
            // legacy "VRM/UnlitTransparentZWrite"
            if (VRMUnlitTransparentZWriteMaterialImporter.TryCreateParam(data, m_vrm, i, out var matDesc))
            {
                return(matDesc);
            }

            // mtoon
            if (VRMMToonMaterialImporter.TryCreateParam(data, m_vrm, i, out matDesc))
            {
                return(matDesc);
            }

            // unlit
            if (GltfUnlitMaterialImporter.TryCreateParam(data, i, out matDesc))
            {
                return(matDesc);
            }

            // pbr
            if (GltfPbrMaterialImporter.TryCreateParam(data, i, out matDesc))
            {
                return(matDesc);
            }

            // fallback
            Debug.LogWarning($"fallback");
            return(new MaterialDescriptor(
                       GltfMaterialDescriptorGenerator.GetMaterialName(i, null),
                       GltfPbrMaterialImporter.ShaderName,
                       null,
                       new Dictionary <string, TextureDescriptor>(),
                       new Dictionary <string, float>(),
                       new Dictionary <string, Color>(),
                       new Dictionary <string, Vector4>(),
                       new Action <Material>[] {}));
        }