From 2e3a60f81efd4e45d3fd9bc44a2dcc23207fce2d Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Sun, 28 Jul 2024 19:23:07 +0900 Subject: [PATCH 01/16] Ignore using Task.Wait() --- .../Runtime/UniGLTF/IO/ImporterContext.cs | 4 +- .../IO/MaterialIO/Import/MaterialFactory.cs | 33 ++++++++-------- .../Runtime/UniGLTF/IO/MeshIO/MeshUploader.cs | 10 ++++- Assets/VRM10/Runtime/IO/Vrm10Importer.cs | 39 ++++++++++--------- 4 files changed, 47 insertions(+), 39 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs index 967fb0c07..d7c56f709 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs @@ -307,7 +307,7 @@ namespace UniGLTF using (MeasureTime("BuildMesh")) { var meshWithMaterials = await MeshUploader.BuildMeshAndUploadAsync(awaitCaller, meshData, - (int? materialIndex) => + async materialIndex => { if (materialIndex.HasValidIndex()) { @@ -315,7 +315,7 @@ namespace UniGLTF } else { - return MaterialFactory.DefaultMaterial; + return await MaterialFactory.GetDefaultMaterialAsync(awaitCaller); } }); var mesh = meshWithMaterials.Mesh; diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialFactory.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialFactory.cs index f54b4d160..ccf38deb0 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialFactory.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialFactory.cs @@ -11,28 +11,17 @@ namespace UniGLTF { private readonly IReadOnlyDictionary m_externalMap; - MaterialDescriptor m_defaultMaterialParams; + /// + /// デフォルトマテリアルの MaterialDescriptor は IMaterialDescriptorGenerator の実装によって異なるので外から渡す + /// + private readonly MaterialDescriptor m_defaultMaterialParams; /// /// gltfPritmitive.material が無い場合のデフォルトマテリアル /// https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#default-material + /// /// - Material m_defaultMaterial; - - public Material DefaultMaterial - { - get - { - if (m_defaultMaterial == null) - { - // default material にバリエーションがある? - var task = LoadAsync(m_defaultMaterialParams, (_x, _y) => Task.FromResult(null), new ImmediateCaller()); - task.Wait(); - m_defaultMaterial = task.Result; - } - return m_defaultMaterial; - } - } + private Material m_defaultMaterial; public MaterialFactory(IReadOnlyDictionary externalMaterialMap, MaterialDescriptor defaultMaterialParams) { @@ -110,6 +99,16 @@ namespace UniGLTF return m_materials[index].Asset; } + public async Task GetDefaultMaterialAsync(IAwaitCaller awaitCaller) + { + if (m_defaultMaterial == null) + { + m_defaultMaterial = await LoadAsync(m_defaultMaterialParams, (_, _) => null, awaitCaller); + } + return m_defaultMaterial; + } + + public async Task LoadAsync(MaterialDescriptor matDesc, GetTextureAsyncFunc getTexture, IAwaitCaller awaitCaller) { if (m_externalMap.TryGetValue(matDesc.SubAssetKey, out Material material)) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshUploader.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshUploader.cs index 337e30af9..98450f1c9 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshUploader.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshUploader.cs @@ -89,7 +89,7 @@ namespace UniGLTF public static async Task BuildMeshAndUploadAsync( IAwaitCaller awaitCaller, MeshData data, - Func materialFromIndex) + Func> materialFromIndex) { //Debug.Log(prims.ToJson()); @@ -117,10 +117,16 @@ namespace UniGLTF mesh.RecalculateTangents(); await awaitCaller.NextFrame(); + var materials = new Material[data.MaterialIndices.Count]; + for (var idx = 0; idx < data.MaterialIndices.Count; ++idx) + { + materials[idx] = await materialFromIndex(data.MaterialIndices[idx]); + } + var result = new MeshWithMaterials { Mesh = mesh, - Materials = data.MaterialIndices.Select(materialFromIndex).ToArray(), + Materials = materials, ShouldSetRendererNodeAsBone = data.ShouldSetRendererNodeAsBone, }; await awaitCaller.NextFrame(); diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs index 6fb7d0a1f..96918786d 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs @@ -238,7 +238,7 @@ namespace UniVRM10 continue; } - CreateRenderer(node, go, map, MaterialFactory); + await CreateRendererAsync(node, go, map, MaterialFactory, awaitCaller); await awaitCaller.NextFrame(); } } @@ -799,7 +799,7 @@ namespace UniVRM10 /// /// MeshFilter + MeshRenderer もしくは SkinnedMeshRenderer を構築する /// - public static Renderer CreateRenderer(VrmLib.Node node, GameObject go, ModelMap map, MaterialFactory materialFactory) + public static async Task CreateRendererAsync(VrmLib.Node node, GameObject go, ModelMap map, MaterialFactory materialFactory, IAwaitCaller awaitCaller) { Renderer renderer = null; var hasBlendShape = node.MeshGroup.Meshes[0].MorphTargets.Any(); @@ -833,35 +833,38 @@ namespace UniVRM10 } else if (node.MeshGroup.Meshes.Count == 1) { - var materials = node.MeshGroup.Meshes[0].Submeshes.Select( - x => + var materialCount = node.MeshGroup.Meshes[0].Submeshes.Count; + var materials = new Material[materialCount]; + for (var idx = 0; idx < materialCount; ++idx) + { + var materialIndex = node.MeshGroup.Meshes[0].Submeshes[idx].Material; + if (materialIndex.HasValidIndex()) { - if (x.Material.HasValidIndex()) - { - return materialFactory.Materials[x.Material.Value].Asset; - } - else - { - return materialFactory.DefaultMaterial; - } + materials[idx] = materialFactory.Materials[materialIndex.Value].Asset; } - ).ToArray(); + else + { + materials[idx] = await materialFactory.GetDefaultMaterialAsync(awaitCaller); + } + } renderer.sharedMaterials = materials; } else { - var materials = node.MeshGroup.Meshes.Select(x => + var materialCount = node.MeshGroup.Meshes.Count; + var materials = new Material[materialCount]; + for (var idx = 0; idx < materialCount; ++idx) { - if (x.Submeshes[0].Material.HasValidIndex()) + var materialIndex = node.MeshGroup.Meshes[idx].Submeshes[0].Material; + if (materialIndex.HasValidIndex()) { - return materialFactory.Materials[x.Submeshes[0].Material.Value].Asset; + materials[idx] = materialFactory.Materials[materialIndex.Value].Asset; } else { - return materialFactory.DefaultMaterial; + materials[idx] = await materialFactory.GetDefaultMaterialAsync(awaitCaller); } } - ).ToArray(); renderer.sharedMaterials = materials; } From a9742c48bfa9f9d2621e5ef4688c19d39a9c735e Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Mon, 29 Jul 2024 20:01:30 +0900 Subject: [PATCH 02/16] Extract UniUnlit shader from the Resources directory --- Assets/UniGLTF/UniUnlit/Resources.meta | 8 -------- .../UniUnlit/{Resources/UniGLTF.meta => Shaders.meta} | 0 .../{Resources/UniGLTF => Shaders}/UniUnlit.shader | 0 .../{Resources/UniGLTF => Shaders}/UniUnlit.shader.meta | 0 4 files changed, 8 deletions(-) delete mode 100644 Assets/UniGLTF/UniUnlit/Resources.meta rename Assets/UniGLTF/UniUnlit/{Resources/UniGLTF.meta => Shaders.meta} (100%) rename Assets/UniGLTF/UniUnlit/{Resources/UniGLTF => Shaders}/UniUnlit.shader (100%) rename Assets/UniGLTF/UniUnlit/{Resources/UniGLTF => Shaders}/UniUnlit.shader.meta (100%) diff --git a/Assets/UniGLTF/UniUnlit/Resources.meta b/Assets/UniGLTF/UniUnlit/Resources.meta deleted file mode 100644 index cec1abd10..000000000 --- a/Assets/UniGLTF/UniUnlit/Resources.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3254d78d0dc8f2845a12b4646c4334a8 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/UniGLTF/UniUnlit/Resources/UniGLTF.meta b/Assets/UniGLTF/UniUnlit/Shaders.meta similarity index 100% rename from Assets/UniGLTF/UniUnlit/Resources/UniGLTF.meta rename to Assets/UniGLTF/UniUnlit/Shaders.meta diff --git a/Assets/UniGLTF/UniUnlit/Resources/UniGLTF/UniUnlit.shader b/Assets/UniGLTF/UniUnlit/Shaders/UniUnlit.shader similarity index 100% rename from Assets/UniGLTF/UniUnlit/Resources/UniGLTF/UniUnlit.shader rename to Assets/UniGLTF/UniUnlit/Shaders/UniUnlit.shader diff --git a/Assets/UniGLTF/UniUnlit/Resources/UniGLTF/UniUnlit.shader.meta b/Assets/UniGLTF/UniUnlit/Shaders/UniUnlit.shader.meta similarity index 100% rename from Assets/UniGLTF/UniUnlit/Resources/UniGLTF/UniUnlit.shader.meta rename to Assets/UniGLTF/UniUnlit/Shaders/UniUnlit.shader.meta From 1499e25aec0bcbded55759eecd298349651fc6e9 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Mon, 29 Jul 2024 20:02:58 +0900 Subject: [PATCH 03/16] Extract MToon0X shaders from the Resouces directory --- Assets/VRM/MToon/Resources.meta | 8 -------- Assets/VRM/MToon/{Resources => }/Shaders.meta | 0 Assets/VRM/MToon/{Resources => }/Shaders/MToon.shader | 0 .../VRM/MToon/{Resources => }/Shaders/MToon.shader.meta | 0 Assets/VRM/MToon/{Resources => }/Shaders/MToonCore.cginc | 0 .../MToon/{Resources => }/Shaders/MToonCore.cginc.meta | 0 Assets/VRM/MToon/{Resources => }/Shaders/MToonSM3.cginc | 0 .../VRM/MToon/{Resources => }/Shaders/MToonSM3.cginc.meta | 0 Assets/VRM/MToon/{Resources => }/Shaders/MToonSM4.cginc | 0 .../VRM/MToon/{Resources => }/Shaders/MToonSM4.cginc.meta | 0 10 files changed, 8 deletions(-) delete mode 100644 Assets/VRM/MToon/Resources.meta rename Assets/VRM/MToon/{Resources => }/Shaders.meta (100%) rename Assets/VRM/MToon/{Resources => }/Shaders/MToon.shader (100%) rename Assets/VRM/MToon/{Resources => }/Shaders/MToon.shader.meta (100%) rename Assets/VRM/MToon/{Resources => }/Shaders/MToonCore.cginc (100%) rename Assets/VRM/MToon/{Resources => }/Shaders/MToonCore.cginc.meta (100%) rename Assets/VRM/MToon/{Resources => }/Shaders/MToonSM3.cginc (100%) rename Assets/VRM/MToon/{Resources => }/Shaders/MToonSM3.cginc.meta (100%) rename Assets/VRM/MToon/{Resources => }/Shaders/MToonSM4.cginc (100%) rename Assets/VRM/MToon/{Resources => }/Shaders/MToonSM4.cginc.meta (100%) diff --git a/Assets/VRM/MToon/Resources.meta b/Assets/VRM/MToon/Resources.meta deleted file mode 100644 index f1a215fdd..000000000 --- a/Assets/VRM/MToon/Resources.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9491ac346386a2b4e9f3c801c6786818 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/MToon/Resources/Shaders.meta b/Assets/VRM/MToon/Shaders.meta similarity index 100% rename from Assets/VRM/MToon/Resources/Shaders.meta rename to Assets/VRM/MToon/Shaders.meta diff --git a/Assets/VRM/MToon/Resources/Shaders/MToon.shader b/Assets/VRM/MToon/Shaders/MToon.shader similarity index 100% rename from Assets/VRM/MToon/Resources/Shaders/MToon.shader rename to Assets/VRM/MToon/Shaders/MToon.shader diff --git a/Assets/VRM/MToon/Resources/Shaders/MToon.shader.meta b/Assets/VRM/MToon/Shaders/MToon.shader.meta similarity index 100% rename from Assets/VRM/MToon/Resources/Shaders/MToon.shader.meta rename to Assets/VRM/MToon/Shaders/MToon.shader.meta diff --git a/Assets/VRM/MToon/Resources/Shaders/MToonCore.cginc b/Assets/VRM/MToon/Shaders/MToonCore.cginc similarity index 100% rename from Assets/VRM/MToon/Resources/Shaders/MToonCore.cginc rename to Assets/VRM/MToon/Shaders/MToonCore.cginc diff --git a/Assets/VRM/MToon/Resources/Shaders/MToonCore.cginc.meta b/Assets/VRM/MToon/Shaders/MToonCore.cginc.meta similarity index 100% rename from Assets/VRM/MToon/Resources/Shaders/MToonCore.cginc.meta rename to Assets/VRM/MToon/Shaders/MToonCore.cginc.meta diff --git a/Assets/VRM/MToon/Resources/Shaders/MToonSM3.cginc b/Assets/VRM/MToon/Shaders/MToonSM3.cginc similarity index 100% rename from Assets/VRM/MToon/Resources/Shaders/MToonSM3.cginc rename to Assets/VRM/MToon/Shaders/MToonSM3.cginc diff --git a/Assets/VRM/MToon/Resources/Shaders/MToonSM3.cginc.meta b/Assets/VRM/MToon/Shaders/MToonSM3.cginc.meta similarity index 100% rename from Assets/VRM/MToon/Resources/Shaders/MToonSM3.cginc.meta rename to Assets/VRM/MToon/Shaders/MToonSM3.cginc.meta diff --git a/Assets/VRM/MToon/Resources/Shaders/MToonSM4.cginc b/Assets/VRM/MToon/Shaders/MToonSM4.cginc similarity index 100% rename from Assets/VRM/MToon/Resources/Shaders/MToonSM4.cginc rename to Assets/VRM/MToon/Shaders/MToonSM4.cginc diff --git a/Assets/VRM/MToon/Resources/Shaders/MToonSM4.cginc.meta b/Assets/VRM/MToon/Shaders/MToonSM4.cginc.meta similarity index 100% rename from Assets/VRM/MToon/Resources/Shaders/MToonSM4.cginc.meta rename to Assets/VRM/MToon/Shaders/MToonSM4.cginc.meta From c8f8330f9012fd807652ef4f312ebfbdf2e01a1e Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Mon, 29 Jul 2024 20:05:32 +0900 Subject: [PATCH 04/16] Extract MToon10 shaders from the Resources directory --- Assets/VRM10/MToon10/Resources.meta | 8 -------- .../VRM10/MToon10/{Resources/VRM10.meta => Shaders.meta} | 0 .../VRM10 => Shaders}/vrmc_materials_mtoon.shader | 0 .../VRM10 => Shaders}/vrmc_materials_mtoon.shader.meta | 0 .../VRM10 => Shaders}/vrmc_materials_mtoon_attribute.hlsl | 0 .../vrmc_materials_mtoon_attribute.hlsl.meta | 0 .../VRM10 => Shaders}/vrmc_materials_mtoon_define.hlsl | 0 .../vrmc_materials_mtoon_define.hlsl.meta | 0 .../vrmc_materials_mtoon_depthnormals_fragment.hlsl | 0 .../vrmc_materials_mtoon_depthnormals_fragment.hlsl.meta | 0 .../vrmc_materials_mtoon_depthnormals_vertex.hlsl | 0 .../vrmc_materials_mtoon_depthnormals_vertex.hlsl.meta | 0 .../vrmc_materials_mtoon_depthonly_fragment.hlsl | 0 .../vrmc_materials_mtoon_depthonly_fragment.hlsl.meta | 0 .../vrmc_materials_mtoon_depthonly_vertex.hlsl | 0 .../vrmc_materials_mtoon_depthonly_vertex.hlsl.meta | 0 .../vrmc_materials_mtoon_forward_fragment.hlsl | 0 .../vrmc_materials_mtoon_forward_fragment.hlsl.meta | 0 .../vrmc_materials_mtoon_forward_vertex.hlsl | 0 .../vrmc_materials_mtoon_forward_vertex.hlsl.meta | 0 .../vrmc_materials_mtoon_geometry_alpha.hlsl | 0 .../vrmc_materials_mtoon_geometry_alpha.hlsl.meta | 0 .../vrmc_materials_mtoon_geometry_normal.hlsl | 0 .../vrmc_materials_mtoon_geometry_normal.hlsl.meta | 0 .../vrmc_materials_mtoon_geometry_uv.hlsl | 0 .../vrmc_materials_mtoon_geometry_uv.hlsl.meta | 0 .../vrmc_materials_mtoon_geometry_vertex.hlsl | 0 .../vrmc_materials_mtoon_geometry_vertex.hlsl.meta | 0 .../VRM10 => Shaders}/vrmc_materials_mtoon_input.hlsl | 0 .../vrmc_materials_mtoon_input.hlsl.meta | 0 .../vrmc_materials_mtoon_lighting_mtoon.hlsl | 0 .../vrmc_materials_mtoon_lighting_mtoon.hlsl.meta | 0 .../vrmc_materials_mtoon_lighting_unity.hlsl | 0 .../vrmc_materials_mtoon_lighting_unity.hlsl.meta | 0 .../vrmc_materials_mtoon_render_pipeline.hlsl | 0 .../vrmc_materials_mtoon_render_pipeline.hlsl.meta | 0 .../vrmc_materials_mtoon_shadowcaster_fragment.hlsl | 0 .../vrmc_materials_mtoon_shadowcaster_fragment.hlsl.meta | 0 .../vrmc_materials_mtoon_shadowcaster_vertex.hlsl | 0 .../vrmc_materials_mtoon_shadowcaster_vertex.hlsl.meta | 0 .../VRM10 => Shaders}/vrmc_materials_mtoon_urp.shader | 0 .../vrmc_materials_mtoon_urp.shader.meta | 0 .../VRM10 => Shaders}/vrmc_materials_mtoon_utility.hlsl | 0 .../vrmc_materials_mtoon_utility.hlsl.meta | 0 44 files changed, 8 deletions(-) delete mode 100644 Assets/VRM10/MToon10/Resources.meta rename Assets/VRM10/MToon10/{Resources/VRM10.meta => Shaders.meta} (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon.shader (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon.shader.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_attribute.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_attribute.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_define.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_define.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_depthnormals_fragment.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_depthnormals_fragment.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_depthnormals_vertex.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_depthnormals_vertex.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_depthonly_fragment.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_depthonly_fragment.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_depthonly_vertex.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_depthonly_vertex.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_forward_fragment.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_forward_fragment.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_forward_vertex.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_forward_vertex.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_geometry_alpha.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_geometry_alpha.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_geometry_normal.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_geometry_normal.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_geometry_uv.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_geometry_uv.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_geometry_vertex.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_geometry_vertex.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_input.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_input.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_lighting_mtoon.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_lighting_mtoon.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_lighting_unity.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_lighting_unity.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_render_pipeline.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_render_pipeline.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_shadowcaster_fragment.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_shadowcaster_fragment.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_shadowcaster_vertex.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_shadowcaster_vertex.hlsl.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_urp.shader (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_urp.shader.meta (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_utility.hlsl (100%) rename Assets/VRM10/MToon10/{Resources/VRM10 => Shaders}/vrmc_materials_mtoon_utility.hlsl.meta (100%) diff --git a/Assets/VRM10/MToon10/Resources.meta b/Assets/VRM10/MToon10/Resources.meta deleted file mode 100644 index 6b69de785..000000000 --- a/Assets/VRM10/MToon10/Resources.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d5b5138c63fcb784595ae54e08a0e9e7 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM10/MToon10/Resources/VRM10.meta b/Assets/VRM10/MToon10/Shaders.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10.meta rename to Assets/VRM10/MToon10/Shaders.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon.shader b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon.shader similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon.shader rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon.shader diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon.shader.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon.shader.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon.shader.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon.shader.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_attribute.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_attribute.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_attribute.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_attribute.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_define.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_define.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_define.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_define.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_fragment.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthnormals_fragment.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_fragment.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthnormals_fragment.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_fragment.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthnormals_fragment.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_fragment.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthnormals_fragment.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_vertex.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthnormals_vertex.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_vertex.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthnormals_vertex.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_vertex.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthnormals_vertex.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_vertex.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthnormals_vertex.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthonly_fragment.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthonly_fragment.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthonly_fragment.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthonly_fragment.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthonly_fragment.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthonly_fragment.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthonly_fragment.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthonly_fragment.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthonly_vertex.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthonly_vertex.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthonly_vertex.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthonly_vertex.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthonly_vertex.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthonly_vertex.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthonly_vertex.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_depthonly_vertex.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_forward_fragment.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_forward_fragment.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_forward_fragment.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_forward_fragment.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_forward_vertex.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_forward_vertex.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_forward_vertex.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_forward_vertex.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_alpha.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_alpha.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_alpha.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_alpha.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_alpha.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_alpha.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_alpha.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_alpha.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_normal.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_normal.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_normal.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_normal.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_uv.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_uv.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_uv.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_uv.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_vertex.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_vertex.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_vertex.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_geometry_vertex.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_input.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_input.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_input.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_input.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_lighting_mtoon.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_lighting_mtoon.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_lighting_mtoon.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_lighting_mtoon.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_lighting_unity.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_lighting_unity.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_lighting_unity.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_lighting_unity.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_render_pipeline.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_render_pipeline.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_render_pipeline.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_render_pipeline.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_render_pipeline.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_render_pipeline.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_render_pipeline.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_render_pipeline.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_fragment.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_shadowcaster_fragment.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_fragment.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_shadowcaster_fragment.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_fragment.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_shadowcaster_fragment.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_fragment.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_shadowcaster_fragment.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_vertex.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_shadowcaster_vertex.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_vertex.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_shadowcaster_vertex.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_vertex.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_shadowcaster_vertex.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_vertex.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_shadowcaster_vertex.hlsl.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_urp.shader similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_urp.shader diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_urp.shader.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_urp.shader.meta diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_utility.hlsl b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_utility.hlsl similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_utility.hlsl rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_utility.hlsl diff --git a/Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_utility.hlsl.meta b/Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_utility.hlsl.meta similarity index 100% rename from Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_utility.hlsl.meta rename to Assets/VRM10/MToon10/Shaders/vrmc_materials_mtoon_utility.hlsl.meta From f5f468444c5094d61af3e9dc05e12d4058878338 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Mon, 29 Jul 2024 20:06:38 +0900 Subject: [PATCH 05/16] Remove incomplete shadervariants files --- Assets/VRM/Settings.meta | 8 -------- Assets/VRM/Settings/VRMShaders.shadervariants | 19 ------------------- .../Settings/VRMShaders.shadervariants.meta | 9 --------- Assets/VRM10/Settings.meta | 8 -------- .../Settings/VRM10Shaders.shadervariants | 19 ------------------- .../Settings/VRM10Shaders.shadervariants.meta | 8 -------- 6 files changed, 71 deletions(-) delete mode 100644 Assets/VRM/Settings.meta delete mode 100644 Assets/VRM/Settings/VRMShaders.shadervariants delete mode 100644 Assets/VRM/Settings/VRMShaders.shadervariants.meta delete mode 100644 Assets/VRM10/Settings.meta delete mode 100644 Assets/VRM10/Settings/VRM10Shaders.shadervariants delete mode 100644 Assets/VRM10/Settings/VRM10Shaders.shadervariants.meta diff --git a/Assets/VRM/Settings.meta b/Assets/VRM/Settings.meta deleted file mode 100644 index 3259186ec..000000000 --- a/Assets/VRM/Settings.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6cf41692967c5544b8ceeb148cad87b3 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/Settings/VRMShaders.shadervariants b/Assets/VRM/Settings/VRMShaders.shadervariants deleted file mode 100644 index 9ae663e70..000000000 --- a/Assets/VRM/Settings/VRMShaders.shadervariants +++ /dev/null @@ -1,19 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!200 &20000000 -ShaderVariantCollection: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: VRMShaders - m_Shaders: - - first: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - second: - variants: [] - - first: {fileID: 4800000, guid: 1a97144e4ad27a04aafd70f7b915cedb, type: 3} - second: - variants: [] - - first: {fileID: 4800000, guid: 8c17b56f4bf084c47872edcb95237e4a, type: 3} - second: - variants: [] diff --git a/Assets/VRM/Settings/VRMShaders.shadervariants.meta b/Assets/VRM/Settings/VRMShaders.shadervariants.meta deleted file mode 100644 index 6cccfe0a3..000000000 --- a/Assets/VRM/Settings/VRMShaders.shadervariants.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 486ebb794ada0de41be4f35c56876f82 -timeCreated: 1520840003 -licenseType: Free -NativeFormatImporter: - mainObjectFileID: 20000000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM10/Settings.meta b/Assets/VRM10/Settings.meta deleted file mode 100644 index 1a4cea139..000000000 --- a/Assets/VRM10/Settings.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 163e23db776ac5949b74480605c68c90 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM10/Settings/VRM10Shaders.shadervariants b/Assets/VRM10/Settings/VRM10Shaders.shadervariants deleted file mode 100644 index 862245327..000000000 --- a/Assets/VRM10/Settings/VRM10Shaders.shadervariants +++ /dev/null @@ -1,19 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!200 &20000000 -ShaderVariantCollection: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: VRM10Shaders - m_Shaders: - - first: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - second: - variants: [] - - first: {fileID: 4800000, guid: e0edbf68d81d1f340ae8b110086b7063, type: 3} - second: - variants: [] - - first: {fileID: 4800000, guid: 8c17b56f4bf084c47872edcb95237e4a, type: 3} - second: - variants: [] diff --git a/Assets/VRM10/Settings/VRM10Shaders.shadervariants.meta b/Assets/VRM10/Settings/VRM10Shaders.shadervariants.meta deleted file mode 100644 index d725f5ce2..000000000 --- a/Assets/VRM10/Settings/VRM10Shaders.shadervariants.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 58f01bf8180084642a5f4c17a3c8cd4b -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 0 - userData: - assetBundleName: - assetBundleVariant: From f5d40b4d850dd091212cffdea855dd87679cc562 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Mon, 29 Jul 2024 21:59:14 +0900 Subject: [PATCH 06/16] Refactor about detecting the RenderPipeline --- .../MaterialDescriptorGeneratorUtility.cs | 16 ++++++++++++++++ .../MaterialDescriptorGeneratorUtility.cs.meta} | 0 ...iptorUtility.cs => RenderPipelineUtility.cs} | 17 +++-------------- .../IO/MaterialIO/RenderPipelineUtility.cs.meta | 3 +++ ...=> VrmMaterialDescriptorGeneratorUtility.cs} | 2 +- ...mMaterialDescriptorGeneratorUtility.cs.meta} | 0 ...rialDescriptorGeneratorDescriptorUtility.cs} | 2 +- ...escriptorGeneratorDescriptorUtility.cs.meta} | 0 8 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialDescriptorGeneratorUtility.cs rename Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/{RenderPipelineMaterialDescriptorUtility.cs.meta => Import/MaterialDescriptorGeneratorUtility.cs.meta} (100%) rename Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/{RenderPipelineMaterialDescriptorUtility.cs => RenderPipelineUtility.cs} (57%) create mode 100644 Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/RenderPipelineUtility.cs.meta rename Assets/VRM/Runtime/IO/MaterialIO/{VRMRenderPipelineMaterialDescriptorGeneratorUtility.cs => VrmMaterialDescriptorGeneratorUtility.cs} (86%) rename Assets/VRM/Runtime/IO/MaterialIO/{VRMRenderPipelineMaterialDescriptorGeneratorUtility.cs.meta => VrmMaterialDescriptorGeneratorUtility.cs.meta} (100%) rename Assets/VRM10/Runtime/IO/Material/URP/Import/{VRM10RenderPipelineMaterialDescriptorGeneratorUtility.cs => Vrm10MaterialDescriptorGeneratorDescriptorUtility.cs} (86%) rename Assets/VRM10/Runtime/IO/Material/URP/Import/{VRM10RenderPipelineMaterialDescriptorGeneratorUtility.cs.meta => Vrm10MaterialDescriptorGeneratorDescriptorUtility.cs.meta} (100%) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialDescriptorGeneratorUtility.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialDescriptorGeneratorUtility.cs new file mode 100644 index 000000000..dee8cba3d --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialDescriptorGeneratorUtility.cs @@ -0,0 +1,16 @@ +namespace UniGLTF +{ + public static class MaterialDescriptorGeneratorUtility + { + public static IMaterialDescriptorGenerator GetValidGltfMaterialDescriptorGenerator() + { + return RenderPipelineUtility.GetRenderPipelineType() switch + { + RenderPipelineTypes.UniversalRenderPipeline => new UrpGltfMaterialDescriptorGenerator(), + RenderPipelineTypes.BuiltinRenderPipeline => new BuiltInGltfMaterialDescriptorGenerator(), + _ => new BuiltInGltfMaterialDescriptorGenerator(), + }; + } + } +} + diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/RenderPipelineMaterialDescriptorUtility.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialDescriptorGeneratorUtility.cs.meta similarity index 100% rename from Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/RenderPipelineMaterialDescriptorUtility.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialDescriptorGeneratorUtility.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/RenderPipelineMaterialDescriptorUtility.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/RenderPipelineUtility.cs similarity index 57% rename from Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/RenderPipelineMaterialDescriptorUtility.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/RenderPipelineUtility.cs index 927e6f6e6..76ecc0547 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/RenderPipelineMaterialDescriptorUtility.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/RenderPipelineUtility.cs @@ -1,8 +1,8 @@ -using UnityEngine.Rendering; +using UnityEngine.Rendering; namespace UniGLTF { - public static class MaterialDescriptorGeneratorUtility + public static class RenderPipelineUtility { public static RenderPipelineTypes GetRenderPipelineType() { @@ -25,16 +25,5 @@ namespace UniGLTF return RenderPipelineTypes.Unknown; } - - public static IMaterialDescriptorGenerator GetValidGltfMaterialDescriptorGenerator() - { - return GetRenderPipelineType() switch - { - RenderPipelineTypes.UniversalRenderPipeline => new UrpGltfMaterialDescriptorGenerator(), - RenderPipelineTypes.BuiltinRenderPipeline => new BuiltInGltfMaterialDescriptorGenerator(), - _ => new BuiltInGltfMaterialDescriptorGenerator(), - }; - } } -} - +} \ No newline at end of file diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/RenderPipelineUtility.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/RenderPipelineUtility.cs.meta new file mode 100644 index 000000000..2f54eddfe --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/RenderPipelineUtility.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0fd29db9c49145cd9f56f92e6153c8db +timeCreated: 1722257774 \ No newline at end of file diff --git a/Assets/VRM/Runtime/IO/MaterialIO/VRMRenderPipelineMaterialDescriptorGeneratorUtility.cs b/Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialDescriptorGeneratorUtility.cs similarity index 86% rename from Assets/VRM/Runtime/IO/MaterialIO/VRMRenderPipelineMaterialDescriptorGeneratorUtility.cs rename to Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialDescriptorGeneratorUtility.cs index 282e4d8c3..f13e9e92a 100644 --- a/Assets/VRM/Runtime/IO/MaterialIO/VRMRenderPipelineMaterialDescriptorGeneratorUtility.cs +++ b/Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialDescriptorGeneratorUtility.cs @@ -6,7 +6,7 @@ namespace VRM { public static IMaterialDescriptorGenerator GetValidVrmMaterialDescriptorGenerator(glTF_VRM_extensions vrm) { - return MaterialDescriptorGeneratorUtility.GetRenderPipelineType() switch + return RenderPipelineUtility.GetRenderPipelineType() switch { RenderPipelineTypes.UniversalRenderPipeline => new UrpVrmMaterialDescriptorGenerator(vrm), RenderPipelineTypes.BuiltinRenderPipeline => new BuiltInVrmMaterialDescriptorGenerator(vrm), diff --git a/Assets/VRM/Runtime/IO/MaterialIO/VRMRenderPipelineMaterialDescriptorGeneratorUtility.cs.meta b/Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialDescriptorGeneratorUtility.cs.meta similarity index 100% rename from Assets/VRM/Runtime/IO/MaterialIO/VRMRenderPipelineMaterialDescriptorGeneratorUtility.cs.meta rename to Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialDescriptorGeneratorUtility.cs.meta diff --git a/Assets/VRM10/Runtime/IO/Material/URP/Import/VRM10RenderPipelineMaterialDescriptorGeneratorUtility.cs b/Assets/VRM10/Runtime/IO/Material/URP/Import/Vrm10MaterialDescriptorGeneratorDescriptorUtility.cs similarity index 86% rename from Assets/VRM10/Runtime/IO/Material/URP/Import/VRM10RenderPipelineMaterialDescriptorGeneratorUtility.cs rename to Assets/VRM10/Runtime/IO/Material/URP/Import/Vrm10MaterialDescriptorGeneratorDescriptorUtility.cs index 9bd072165..bb3000f29 100644 --- a/Assets/VRM10/Runtime/IO/Material/URP/Import/VRM10RenderPipelineMaterialDescriptorGeneratorUtility.cs +++ b/Assets/VRM10/Runtime/IO/Material/URP/Import/Vrm10MaterialDescriptorGeneratorDescriptorUtility.cs @@ -6,7 +6,7 @@ namespace UniVRM10 { public static IMaterialDescriptorGenerator GetValidVrm10MaterialDescriptorGenerator() { - return MaterialDescriptorGeneratorUtility.GetRenderPipelineType() switch + return RenderPipelineUtility.GetRenderPipelineType() switch { RenderPipelineTypes.UniversalRenderPipeline => new UrpVrm10MaterialDescriptorGenerator(), RenderPipelineTypes.BuiltinRenderPipeline => new BuiltInVrm10MaterialDescriptorGenerator(), diff --git a/Assets/VRM10/Runtime/IO/Material/URP/Import/VRM10RenderPipelineMaterialDescriptorGeneratorUtility.cs.meta b/Assets/VRM10/Runtime/IO/Material/URP/Import/Vrm10MaterialDescriptorGeneratorDescriptorUtility.cs.meta similarity index 100% rename from Assets/VRM10/Runtime/IO/Material/URP/Import/VRM10RenderPipelineMaterialDescriptorGeneratorUtility.cs.meta rename to Assets/VRM10/Runtime/IO/Material/URP/Import/Vrm10MaterialDescriptorGeneratorDescriptorUtility.cs.meta From 23f387a7c8310683c9dad9596498f489bcf8e383 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Mon, 29 Jul 2024 22:28:35 +0900 Subject: [PATCH 07/16] add RenderPipeline considering to gltf/vrm/vrm10 exporters --- .../UniGLTF/ExportDialog/GltfExportWindow.cs | 7 ++-- .../Export/MaterialExporterUtility.cs | 15 ++++++++ .../Export/MaterialExporterUtility.cs.meta | 3 ++ .../Runtime/UniGLTF/IO/gltfExporter.cs | 32 +++++++++------- .../UniGLTF/EditorTextureSerializerTests.cs | 4 +- Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs | 2 +- Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs | 10 ++--- Assets/VRM/Editor/Format/VRMEditorExporter.cs | 5 ++- .../MaterialIO/VrmMaterialExporterUtility.cs | 17 +++++++++ .../VrmMaterialExporterUtility.cs.meta | 3 ++ Assets/VRM/Runtime/IO/VRMExporter.cs | 24 +++++++----- Assets/VRM10/Editor/Vrm10ExportDialog.cs | 6 ++- ...rm10MaterialDescriptorGeneratorUtility.cs} | 2 +- ...aterialDescriptorGeneratorUtility.cs.meta} | 0 .../Material/Vrm10MaterialExporterUtility.cs | 17 +++++++++ .../Vrm10MaterialExporterUtility.cs.meta | 3 ++ Assets/VRM10/Runtime/IO/Vrm10Exporter.cs | 38 +++++++++++-------- Assets/VRM10/Runtime/IO/Vrm10Importer.cs | 2 +- .../VRM10/Runtime/IO/VrmAnimationExporter.cs | 2 +- Assets/VRM10/Tests/ApiSampleTests.cs | 2 +- .../VRM10RuntimeExporter.cs | 9 +++-- 21 files changed, 143 insertions(+), 60 deletions(-) create mode 100644 Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Export/MaterialExporterUtility.cs create mode 100644 Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Export/MaterialExporterUtility.cs.meta create mode 100644 Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialExporterUtility.cs create mode 100644 Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialExporterUtility.cs.meta rename Assets/VRM10/Runtime/IO/Material/{URP/Import/Vrm10MaterialDescriptorGeneratorDescriptorUtility.cs => Vrm10MaterialDescriptorGeneratorUtility.cs} (87%) rename Assets/VRM10/Runtime/IO/Material/{URP/Import/Vrm10MaterialDescriptorGeneratorDescriptorUtility.cs.meta => Vrm10MaterialDescriptorGeneratorUtility.cs.meta} (100%) create mode 100644 Assets/VRM10/Runtime/IO/Material/Vrm10MaterialExporterUtility.cs create mode 100644 Assets/VRM10/Runtime/IO/Material/Vrm10MaterialExporterUtility.cs.meta diff --git a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/GltfExportWindow.cs b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/GltfExportWindow.cs index b05c56076..75a9686b4 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/GltfExportWindow.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/GltfExportWindow.cs @@ -109,11 +109,12 @@ namespace UniGLTF { var data = new ExportingGltfData(); using (var exporter = new gltfExporter(data, Settings, - progress: new EditorProgress(), - animationExporter: new EditorAnimationExporter())) + progress: new EditorProgress(), + animationExporter: new EditorAnimationExporter(), + textureSerializer: new EditorTextureSerializer())) { exporter.Prepare(State.ExportRoot); - exporter.Export(new EditorTextureSerializer()); + exporter.Export(); } if (isGlb) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Export/MaterialExporterUtility.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Export/MaterialExporterUtility.cs new file mode 100644 index 000000000..449e9f735 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Export/MaterialExporterUtility.cs @@ -0,0 +1,15 @@ +namespace UniGLTF +{ + public static class MaterialExporterUtility + { + public static IMaterialExporter GetValidGltfMaterialExporter() + { + return RenderPipelineUtility.GetRenderPipelineType() switch + { + RenderPipelineTypes.UniversalRenderPipeline => throw new System.NotImplementedException(), + RenderPipelineTypes.BuiltinRenderPipeline => new BuiltInGltfMaterialExporter(), + _ => new BuiltInGltfMaterialExporter(), + }; + } + } +} \ No newline at end of file diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Export/MaterialExporterUtility.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Export/MaterialExporterUtility.cs.meta new file mode 100644 index 000000000..9a2cbdb44 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Export/MaterialExporterUtility.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ce72b16c8b374add909ab887c14a0f44 +timeCreated: 1722257666 \ No newline at end of file diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs index 15d8cd9af..57d423dd1 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs @@ -45,11 +45,6 @@ namespace UniGLTF private set; } - protected virtual IMaterialExporter CreateMaterialExporter() - { - return new BuiltInGltfMaterialExporter(); - } - protected ITextureExporter TextureExporter => _textureExporter; private TextureExporter _textureExporter; @@ -66,10 +61,18 @@ namespace UniGLTF m_progress.Report(new ExportProgress("gltfExporter", msg, progress)); } - IAnimationExporter m_animationExporter; + private readonly IAnimationExporter m_animationExporter; + private readonly IMaterialExporter m_materialExporter; + private readonly ITextureSerializer m_textureSerializer; - public gltfExporter(ExportingGltfData data, GltfExportSettings settings, IProgress progress = null, - IAnimationExporter animationExporter = null) + public gltfExporter( + ExportingGltfData data, + GltfExportSettings settings, + IProgress progress = null, + IAnimationExporter animationExporter = null, + IMaterialExporter materialExporter = null, + ITextureSerializer textureSerializer = null + ) { _data = data; @@ -87,6 +90,8 @@ namespace UniGLTF } m_animationExporter = animationExporter; + m_materialExporter = materialExporter ?? MaterialExporterUtility.GetValidGltfMaterialExporter(); + m_textureSerializer = textureSerializer ?? new RuntimeTextureSerializer(); } GameObject m_tmpParent = null; @@ -224,7 +229,7 @@ namespace UniGLTF // do nothing } - public virtual void Export(ITextureSerializer textureSerializer) + public virtual void Export() { if (m_settings.FreezeMesh) { @@ -249,10 +254,9 @@ namespace UniGLTF ReportProgress("Materials and Textures", 0.2f); Materials = uniqueUnityMeshes.GetUniqueMaterials().ToList(); - _textureExporter = new TextureExporter(textureSerializer); + _textureExporter = new TextureExporter(m_textureSerializer); - var materialExporter = CreateMaterialExporter(); - _gltf.materials = Materials.Select(x => materialExporter.ExportMaterial(x, TextureExporter, m_settings)).ToList(); + _gltf.materials = Materials.Select(x => m_materialExporter.ExportMaterial(x, TextureExporter, m_settings)).ToList(); #endregion #region Meshes @@ -346,14 +350,14 @@ namespace UniGLTF m_animationExporter.Export(_data, Copy, Nodes); } - ExportExtensions(textureSerializer); + ExportExtensions(m_textureSerializer); // Extension で Texture が増える場合があるので最後に呼ぶ var exported = _textureExporter.Export(); for (var exportedTextureIdx = 0; exportedTextureIdx < exported.Count; ++exportedTextureIdx) { var (unityTexture, colorSpace) = exported[exportedTextureIdx]; - GltfTextureExporter.PushGltfTexture(_data, unityTexture, colorSpace, textureSerializer); + GltfTextureExporter.PushGltfTexture(_data, unityTexture, colorSpace, m_textureSerializer); } FixName(_gltf); diff --git a/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs b/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs index 3766f9d4f..dbc1349e9 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs @@ -125,10 +125,10 @@ namespace UniGLTF ExportOnlyBlendShapePosition = false, UseSparseAccessorForMorphTarget = false, DivideVertexBuffer = false, - })) + }, textureSerializer: new EditorTextureSerializer())) { exporter.Prepare(root); - exporter.Export(new EditorTextureSerializer()); + exporter.Export(); } var gltf = data.Gltf; Assert.AreEqual(1, gltf.images.Count); diff --git a/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs b/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs index 7231079b6..58e0f7e76 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs @@ -68,7 +68,7 @@ namespace UniGLTF using (var exporter = new gltfExporter(data, new GltfExportSettings())) { exporter.Prepare(root); - exporter.Export(new EditorTextureSerializer()); + exporter.Export(); } return data.ToGlbBytes(); } diff --git a/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs b/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs index 5b918f109..99ad080f6 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs @@ -105,7 +105,7 @@ namespace UniGLTF using (var exporter = new gltfExporter(data, new GltfExportSettings())) { exporter.Prepare(go); - exporter.Export(new EditorTextureSerializer()); + exporter.Export(); // remove empty buffer data.Gltf.buffers.Clear(); @@ -357,7 +357,7 @@ namespace UniGLTF using (var exporter = new gltfExporter(data, new GltfExportSettings())) { exporter.Prepare(CreateSimpleScene()); - exporter.Export(new EditorTextureSerializer()); + exporter.Export(); } var expected = data.Gltf.ToJson().ParseAsJson(); @@ -592,7 +592,7 @@ namespace UniGLTF using (var exporter = new gltfExporter(data, new GltfExportSettings())) { exporter.Prepare(go); - exporter.Export(new EditorTextureSerializer()); + exporter.Export(); json = gltf.ToJson(); } @@ -670,7 +670,7 @@ namespace UniGLTF using (var exporter = new gltfExporter(data, new GltfExportSettings())) { exporter.Prepare(go); - exporter.Export(new EditorTextureSerializer()); + exporter.Export(); json = gltf.ToJson(); } @@ -733,7 +733,7 @@ namespace UniGLTF using (var exporter = new gltfExporter(data, new GltfExportSettings())) { exporter.Prepare(root); - exporter.Export(new EditorTextureSerializer()); + exporter.Export(); json = gltf.ToJson(); } diff --git a/Assets/VRM/Editor/Format/VRMEditorExporter.cs b/Assets/VRM/Editor/Format/VRMEditorExporter.cs index 427da420d..c4489d7a4 100644 --- a/Assets/VRM/Editor/Format/VRMEditorExporter.cs +++ b/Assets/VRM/Editor/Format/VRMEditorExporter.cs @@ -226,10 +226,11 @@ namespace VRM var data = new UniGLTF.ExportingGltfData(); var gltfExportSettings = settings.GltfExportSettings; using (var exporter = new VRMExporter(data, gltfExportSettings, - settings.KeepAnimation ? new EditorAnimationExporter() : null)) + animationExporter: settings.KeepAnimation ? new EditorAnimationExporter() : null, + textureSerializer: new EditorTextureSerializer())) { exporter.Prepare(target); - exporter.Export(new EditorTextureSerializer()); + exporter.Export(); } var bytes = data.ToGlbBytes(); Debug.LogFormat("Export elapsed {0}", sw.Elapsed); diff --git a/Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialExporterUtility.cs b/Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialExporterUtility.cs new file mode 100644 index 000000000..9c220c65c --- /dev/null +++ b/Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialExporterUtility.cs @@ -0,0 +1,17 @@ +using UniGLTF; + +namespace VRM +{ + public static class VrmMaterialExporterUtility + { + public static IMaterialExporter GetValidVrmMaterialExporter() + { + return RenderPipelineUtility.GetRenderPipelineType() switch + { + RenderPipelineTypes.UniversalRenderPipeline => throw new System.NotImplementedException(), + RenderPipelineTypes.BuiltinRenderPipeline => new BuiltInVrmMaterialExporter(), + _ => new BuiltInVrmMaterialExporter(), + }; + } + } +} \ No newline at end of file diff --git a/Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialExporterUtility.cs.meta b/Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialExporterUtility.cs.meta new file mode 100644 index 000000000..cb4b69cfe --- /dev/null +++ b/Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialExporterUtility.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c195ef8334f647febbfc517181117548 +timeCreated: 1722258234 \ No newline at end of file diff --git a/Assets/VRM/Runtime/IO/VRMExporter.cs b/Assets/VRM/Runtime/IO/VRMExporter.cs index f1f5d02b2..64e77cb80 100644 --- a/Assets/VRM/Runtime/IO/VRMExporter.cs +++ b/Assets/VRM/Runtime/IO/VRMExporter.cs @@ -14,18 +14,29 @@ namespace VRM public static ExportingGltfData Export(GltfExportSettings configuration, GameObject go, ITextureSerializer textureSerializer) { var data = new ExportingGltfData(); - using (var exporter = new VRMExporter(data, configuration)) + using (var exporter = new VRMExporter(data, configuration, textureSerializer: textureSerializer)) { exporter.Prepare(go); - exporter.Export(textureSerializer); + exporter.Export(); } return data; } public readonly VRM.glTF_VRM_extensions VRM = new glTF_VRM_extensions(); - public VRMExporter(ExportingGltfData data, GltfExportSettings exportSettings, IAnimationExporter animationExporter = null) : base( - data, exportSettings, animationExporter: animationExporter) + public VRMExporter( + ExportingGltfData data, + GltfExportSettings exportSettings, + IAnimationExporter animationExporter = null, + IMaterialExporter materialExporter = null, + ITextureSerializer textureSerializer = null + ) : base( + data, + exportSettings, + animationExporter: animationExporter, + materialExporter: materialExporter ?? VrmMaterialExporterUtility.GetValidVrmMaterialExporter(), + textureSerializer: textureSerializer + ) { if (exportSettings == null) { @@ -40,11 +51,6 @@ namespace VRM _gltf.extensionsUsed.Add(glTF_VRM_extensions.ExtensionName); } - protected override IMaterialExporter CreateMaterialExporter() - { - return new BuiltInVrmMaterialExporter(); - } - public override void ExportExtensions(ITextureSerializer textureSerializer) { var getBone = UniHumanoid.Humanoid.Get_GetBoneTransform(Copy); diff --git a/Assets/VRM10/Editor/Vrm10ExportDialog.cs b/Assets/VRM10/Editor/Vrm10ExportDialog.cs index 64b8a6e7a..8c463b5ec 100644 --- a/Assets/VRM10/Editor/Vrm10ExportDialog.cs +++ b/Assets/VRM10/Editor/Vrm10ExportDialog.cs @@ -311,7 +311,11 @@ namespace UniVRM10 model.ConvertCoordinate(VrmLib.Coordinates.Vrm1, ignoreVrm: false); // export vrm-1.0 - var exporter = new UniVRM10.Vrm10Exporter(new EditorTextureSerializer(), m_settings.MeshExportSettings); + var exporter = new Vrm10Exporter( + m_settings.MeshExportSettings, + Vrm10MaterialExporterUtility.GetValidVrm10MaterialExporter(), + new EditorTextureSerializer() + ); var option = new VrmLib.ExportArgs { sparse = m_settings.MorphTargetUseSparse, diff --git a/Assets/VRM10/Runtime/IO/Material/URP/Import/Vrm10MaterialDescriptorGeneratorDescriptorUtility.cs b/Assets/VRM10/Runtime/IO/Material/Vrm10MaterialDescriptorGeneratorUtility.cs similarity index 87% rename from Assets/VRM10/Runtime/IO/Material/URP/Import/Vrm10MaterialDescriptorGeneratorDescriptorUtility.cs rename to Assets/VRM10/Runtime/IO/Material/Vrm10MaterialDescriptorGeneratorUtility.cs index bb3000f29..d45c4741d 100644 --- a/Assets/VRM10/Runtime/IO/Material/URP/Import/Vrm10MaterialDescriptorGeneratorDescriptorUtility.cs +++ b/Assets/VRM10/Runtime/IO/Material/Vrm10MaterialDescriptorGeneratorUtility.cs @@ -2,7 +2,7 @@ using UniGLTF; namespace UniVRM10 { - public static class Vrm10MaterialDescriptorGeneratorDescriptorUtility + public static class Vrm10MaterialDescriptorGeneratorUtility { public static IMaterialDescriptorGenerator GetValidVrm10MaterialDescriptorGenerator() { diff --git a/Assets/VRM10/Runtime/IO/Material/URP/Import/Vrm10MaterialDescriptorGeneratorDescriptorUtility.cs.meta b/Assets/VRM10/Runtime/IO/Material/Vrm10MaterialDescriptorGeneratorUtility.cs.meta similarity index 100% rename from Assets/VRM10/Runtime/IO/Material/URP/Import/Vrm10MaterialDescriptorGeneratorDescriptorUtility.cs.meta rename to Assets/VRM10/Runtime/IO/Material/Vrm10MaterialDescriptorGeneratorUtility.cs.meta diff --git a/Assets/VRM10/Runtime/IO/Material/Vrm10MaterialExporterUtility.cs b/Assets/VRM10/Runtime/IO/Material/Vrm10MaterialExporterUtility.cs new file mode 100644 index 000000000..5f8e61397 --- /dev/null +++ b/Assets/VRM10/Runtime/IO/Material/Vrm10MaterialExporterUtility.cs @@ -0,0 +1,17 @@ +using UniGLTF; + +namespace UniVRM10 +{ + public static class Vrm10MaterialExporterUtility + { + public static IMaterialExporter GetValidVrm10MaterialExporter() + { + return RenderPipelineUtility.GetRenderPipelineType() switch + { + RenderPipelineTypes.UniversalRenderPipeline => throw new System.NotImplementedException(), + RenderPipelineTypes.BuiltinRenderPipeline => new BuiltInVrm10MaterialExporter(), + _ => new BuiltInVrm10MaterialExporter(), + }; + } + } +} \ No newline at end of file diff --git a/Assets/VRM10/Runtime/IO/Material/Vrm10MaterialExporterUtility.cs.meta b/Assets/VRM10/Runtime/IO/Material/Vrm10MaterialExporterUtility.cs.meta new file mode 100644 index 000000000..753c36dfc --- /dev/null +++ b/Assets/VRM10/Runtime/IO/Material/Vrm10MaterialExporterUtility.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6f58deb399404ebd81647dcf52ad7929 +timeCreated: 1722258791 \ No newline at end of file diff --git a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs index 79bdfc6e9..903ba4901 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs @@ -21,19 +21,22 @@ namespace UniVRM10 public readonly string VrmExtensionName = "VRMC_vrm"; + IMaterialExporter m_materialExporter; ITextureSerializer m_textureSerializer; TextureExporter m_textureExporter; GltfExportSettings m_settings; - public Vrm10Exporter(ITextureSerializer textureSerializer, GltfExportSettings settings) + public Vrm10Exporter( + GltfExportSettings settings, + IMaterialExporter materialExporter, + ITextureSerializer textureSerializer + ) { - m_settings = settings; - - if (textureSerializer == null) - { - throw new ArgumentException(nameof(textureSerializer)); - } + m_settings = settings ?? throw new ArgumentException(nameof(settings)); + m_materialExporter = materialExporter ?? throw new ArgumentException(nameof(materialExporter)); + m_textureSerializer = textureSerializer ?? throw new ArgumentException(nameof(textureSerializer)); + m_textureExporter = new TextureExporter(m_textureSerializer); Storage.Gltf.extensionsUsed.Add(glTF_KHR_texture_transform.ExtensionName); Storage.Gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_vrm.VRMC_vrm.ExtensionName); @@ -41,9 +44,6 @@ namespace UniVRM10 Storage.Gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_materials_mtoon.VRMC_materials_mtoon.ExtensionName); Storage.Gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_springBone.VRMC_springBone.ExtensionName); Storage.Gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint.ExtensionName); - - m_textureSerializer = textureSerializer; - m_textureExporter = new TextureExporter(m_textureSerializer); } public void Dispose() @@ -169,9 +169,8 @@ namespace UniVRM10 return reserveBytes; } - static IEnumerable ExportMaterials(Model model, ITextureExporter textureExporter, GltfExportSettings settings) + static IEnumerable ExportMaterials(Model model, IMaterialExporter materialExporter, ITextureExporter textureExporter, GltfExportSettings settings) { - var materialExporter = new BuiltInVrm10MaterialExporter(); foreach (Material material in model.Materials) { yield return materialExporter.ExportMaterial(material, textureExporter, settings); @@ -184,7 +183,7 @@ namespace UniVRM10 Storage.Reserve(CalcReserveBytes(model)); - foreach (var material in ExportMaterials(model, m_textureExporter, m_settings)) + foreach (var material in ExportMaterials(model, m_materialExporter, m_textureExporter, m_settings)) { Storage.Gltf.materials.Add(material); } @@ -916,7 +915,11 @@ namespace UniVRM10 /// /// /// - public static byte[] Export(GameObject go, ITextureSerializer textureSerializer = null, VRM10ObjectMeta vrmMeta = null) + public static byte[] Export( + GameObject go, + IMaterialExporter materialExporter = null, + ITextureSerializer textureSerializer = null, + VRM10ObjectMeta vrmMeta = null) { using (var arrayManager = new NativeArrayManager()) { @@ -928,7 +931,12 @@ namespace UniVRM10 model.ConvertCoordinate(VrmLib.Coordinates.Vrm1); // Model と go から VRM-1.0 にExport - var exporter10 = new Vrm10Exporter(textureSerializer ?? new RuntimeTextureSerializer(), new GltfExportSettings()); + var exporter10 = new Vrm10Exporter( + new GltfExportSettings(), + materialExporter ?? Vrm10MaterialExporterUtility.GetValidVrm10MaterialExporter(), + textureSerializer ?? new RuntimeTextureSerializer() + ); + var option = new VrmLib.ExportArgs { }; diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs index 96918786d..a9447fea7 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs @@ -41,7 +41,7 @@ namespace UniVRM10 m_useControlRig = useControlRig; TextureDescriptorGenerator = new Vrm10TextureDescriptorGenerator(Data); - MaterialDescriptorGenerator = materialGenerator ?? Vrm10MaterialDescriptorGeneratorDescriptorUtility.GetValidVrm10MaterialDescriptorGenerator(); + MaterialDescriptorGenerator = materialGenerator ?? Vrm10MaterialDescriptorGeneratorUtility.GetValidVrm10MaterialDescriptorGenerator(); m_externalMap = externalObjectMap; if (m_externalMap == null) diff --git a/Assets/VRM10/Runtime/IO/VrmAnimationExporter.cs b/Assets/VRM10/Runtime/IO/VrmAnimationExporter.cs index 4cda49aa5..d61369b64 100644 --- a/Assets/VRM10/Runtime/IO/VrmAnimationExporter.cs +++ b/Assets/VRM10/Runtime/IO/VrmAnimationExporter.cs @@ -80,7 +80,7 @@ namespace UniVRM10 public void Export(Action addFrames) { - base.Export(new RuntimeTextureSerializer()); + base.Export(); addFrames(this); diff --git a/Assets/VRM10/Tests/ApiSampleTests.cs b/Assets/VRM10/Tests/ApiSampleTests.cs index 326a2eee3..cc50aec15 100644 --- a/Assets/VRM10/Tests/ApiSampleTests.cs +++ b/Assets/VRM10/Tests/ApiSampleTests.cs @@ -46,7 +46,7 @@ namespace UniVRM10.Test Debug.Log(go); // export - var vrmBytes = Vrm10Exporter.Export(go, new EditorTextureSerializer()); + var vrmBytes = Vrm10Exporter.Export(go, textureSerializer: new EditorTextureSerializer()); Debug.Log($"export {vrmBytes.Length} bytes"); } diff --git a/Assets/VRM10_Samples/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs b/Assets/VRM10_Samples/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs index 76c5ebc2c..5accf8ca8 100644 --- a/Assets/VRM10_Samples/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs +++ b/Assets/VRM10_Samples/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs @@ -142,10 +142,11 @@ namespace UniVRM10.RuntimeExporterSample model.ConvertCoordinate(VrmLib.Coordinates.Vrm1, ignoreVrm: false); // export vrm-1.0 - var exporter = new UniVRM10.Vrm10Exporter(new RuntimeTextureSerializer(), new GltfExportSettings - { - - }); + var exporter = new Vrm10Exporter( + new GltfExportSettings(), + Vrm10MaterialExporterUtility.GetValidVrm10MaterialExporter(), + new RuntimeTextureSerializer() + ); exporter.Export(root, model, converter, new VrmLib.ExportArgs { }, meta); From 78a99fb9e966774439299126a50e92f6f33eb404 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Mon, 29 Jul 2024 22:33:51 +0900 Subject: [PATCH 08/16] use default arguments --- Assets/VRM10/Editor/Vrm10ExportDialog.cs | 3 +-- Assets/VRM10/Runtime/IO/Vrm10Exporter.cs | 15 +++++---------- .../VRM10RuntimeExporter.cs | 6 +----- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/Assets/VRM10/Editor/Vrm10ExportDialog.cs b/Assets/VRM10/Editor/Vrm10ExportDialog.cs index 8c463b5ec..a2c9195aa 100644 --- a/Assets/VRM10/Editor/Vrm10ExportDialog.cs +++ b/Assets/VRM10/Editor/Vrm10ExportDialog.cs @@ -313,8 +313,7 @@ namespace UniVRM10 // export vrm-1.0 var exporter = new Vrm10Exporter( m_settings.MeshExportSettings, - Vrm10MaterialExporterUtility.GetValidVrm10MaterialExporter(), - new EditorTextureSerializer() + textureSerializer: new EditorTextureSerializer() ); var option = new VrmLib.ExportArgs { diff --git a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs index 903ba4901..864c1e6ff 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs @@ -29,13 +29,13 @@ namespace UniVRM10 public Vrm10Exporter( GltfExportSettings settings, - IMaterialExporter materialExporter, - ITextureSerializer textureSerializer + IMaterialExporter materialExporter = null, + ITextureSerializer textureSerializer = null ) { m_settings = settings ?? throw new ArgumentException(nameof(settings)); - m_materialExporter = materialExporter ?? throw new ArgumentException(nameof(materialExporter)); - m_textureSerializer = textureSerializer ?? throw new ArgumentException(nameof(textureSerializer)); + m_materialExporter = materialExporter ?? Vrm10MaterialExporterUtility.GetValidVrm10MaterialExporter(); + m_textureSerializer = textureSerializer ?? new RuntimeTextureSerializer(); m_textureExporter = new TextureExporter(m_textureSerializer); Storage.Gltf.extensionsUsed.Add(glTF_KHR_texture_transform.ExtensionName); @@ -931,12 +931,7 @@ namespace UniVRM10 model.ConvertCoordinate(VrmLib.Coordinates.Vrm1); // Model と go から VRM-1.0 にExport - var exporter10 = new Vrm10Exporter( - new GltfExportSettings(), - materialExporter ?? Vrm10MaterialExporterUtility.GetValidVrm10MaterialExporter(), - textureSerializer ?? new RuntimeTextureSerializer() - ); - + var exporter10 = new Vrm10Exporter(new GltfExportSettings(), materialExporter, textureSerializer); var option = new VrmLib.ExportArgs { }; diff --git a/Assets/VRM10_Samples/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs b/Assets/VRM10_Samples/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs index 5accf8ca8..f76da8c6b 100644 --- a/Assets/VRM10_Samples/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs +++ b/Assets/VRM10_Samples/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs @@ -142,11 +142,7 @@ namespace UniVRM10.RuntimeExporterSample model.ConvertCoordinate(VrmLib.Coordinates.Vrm1, ignoreVrm: false); // export vrm-1.0 - var exporter = new Vrm10Exporter( - new GltfExportSettings(), - Vrm10MaterialExporterUtility.GetValidVrm10MaterialExporter(), - new RuntimeTextureSerializer() - ); + var exporter = new Vrm10Exporter(new GltfExportSettings()); exporter.Export(root, model, converter, new VrmLib.ExportArgs { }, meta); From 3fa8ec8a07087d2ddde0435d6c3f10c7a595c3bc Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Mon, 29 Jul 2024 23:34:39 +0900 Subject: [PATCH 09/16] Fixed an issue where unnecessary files were left behind after running tests. --- Assets/UniGLTF/Tests/UniGLTF/AssetTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Assets/UniGLTF/Tests/UniGLTF/AssetTests.cs b/Assets/UniGLTF/Tests/UniGLTF/AssetTests.cs index 50b0a6867..1fddabbee 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/AssetTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/AssetTests.cs @@ -33,6 +33,8 @@ namespace UniGLTF var tmp = AssetDatabase.LoadAssetAtPath(assetPath); Assert.Null(tmp); + + AssetDatabase.DeleteAsset(assetPath); } AssetDatabase.Refresh(); From c4e3f53d5d97c099d0481e84230db0fcc2e0dc58 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Mon, 29 Jul 2024 23:52:55 +0900 Subject: [PATCH 10/16] Move Test Assets --- Assets/UniGLTF/Tests/Objects.meta | 8 ++++ .../4x4_gray_import_as_linear.png | Bin .../4x4_gray_import_as_linear.png.meta | 17 +++++++- .../4x4_gray_import_as_normal_map.png | Bin .../4x4_gray_import_as_normal_map.png.meta | 17 +++++++- .../4x4_gray_import_as_srgb.png | Bin .../4x4_gray_import_as_srgb.png.meta | 17 +++++++- .../{UniGLTF => Objects}/4x4_non_readable.png | Bin .../4x4_non_readable.png.meta | 0 .../4x4_non_readable_compressed.DDS | Bin .../4x4_non_readable_compressed.DDS.meta | 0 .../{UniGLTF => Objects}/New Material.mat | 0 .../New Material.mat.meta | 0 .../UniGLTF/Tests/UniGLTF/CopyTextureTests.cs | 9 ++--- .../UniGLTF/EditorTextureSerializerTests.cs | 37 ++++++++++-------- Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs | 12 ++++++ .../UniGLTF/Tests/UniGLTF/TestAssets.cs.meta | 3 ++ .../Tests/UniGLTF/TextureBytesTests.cs | 7 +--- 18 files changed, 96 insertions(+), 31 deletions(-) create mode 100644 Assets/UniGLTF/Tests/Objects.meta rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_gray_import_as_linear.png (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_gray_import_as_linear.png.meta (86%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_gray_import_as_normal_map.png (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_gray_import_as_normal_map.png.meta (86%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_gray_import_as_srgb.png (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_gray_import_as_srgb.png.meta (86%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_non_readable.png (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_non_readable.png.meta (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_non_readable_compressed.DDS (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/4x4_non_readable_compressed.DDS.meta (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/New Material.mat (100%) rename Assets/UniGLTF/Tests/{UniGLTF => Objects}/New Material.mat.meta (100%) create mode 100644 Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs create mode 100644 Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs.meta diff --git a/Assets/UniGLTF/Tests/Objects.meta b/Assets/UniGLTF/Tests/Objects.meta new file mode 100644 index 000000000..895ef31b1 --- /dev/null +++ b/Assets/UniGLTF/Tests/Objects.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 257f9efac603801459934018928760de +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_linear.png b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_linear.png similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_linear.png rename to Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_linear.png diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_linear.png.meta b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_linear.png.meta similarity index 86% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_linear.png.meta rename to Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_linear.png.meta index 34e2b319c..8cff80177 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_linear.png.meta +++ b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_linear.png.meta @@ -3,7 +3,7 @@ guid: fc1ba24d4a4141d4d9e9ae0a0d3ecd0a TextureImporter: internalIDToNameTable: [] externalObjects: {} - serializedVersion: 11 + serializedVersion: 12 mipmaps: mipMapMode: 0 enableMipMap: 0 @@ -24,6 +24,7 @@ TextureImporter: streamingMipmaps: 0 streamingMipmapsPriority: 0 vTOnly: 0 + ignoreMasterTextureLimit: 0 grayScaleToAlpha: 0 generateCubemap: 6 cubemapConvolution: 0 @@ -62,6 +63,7 @@ TextureImporter: textureFormatSet: 0 ignorePngGamma: 0 applyGammaDecoding: 0 + cookieLightType: 1 platformSettings: - serializedVersion: 3 buildTarget: DefaultTexturePlatform @@ -99,6 +101,18 @@ TextureImporter: overridden: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 spriteSheet: serializedVersion: 2 sprites: [] @@ -112,6 +126,7 @@ TextureImporter: edges: [] weights: [] secondaryTextures: [] + nameFileIdTable: {} spritePackingTag: pSDRemoveMatte: 0 pSDShowRemoveMatteOption: 0 diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_normal_map.png b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_normal_map.png similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_normal_map.png rename to Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_normal_map.png diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_normal_map.png.meta b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_normal_map.png.meta similarity index 86% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_normal_map.png.meta rename to Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_normal_map.png.meta index 4862a8127..aa67d0199 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_normal_map.png.meta +++ b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_normal_map.png.meta @@ -3,7 +3,7 @@ guid: b5d17df8d14f2324692a7c69f24cf658 TextureImporter: internalIDToNameTable: [] externalObjects: {} - serializedVersion: 11 + serializedVersion: 12 mipmaps: mipMapMode: 0 enableMipMap: 1 @@ -24,6 +24,7 @@ TextureImporter: streamingMipmaps: 0 streamingMipmapsPriority: 0 vTOnly: 0 + ignoreMasterTextureLimit: 0 grayScaleToAlpha: 0 generateCubemap: 6 cubemapConvolution: 0 @@ -62,6 +63,7 @@ TextureImporter: textureFormatSet: 0 ignorePngGamma: 0 applyGammaDecoding: 0 + cookieLightType: 1 platformSettings: - serializedVersion: 3 buildTarget: DefaultTexturePlatform @@ -99,6 +101,18 @@ TextureImporter: overridden: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 spriteSheet: serializedVersion: 2 sprites: [] @@ -112,6 +126,7 @@ TextureImporter: edges: [] weights: [] secondaryTextures: [] + nameFileIdTable: {} spritePackingTag: pSDRemoveMatte: 0 pSDShowRemoveMatteOption: 0 diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_srgb.png b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_srgb.png similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_srgb.png rename to Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_srgb.png diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_srgb.png.meta b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_srgb.png.meta similarity index 86% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_srgb.png.meta rename to Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_srgb.png.meta index 39acaa02f..c2e9bfc6f 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/4x4_gray_import_as_srgb.png.meta +++ b/Assets/UniGLTF/Tests/Objects/4x4_gray_import_as_srgb.png.meta @@ -3,7 +3,7 @@ guid: 0f7acf68f1798ae48a5505519abac457 TextureImporter: internalIDToNameTable: [] externalObjects: {} - serializedVersion: 11 + serializedVersion: 12 mipmaps: mipMapMode: 0 enableMipMap: 0 @@ -24,6 +24,7 @@ TextureImporter: streamingMipmaps: 0 streamingMipmapsPriority: 0 vTOnly: 0 + ignoreMasterTextureLimit: 0 grayScaleToAlpha: 0 generateCubemap: 6 cubemapConvolution: 0 @@ -62,6 +63,7 @@ TextureImporter: textureFormatSet: 0 ignorePngGamma: 0 applyGammaDecoding: 0 + cookieLightType: 1 platformSettings: - serializedVersion: 3 buildTarget: DefaultTexturePlatform @@ -99,6 +101,18 @@ TextureImporter: overridden: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 spriteSheet: serializedVersion: 2 sprites: [] @@ -112,6 +126,7 @@ TextureImporter: edges: [] weights: [] secondaryTextures: [] + nameFileIdTable: {} spritePackingTag: pSDRemoveMatte: 0 pSDShowRemoveMatteOption: 0 diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable.png b/Assets/UniGLTF/Tests/Objects/4x4_non_readable.png similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable.png rename to Assets/UniGLTF/Tests/Objects/4x4_non_readable.png diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable.png.meta b/Assets/UniGLTF/Tests/Objects/4x4_non_readable.png.meta similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable.png.meta rename to Assets/UniGLTF/Tests/Objects/4x4_non_readable.png.meta diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable_compressed.DDS b/Assets/UniGLTF/Tests/Objects/4x4_non_readable_compressed.DDS similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable_compressed.DDS rename to Assets/UniGLTF/Tests/Objects/4x4_non_readable_compressed.DDS diff --git a/Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable_compressed.DDS.meta b/Assets/UniGLTF/Tests/Objects/4x4_non_readable_compressed.DDS.meta similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/4x4_non_readable_compressed.DDS.meta rename to Assets/UniGLTF/Tests/Objects/4x4_non_readable_compressed.DDS.meta diff --git a/Assets/UniGLTF/Tests/UniGLTF/New Material.mat b/Assets/UniGLTF/Tests/Objects/New Material.mat similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/New Material.mat rename to Assets/UniGLTF/Tests/Objects/New Material.mat diff --git a/Assets/UniGLTF/Tests/UniGLTF/New Material.mat.meta b/Assets/UniGLTF/Tests/Objects/New Material.mat.meta similarity index 100% rename from Assets/UniGLTF/Tests/UniGLTF/New Material.mat.meta rename to Assets/UniGLTF/Tests/Objects/New Material.mat.meta diff --git a/Assets/UniGLTF/Tests/UniGLTF/CopyTextureTests.cs b/Assets/UniGLTF/Tests/UniGLTF/CopyTextureTests.cs index 8170541d9..d8304c00b 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/CopyTextureTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/CopyTextureTests.cs @@ -1,13 +1,10 @@ using NUnit.Framework; -using UnityEditor; using UnityEngine; namespace UniGLTF { public sealed class CopyTextureTests { - private static string AssetPath = "Assets/VRMShaders/GLTF/IO/Tests"; - private static readonly Color32 Black = new Color32(0, 0, 0, 255); private static readonly Color32 Gray = new Color32(127, 127, 127, 255); private static readonly Color32 White = new Color32(255, 255, 255, 255); @@ -32,7 +29,7 @@ namespace UniGLTF [Test] public void CopyFromNonReadableSRgbPng() { - var nonReadableTex = AssetDatabase.LoadAssetAtPath($"{AssetPath}/4x4_non_readable.png"); + var nonReadableTex = TestAssets.LoadAsset("4x4_non_readable.png"); Assert.False(nonReadableTex.isReadable); var copiedTex = TextureConverter.CopyTexture(nonReadableTex, ColorSpace.sRGB, true, null); var pixels = copiedTex.GetPixels32(miplevel: 0); @@ -46,7 +43,7 @@ namespace UniGLTF [Test] public void CopyFromNonReadableSRgbDds() { - var compressedTex = AssetDatabase.LoadAssetAtPath($"{AssetPath}/4x4_non_readable_compressed.dds"); + var compressedTex = TestAssets.LoadAsset("4x4_non_readable_compressed.dds"); Assert.False(compressedTex.isReadable); var copiedTex = TextureConverter.CopyTexture(compressedTex, ColorSpace.sRGB, true, null); var pixels = copiedTex.GetPixels32(miplevel: 0); @@ -60,7 +57,7 @@ namespace UniGLTF [Test] public void CopyAttributes() { - var src = AssetDatabase.LoadAssetAtPath($"{AssetPath}/4x4_non_readable.png"); + var src = TestAssets.LoadAsset("4x4_non_readable.png"); var dst = TextureConverter.CopyTexture(src, ColorSpace.sRGB, false, null); Assert.AreEqual(src.name, dst.name); Assert.AreEqual(src.anisoLevel, dst.anisoLevel); diff --git a/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs b/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs index dbc1349e9..a0a128da1 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs @@ -1,18 +1,16 @@ using NUnit.Framework; -using UnityEditor; using UnityEngine; namespace UniGLTF { public sealed class EditorTextureSerializerTests { - private static readonly string AssetPath = "Assets/UniGLTF/Tests/UniGLTF"; private static readonly string SrgbGrayImageName = "4x4_gray_import_as_srgb"; private static readonly string LinearGrayImageName = "4x4_gray_import_as_linear"; private static readonly string NormalMapGrayImageName = "4x4_gray_import_as_normal_map"; - private static readonly Texture2D SrgbGrayTex = AssetDatabase.LoadAssetAtPath($"{AssetPath}/{SrgbGrayImageName}.png"); - private static readonly Texture2D LinearGrayTex = AssetDatabase.LoadAssetAtPath($"{AssetPath}/{LinearGrayImageName}.png"); - private static readonly Texture2D NormalMapGrayTex = AssetDatabase.LoadAssetAtPath($"{AssetPath}/{NormalMapGrayImageName}.png"); + private static readonly Texture2D SrgbGrayTex = TestAssets.LoadAsset($"{SrgbGrayImageName}.png"); + private static readonly Texture2D LinearGrayTex = TestAssets.LoadAsset($"{LinearGrayImageName}.png"); + private static readonly Texture2D NormalMapGrayTex = TestAssets.LoadAsset($"{NormalMapGrayImageName}.png"); private static readonly Color32 JustGray = new Color32(127, 127, 127, 255); private static readonly Color32 SrgbGrayInSrgb = JustGray; private static readonly Color32 SrgbGrayInLinear = ((Color)SrgbGrayInSrgb).linear; @@ -113,23 +111,28 @@ namespace UniGLTF { // Prepare var root = GameObject.CreatePrimitive(PrimitiveType.Cube); - var mat = new Material(Shader.Find("Standard")); + var mat = new Material(Shader.Find(BuiltInStandardMaterialExporter.TargetShaderName)); mat.SetTexture(propertyName, srcTex); root.GetComponentOrThrow().sharedMaterial = mat; // Export glTF var data = new ExportingGltfData(); - using (var exporter = new gltfExporter(data, new GltfExportSettings - { - InverseAxis = Axes.X, - ExportOnlyBlendShapePosition = false, - UseSparseAccessorForMorphTarget = false, - DivideVertexBuffer = false, - }, textureSerializer: new EditorTextureSerializer())) - { - exporter.Prepare(root); - exporter.Export(); - } + using var exporter = new gltfExporter( + data, + new GltfExportSettings + { + InverseAxis = Axes.X, + ExportOnlyBlendShapePosition = false, + UseSparseAccessorForMorphTarget = false, + DivideVertexBuffer = false, + }, + materialExporter: new BuiltInGltfMaterialExporter(), + textureSerializer: new EditorTextureSerializer() + ); + + exporter.Prepare(root); + exporter.Export(); + var gltf = data.Gltf; Assert.AreEqual(1, gltf.images.Count); var exportedImage = gltf.images[0]; diff --git a/Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs b/Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs new file mode 100644 index 000000000..96319bbf4 --- /dev/null +++ b/Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs @@ -0,0 +1,12 @@ +namespace UniGLTF +{ + public static class TestAssets + { + public static readonly string AssetPath = "Assets/UniGLTF/Tests/Objects"; + + public static T LoadAsset(string filename) where T : UnityEngine.Object + { + return UnityEditor.AssetDatabase.LoadAssetAtPath($"{AssetPath}/{filename}"); + } + } +} \ No newline at end of file diff --git a/Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs.meta b/Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs.meta new file mode 100644 index 000000000..ce8bf83a6 --- /dev/null +++ b/Assets/UniGLTF/Tests/UniGLTF/TestAssets.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8519ebb2f0f84833a752bb564b59c47c +timeCreated: 1722263712 \ No newline at end of file diff --git a/Assets/UniGLTF/Tests/UniGLTF/TextureBytesTests.cs b/Assets/UniGLTF/Tests/UniGLTF/TextureBytesTests.cs index f4ef96a2f..f99019151 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/TextureBytesTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/TextureBytesTests.cs @@ -1,17 +1,14 @@ using NUnit.Framework; -using UnityEditor; using UnityEngine; namespace UniGLTF { public class TextureBytesTests { - static string AssetPath = "Assets/VRMShaders/GLTF/IO/Tests"; - [Test] public void NonReadablePng() { - var nonReadableTex = AssetDatabase.LoadAssetAtPath($"{AssetPath}/4x4_non_readable.png"); + var nonReadableTex = TestAssets.LoadAsset("4x4_non_readable.png"); Assert.False(nonReadableTex.isReadable); var (bytes, mime) = new EditorTextureSerializer().ExportBytesWithMime(nonReadableTex, ColorSpace.sRGB); Assert.NotNull(bytes); @@ -20,7 +17,7 @@ namespace UniGLTF [Test] public void NonReadableDds() { - var readonlyTexture = AssetDatabase.LoadAssetAtPath($"{AssetPath}/4x4_non_readable_compressed.dds"); + var readonlyTexture = TestAssets.LoadAsset("4x4_non_readable_compressed.dds"); Assert.False(readonlyTexture.isReadable); var (bytes, mime) = new EditorTextureSerializer().ExportBytesWithMime(readonlyTexture, ColorSpace.sRGB); Assert.NotNull(bytes); From eff55a9465dbb397b83ed8f413b84981595869f9 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Tue, 30 Jul 2024 00:05:24 +0900 Subject: [PATCH 11/16] Fix Vrm10 Tests --- Assets/VRM10/Tests/ApiSampleTests.cs | 41 ++++------------------------ Assets/VRM10/Tests/MigrationTests.cs | 6 ++-- Assets/VRM10/Tests/TestAsset.cs | 5 +--- Assets/VRM10/Tests/TestVrm10.cs | 37 +++++++++++++++++++++++++ Assets/VRM10/Tests/TestVrm10.cs.meta | 3 ++ 5 files changed, 50 insertions(+), 42 deletions(-) create mode 100644 Assets/VRM10/Tests/TestVrm10.cs create mode 100644 Assets/VRM10/Tests/TestVrm10.cs.meta diff --git a/Assets/VRM10/Tests/ApiSampleTests.cs b/Assets/VRM10/Tests/ApiSampleTests.cs index cc50aec15..3f9d1f58f 100644 --- a/Assets/VRM10/Tests/ApiSampleTests.cs +++ b/Assets/VRM10/Tests/ApiSampleTests.cs @@ -7,49 +7,20 @@ namespace UniVRM10.Test { public class ApiSampleTests { - VrmLib.Model ReadModel(string path) - { - var bytes = MigrationVrm.Migrate(File.ReadAllBytes(path)); - - var data = new GlbLowLevelParser(path, bytes).Parse(); - - var model = ModelReader.Read(data); - return model; - } - - GameObject BuildGameObject(Vrm10Data data, bool showMesh) - { - using (var loader = new Vrm10Importer(data, null)) - { - var loaded = loader.Load(); - if (showMesh) - { - loaded.ShowMeshes(); - } - loaded.EnableUpdateWhenOffscreen(); - return loaded.gameObject; - } - } - [Test] public void Sample() { var path = "Tests/Models/Alicia_vrm-0.51/AliciaSolid_vrm-0.51.vrm"; Debug.Log($"load: {path}"); - using (var data = new GlbFileParser(path).Parse()) - using (var migrated = Vrm10Data.Migrate(data, out Vrm10Data result, out MigrationData migration)) - { - Assert.NotNull(result); + var instance = TestVrm10.LoadPathAsBuiltInRP(path, canLoadVrm0X: true); + Assert.NotNull(instance); - var go = BuildGameObject(result, true); - Debug.Log(go); + var go = instance.gameObject; + Debug.Log(go); - // export - var vrmBytes = Vrm10Exporter.Export(go, textureSerializer: new EditorTextureSerializer()); - - Debug.Log($"export {vrmBytes.Length} bytes"); - } + var vrmBytes = TestVrm10.ExportAsBuiltInRP(go); + Debug.Log($"export {vrmBytes.Length} bytes"); } } } diff --git a/Assets/VRM10/Tests/MigrationTests.cs b/Assets/VRM10/Tests/MigrationTests.cs index 09add1b02..999584449 100644 --- a/Assets/VRM10/Tests/MigrationTests.cs +++ b/Assets/VRM10/Tests/MigrationTests.cs @@ -197,7 +197,7 @@ namespace UniVRM10 { try { - Vrm10.LoadPathAsync(gltf.FullName, true, controlRigGenerationOption: ControlRigGenerationOption.None).Wait(); + TestVrm10.LoadPathAsBuiltInRP(gltf.FullName); } catch (UnNormalizedException) { @@ -372,7 +372,7 @@ namespace UniVRM10 new Color(2.0f, 2.0f, 2.0f, 1), }; - var instance106 = Vrm10.LoadBytesAsync(model106, awaitCaller: new ImmediateCaller()).Result; + var instance106 = TestVrm10.LoadBytesAsBuiltInRP(model106); var materials106 = instance106.GetComponent().Materials; Assert.AreEqual(materialCount, materials106.Count); for (var idx = 0; idx < materialCount; ++idx) @@ -384,7 +384,7 @@ namespace UniVRM10 if (correctEmissions[idx].HasValue) AssertAreApproximatelyEqualColor(correctEmissions[idx].Value, material.GetColor(emissionName)); } - var instance107 = Vrm10.LoadBytesAsync(model107, awaitCaller: new ImmediateCaller()).Result; + var instance107 = TestVrm10.LoadBytesAsBuiltInRP(model107); var materials107 = instance107.GetComponent().Materials; Assert.AreEqual(materialCount, materials107.Count); for (var idx = 0; idx < materialCount; ++idx) diff --git a/Assets/VRM10/Tests/TestAsset.cs b/Assets/VRM10/Tests/TestAsset.cs index 6077c2c44..5982583ee 100644 --- a/Assets/VRM10/Tests/TestAsset.cs +++ b/Assets/VRM10/Tests/TestAsset.cs @@ -16,10 +16,7 @@ namespace UniVRM10 public static Vrm10Instance LoadAlicia() { - var task = Vrm10.LoadPathAsync(AliciaPath, canLoadVrm0X: true); - task.Wait(); - var instance = task.Result; - + var instance = TestVrm10.LoadPathAsBuiltInRP(AliciaPath, canLoadVrm0X: true); return instance.GetComponent(); } } diff --git a/Assets/VRM10/Tests/TestVrm10.cs b/Assets/VRM10/Tests/TestVrm10.cs new file mode 100644 index 000000000..108c6d321 --- /dev/null +++ b/Assets/VRM10/Tests/TestVrm10.cs @@ -0,0 +1,37 @@ +using UniGLTF; +using UnityEngine; + +namespace UniVRM10 +{ + public static class TestVrm10 + { + public static Vrm10Instance LoadBytesAsBuiltInRP(byte[] bytes, bool canLoadVrm0X = true) + { + return Vrm10.LoadBytesAsync( + bytes, + canLoadVrm0X: canLoadVrm0X, + awaitCaller: new ImmediateCaller(), + materialGenerator: new BuiltInVrm10MaterialDescriptorGenerator() + ).Result; + } + + public static Vrm10Instance LoadPathAsBuiltInRP(string path, bool canLoadVrm0X = true) + { + return Vrm10.LoadPathAsync( + path, + canLoadVrm0X: canLoadVrm0X, + awaitCaller: new ImmediateCaller(), + materialGenerator: new BuiltInVrm10MaterialDescriptorGenerator() + ).Result; + } + + public static byte[] ExportAsBuiltInRP(GameObject gameObject) + { + return Vrm10Exporter.Export( + gameObject, + materialExporter: new BuiltInVrm10MaterialExporter(), + textureSerializer: new EditorTextureSerializer() + ); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10/Tests/TestVrm10.cs.meta b/Assets/VRM10/Tests/TestVrm10.cs.meta new file mode 100644 index 000000000..69837185f --- /dev/null +++ b/Assets/VRM10/Tests/TestVrm10.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4c9e0897ac194db3b7a55132871e6d75 +timeCreated: 1722265007 \ No newline at end of file From ccf3a16b98512dabf735b794b72ef2f1da5d187c Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Tue, 30 Jul 2024 00:30:22 +0900 Subject: [PATCH 12/16] Fix VRM0X Tests --- Assets/VRM/Editor/Format/VRMEditorExporter.cs | 19 ++++++--- .../Tests/SampleTests/VRMImportExportTests.cs | 22 +++++++---- Assets/VRM/Tests/TestVrm0X.cs | 32 +++++++++++++++ Assets/VRM/Tests/TestVrm0X.cs.meta | 3 ++ Assets/VRM/Tests/VRMLookAtTests.cs | 39 +++++++------------ Assets/VRM/Tests/VrmDividedMeshTests.cs | 12 +++++- 6 files changed, 86 insertions(+), 41 deletions(-) create mode 100644 Assets/VRM/Tests/TestVrm0X.cs create mode 100644 Assets/VRM/Tests/TestVrm0X.cs.meta diff --git a/Assets/VRM/Editor/Format/VRMEditorExporter.cs b/Assets/VRM/Editor/Format/VRMEditorExporter.cs index c4489d7a4..6e48f7d88 100644 --- a/Assets/VRM/Editor/Format/VRMEditorExporter.cs +++ b/Assets/VRM/Editor/Format/VRMEditorExporter.cs @@ -16,12 +16,17 @@ namespace VRM /// /// 出力先 /// エクスポート設定 - public static byte[] Export(GameObject exportRoot, VRMMetaObject meta, VRMExportSettings settings) + public static byte[] Export( + GameObject exportRoot, + VRMMetaObject meta, + VRMExportSettings settings, + IMaterialExporter materialExporter = null + ) { List destroy = new List(); try { - return Export(exportRoot, meta, settings, destroy); + return Export(exportRoot, meta, settings, materialExporter, destroy); } finally { @@ -143,9 +148,12 @@ namespace VRM /// /// /// 作業が終わったらDestoryするべき一時オブジェクト - static byte[] Export(GameObject exportRoot, VRMMetaObject meta, - VRMExportSettings settings, - List destroy) + private static byte[] Export( + GameObject exportRoot, + VRMMetaObject meta, + VRMExportSettings settings, + IMaterialExporter materialExporter, + List destroy) { var target = exportRoot; @@ -227,6 +235,7 @@ namespace VRM var gltfExportSettings = settings.GltfExportSettings; using (var exporter = new VRMExporter(data, gltfExportSettings, animationExporter: settings.KeepAnimation ? new EditorAnimationExporter() : null, + materialExporter: materialExporter, textureSerializer: new EditorTextureSerializer())) { exporter.Prepare(target); diff --git a/Assets/VRM/Tests/SampleTests/VRMImportExportTests.cs b/Assets/VRM/Tests/SampleTests/VRMImportExportTests.cs index 9cf0e3591..d0ce6b581 100644 --- a/Assets/VRM/Tests/SampleTests/VRMImportExportTests.cs +++ b/Assets/VRM/Tests/SampleTests/VRMImportExportTests.cs @@ -33,9 +33,11 @@ namespace VRM.Samples public void ImportExportTest() { var path = AliciaPath; - using (var data = new GlbFileParser(path).Parse()) - using (var context = new VRMImporterContext(new VRMData(data))) - using (var loaded = context.Load()) + using var data = new GlbFileParser(path).Parse(); + var vrmData = new VRMData(data); + var materialGenerator = new BuiltInVrmMaterialDescriptorGenerator(vrmData.VrmExtension); + using var context = new VRMImporterContext(vrmData, materialGenerator: materialGenerator); + using var loaded = context.Load(); { loaded.ShowMeshes(); loaded.EnableUpdateWhenOffscreen(); @@ -126,9 +128,11 @@ namespace VRM.Samples public void MeshCopyTest() { var path = AliciaPath; - using (var data = new GlbFileParser(path).Parse()) - using (var context = new VRMImporterContext(new VRMData(data))) - using (var loaded = context.Load()) + using var data = new GlbFileParser(path).Parse(); + var vrmData = new VRMData(data); + var materialGenerator = new BuiltInVrmMaterialDescriptorGenerator(vrmData.VrmExtension); + using var context = new VRMImporterContext(vrmData, materialGenerator: materialGenerator); + using var loaded = context.Load(); { loaded.ShowMeshes(); loaded.EnableUpdateWhenOffscreen(); @@ -147,8 +151,10 @@ namespace VRM.Samples // Aliciaを古いデシリアライザでロードする var path = AliciaPath; - using (var data = new GlbFileParser(path).Parse()) - using (var context = new VRMImporterContext(new VRMData(data))) + using var data = new GlbFileParser(path).Parse(); + var vrmData = new VRMData(data); + var materialGenerator = new BuiltInVrmMaterialDescriptorGenerator(vrmData.VrmExtension); + using var context = new VRMImporterContext(vrmData, materialGenerator: materialGenerator); { var oldJson = context.GLTF.ToJson().ParseAsJson().ToString(" "); diff --git a/Assets/VRM/Tests/TestVrm0X.cs b/Assets/VRM/Tests/TestVrm0X.cs new file mode 100644 index 000000000..6f99e905d --- /dev/null +++ b/Assets/VRM/Tests/TestVrm0X.cs @@ -0,0 +1,32 @@ +using UniGLTF; +using UnityEngine; + +namespace VRM +{ + public static class TestVrm0X + { + public static RuntimeGltfInstance LoadBytesAsBuiltInRP(byte[] bytes) + { + return VrmUtility.LoadBytesAsync( + "", + bytes, + awaitCaller: new ImmediateCaller(), + materialGeneratorCallback: x => new BuiltInVrmMaterialDescriptorGenerator(x) + ).Result; + } + + public static RuntimeGltfInstance LoadPathAsBuiltInRP(string path) + { + return VrmUtility.LoadAsync( + path, + awaitCaller: new ImmediateCaller(), + materialGeneratorCallback: x => new BuiltInVrmMaterialDescriptorGenerator(x) + ).Result; + } + + public static byte[] ExportAsBuiltInRP(GameObject gameObject, VRMExportSettings exportSettings) + { + return VRMEditorExporter.Export(gameObject, null, exportSettings, new BuiltInVrmMaterialExporter()); + } + } +} \ No newline at end of file diff --git a/Assets/VRM/Tests/TestVrm0X.cs.meta b/Assets/VRM/Tests/TestVrm0X.cs.meta new file mode 100644 index 000000000..32d715a00 --- /dev/null +++ b/Assets/VRM/Tests/TestVrm0X.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 47b1209d83114ccbaa0bf02436b8eb04 +timeCreated: 1722265572 \ No newline at end of file diff --git a/Assets/VRM/Tests/VRMLookAtTests.cs b/Assets/VRM/Tests/VRMLookAtTests.cs index a9a07b4a3..40d9424aa 100644 --- a/Assets/VRM/Tests/VRMLookAtTests.cs +++ b/Assets/VRM/Tests/VRMLookAtTests.cs @@ -21,11 +21,8 @@ namespace VRM [Test] public void VRMLookAtTest() { - var data = new GlbFileParser(AliciaPath).Parse(); byte[] bytes = default; - using (data) - using (var loader = new VRMImporterContext(new VRMData(data))) - using (var loaded = loader.Load()) + using var loaded = TestVrm0X.LoadPathAsBuiltInRP(AliciaPath); { loaded.ShowMeshes(); @@ -35,12 +32,12 @@ namespace VRM var lookAt = go.AddComponent(); var settings = (VRMExportSettings)ScriptableObject.CreateInstance(); settings.PoseFreeze = true; - bytes = VRMEditorExporter.Export(go, null, settings); - } + bytes = TestVrm0X.ExportAsBuiltInRP(go, settings); + } - using (var data2 = new GlbLowLevelParser(AliciaPath, bytes).Parse()) - using (var loader2 = new VRMImporterContext(new VRMData(data2))) { + using var data2 = new GlbLowLevelParser(AliciaPath, bytes).Parse(); + using var loader2 = new VRMImporterContext(new VRMData(data2)); Assert.AreEqual(LookAtType.BlendShape, loader2.VRM.firstPerson.lookAtType); } } @@ -48,13 +45,10 @@ namespace VRM [Test] public void VRMLookAtCurveMapWithFreezeTest() { - var data = new GlbFileParser(AliciaPath).Parse(); - byte[] bytes = default; + byte[] bytes; CurveMapper horizontalInner = default; - using (data) - using (var loader = new VRMImporterContext(new VRMData(data))) - using (var loaded = loader.Load()) { + using var loaded = TestVrm0X.LoadPathAsBuiltInRP(AliciaPath); loaded.ShowMeshes(); var go = loaded.gameObject; @@ -63,13 +57,11 @@ namespace VRM horizontalInner = lookAt.HorizontalInner; var settings = ScriptableObject.CreateInstance(); settings.PoseFreeze = true; - bytes = VRMEditorExporter.Export(go, null, settings); + bytes = TestVrm0X.ExportAsBuiltInRP(go, settings); } - using (var data2 = new GlbLowLevelParser(AliciaPath, bytes).Parse()) - using (var loader = new VRMImporterContext(new VRMData(data2))) - using (var loaded = loader.Load()) { + using var loaded = TestVrm0X.LoadBytesAsBuiltInRP(bytes); loaded.ShowMeshes(); var lookAt = loaded.GetComponent(); @@ -81,13 +73,10 @@ namespace VRM [Test] public void VRMLookAtCurveMapTest() { - var data = new GlbFileParser(AliciaPath).Parse(); - byte[] bytes = default; + byte[] bytes; CurveMapper horizontalInner = default; - using (data) - using (var loader = new VRMImporterContext(new VRMData(data))) - using (var loaded = loader.Load()) { + using var loaded = TestVrm0X.LoadPathAsBuiltInRP(AliciaPath); loaded.ShowMeshes(); var go = loaded.gameObject; @@ -96,13 +85,11 @@ namespace VRM horizontalInner = lookAt.HorizontalInner; var settings = (VRMExportSettings)ScriptableObject.CreateInstance(); settings.PoseFreeze = false; - bytes = VRMEditorExporter.Export(go, null, settings); + bytes = TestVrm0X.ExportAsBuiltInRP(go, settings); } - using (var data2 = new GlbLowLevelParser(AliciaPath, bytes).Parse()) - using (var loader = new VRMImporterContext(new VRMData(data2))) - using (var loaded = loader.Load()) { + using var loaded = TestVrm0X.LoadBytesAsBuiltInRP(bytes); loaded.ShowMeshes(); var lookAt = loaded.GetComponent(); diff --git a/Assets/VRM/Tests/VrmDividedMeshTests.cs b/Assets/VRM/Tests/VrmDividedMeshTests.cs index 543b10486..658cda4eb 100644 --- a/Assets/VRM/Tests/VrmDividedMeshTests.cs +++ b/Assets/VRM/Tests/VrmDividedMeshTests.cs @@ -67,13 +67,21 @@ namespace VRM var path = AliciaPath; var loaded = Load(File.ReadAllBytes(path), path); - var exported = VRMExporter.Export(new UniGLTF.GltfExportSettings + var exportSettings = new GltfExportSettings { DivideVertexBuffer = true, // test this ExportOnlyBlendShapePosition = true, ExportTangents = false, UseSparseAccessorForMorphTarget = true, - }, loaded, new EditorTextureSerializer()); + }; + var exported = new ExportingGltfData(); + using var exporter = new VRMExporter( + exported, + exportSettings, + textureSerializer: new EditorTextureSerializer(), + materialExporter: new BuiltInVrmMaterialExporter()); + exporter.Prepare(loaded); + exporter.Export(); var bytes = exported.ToGlbBytes(); var divided = Load(bytes, path); From 9171280dffa4b85325b6c173c4d15686f83714fb Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Tue, 30 Jul 2024 00:46:08 +0900 Subject: [PATCH 13/16] Fix GLTF tests --- Assets/UniGLTF/Tests/UniGLTF/TestGltf.cs | 52 ++++++++++++++ Assets/UniGLTF/Tests/UniGLTF/TestGltf.cs.meta | 3 + Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs | 67 ++++++------------- 3 files changed, 74 insertions(+), 48 deletions(-) create mode 100644 Assets/UniGLTF/Tests/UniGLTF/TestGltf.cs create mode 100644 Assets/UniGLTF/Tests/UniGLTF/TestGltf.cs.meta diff --git a/Assets/UniGLTF/Tests/UniGLTF/TestGltf.cs b/Assets/UniGLTF/Tests/UniGLTF/TestGltf.cs new file mode 100644 index 000000000..36baddf65 --- /dev/null +++ b/Assets/UniGLTF/Tests/UniGLTF/TestGltf.cs @@ -0,0 +1,52 @@ +using UnityEngine; + +namespace UniGLTF +{ + public static class TestGltf + { + public static RuntimeGltfInstance LoadBytesAsBuiltInRP(byte[] bytes) + { + return GltfUtility.LoadBytesAsync( + "", + bytes, + awaitCaller: new ImmediateCaller(), + materialGenerator: new BuiltInGltfMaterialDescriptorGenerator() + ).Result; + } + + public static RuntimeGltfInstance LoadPathAsBuiltInRP(string path) + { + return GltfUtility.LoadAsync( + path, + awaitCaller: new ImmediateCaller(), + materialGenerator: new BuiltInGltfMaterialDescriptorGenerator() + ).Result; + } + + public static ExportingGltfData ExportAsBuiltInRP(GameObject gameObject, GltfExportSettings exportSettings = null) + { + var data = new ExportingGltfData(); + using var exporter = new gltfExporter( + data, + exportSettings ?? new GltfExportSettings(), + progress: new EditorProgress(), + animationExporter: new EditorAnimationExporter(), + materialExporter: new BuiltInGltfMaterialExporter(), + textureSerializer: new EditorTextureSerializer() + ); + exporter.Prepare(gameObject); + exporter.Export(); + + return data; + } + + public static GameObject CreatePrimitiveAsBuiltInRP(PrimitiveType primitiveType) + { + var go = GameObject.CreatePrimitive(primitiveType); + var shader = Shader.Find("Standard"); + var material = new Material(shader); + go.GetComponent().sharedMaterial = material; + return go; + } + } +} \ No newline at end of file diff --git a/Assets/UniGLTF/Tests/UniGLTF/TestGltf.cs.meta b/Assets/UniGLTF/Tests/UniGLTF/TestGltf.cs.meta new file mode 100644 index 000000000..affb261b4 --- /dev/null +++ b/Assets/UniGLTF/Tests/UniGLTF/TestGltf.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 11719ab072944cc2b7c0eaafa0cdff2e +timeCreated: 1722267047 \ No newline at end of file diff --git a/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs b/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs index 99ad080f6..a96368fc3 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs @@ -100,18 +100,17 @@ namespace UniGLTF // export var data = new ExportingGltfData(); + using var exporter = new gltfExporter( + data, + new GltfExportSettings(), + materialExporter: new BuiltInGltfMaterialExporter()); + exporter.Prepare(go); + exporter.Export(); - string json = null; - using (var exporter = new gltfExporter(data, new GltfExportSettings())) - { - exporter.Prepare(go); - exporter.Export(); + // remove empty buffer + data.Gltf.buffers.Clear(); - // remove empty buffer - data.Gltf.buffers.Clear(); - - json = data.Gltf.ToJson(); - } + var json = data.Gltf.ToJson(); // parse using (var parsed = GltfData.CreateFromExportForTest(data)) @@ -353,12 +352,7 @@ namespace UniGLTF [Test] public void GlTFToJsonTest() { - var data = new ExportingGltfData(); - using (var exporter = new gltfExporter(data, new GltfExportSettings())) - { - exporter.Prepare(CreateSimpleScene()); - exporter.Export(); - } + var data = TestGltf.ExportAsBuiltInRP(CreateSimpleScene()); var expected = data.Gltf.ToJson().ParseAsJson(); expected.AddKey(Utf8String.From("meshes")); @@ -565,7 +559,7 @@ namespace UniGLTF { var shader = Shader.Find("Unlit/Color"); - var cubeA = GameObject.CreatePrimitive(PrimitiveType.Cube); + var cubeA = TestGltf.CreatePrimitiveAsBuiltInRP(PrimitiveType.Cube); { cubeA.transform.SetParent(go.transform); var material = new Material(shader); @@ -586,16 +580,8 @@ namespace UniGLTF } // export - var data = new ExportingGltfData(); + var data = TestGltf.ExportAsBuiltInRP(go); var gltf = data.Gltf; - var json = default(string); - using (var exporter = new gltfExporter(data, new GltfExportSettings())) - { - exporter.Prepare(go); - exporter.Export(); - - json = gltf.ToJson(); - } Assert.AreEqual(2, gltf.meshes.Count); @@ -658,22 +644,14 @@ namespace UniGLTF try { { - var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); + var cube = TestGltf.CreatePrimitiveAsBuiltInRP(PrimitiveType.Cube); cube.transform.SetParent(go.transform); UnityEngine.Object.DestroyImmediate(cube.GetComponent()); } // export - var data = new ExportingGltfData(); + var data = TestGltf.ExportAsBuiltInRP(go); var gltf = data.Gltf; - string json; - using (var exporter = new gltfExporter(data, new GltfExportSettings())) - { - exporter.Prepare(go); - exporter.Export(); - - json = gltf.ToJson(); - } Assert.AreEqual(0, gltf.meshes.Count); Assert.AreEqual(1, gltf.nodes.Count); @@ -682,7 +660,7 @@ namespace UniGLTF // import using (var parsed = GltfData.CreateFromExportForTest(data)) { - using (var context = new ImporterContext(parsed)) + using (var context = new ImporterContext(parsed, materialGenerator: new BuiltInGltfMaterialDescriptorGenerator())) using (var loaded = context.Load()) { Assert.AreEqual(1, loaded.transform.GetChildren().Count()); @@ -708,14 +686,14 @@ namespace UniGLTF try { { - var child = GameObject.CreatePrimitive(PrimitiveType.Cube); + var child = TestGltf.CreatePrimitiveAsBuiltInRP(PrimitiveType.Cube); child.transform.SetParent(root.transform); // remove MeshFilter Component.DestroyImmediate(child.GetComponent()); } { - var child = GameObject.CreatePrimitive(PrimitiveType.Cube); + var child = TestGltf.CreatePrimitiveAsBuiltInRP(PrimitiveType.Cube); child.transform.SetParent(root.transform); // set null child.GetComponent().sharedMesh = null; @@ -727,16 +705,9 @@ namespace UniGLTF Assert.True(vs.All(x => x.CanExport)); // export - var data = new ExportingGltfData(); + var data = TestGltf.ExportAsBuiltInRP(root); var gltf = data.Gltf; - string json; - using (var exporter = new gltfExporter(data, new GltfExportSettings())) - { - exporter.Prepare(root); - exporter.Export(); - - json = gltf.ToJson(); - } + var json = gltf.ToJson(); Assert.AreEqual(0, gltf.meshes.Count); Assert.AreEqual(2, gltf.nodes.Count); From d5cffceca0fc5adca679c773e1d7470dcd99e685 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Tue, 30 Jul 2024 23:11:35 +0900 Subject: [PATCH 14/16] glTF ScriptedImporter can detect project's RenderPipeline or select manually. --- .../GltfScriptedImporterBase.cs | 45 +++++++------------ .../ImporterRenderPipelineTypes.cs | 9 ++++ .../ImporterRenderPipelineTypes.cs.meta | 3 ++ .../MaterialDescriptorGeneratorUtility.cs | 7 ++- 4 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ImporterRenderPipelineTypes.cs create mode 100644 Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ImporterRenderPipelineTypes.cs.meta diff --git a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporterBase.cs b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporterBase.cs index 4637c4ecb..9cf0a2113 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporterBase.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporterBase.cs @@ -20,34 +20,7 @@ namespace UniGLTF [SerializeField] [Header("Experimental")] - public RenderPipelineTypes m_renderPipeline; - - void OnValidate() - { - if (m_renderPipeline == UniGLTF.RenderPipelineTypes.UniversalRenderPipeline) - { - if (Shader.Find(UniGLTF.UrpGltfPbrMaterialImporter.ShaderName) == null) - { - Debug.LogWarning("URP is not installed. Force to BuiltinRenderPipeline"); - m_renderPipeline = UniGLTF.RenderPipelineTypes.BuiltinRenderPipeline; - } - } - } - - static IMaterialDescriptorGenerator GetMaterialGenerator(RenderPipelineTypes renderPipeline) - { - switch (renderPipeline) - { - case RenderPipelineTypes.BuiltinRenderPipeline: - return new BuiltInGltfMaterialDescriptorGenerator(); - - case RenderPipelineTypes.UniversalRenderPipeline: - return new UrpGltfMaterialDescriptorGenerator(); - - default: - throw new System.NotImplementedException(); - } - } + public ImporterRenderPipelineTypes m_renderPipeline; /// /// glb をパースして、UnityObject化、さらにAsset化する @@ -55,7 +28,8 @@ namespace UniGLTF /// /// /// - protected static void Import(ScriptedImporter scriptedImporter, AssetImportContext context, Axes reverseAxis, RenderPipelineTypes renderPipeline) + /// + protected static void Import(ScriptedImporter scriptedImporter, AssetImportContext context, Axes reverseAxis, ImporterRenderPipelineTypes renderPipeline) { UniGLTFLogger.Log("OnImportAsset to " + scriptedImporter.assetPath); @@ -68,7 +42,7 @@ namespace UniGLTF .Where(x => x.Value != null) .ToDictionary(kv => new SubAssetKey(kv.Value.GetType(), kv.Key.name), kv => kv.Value); - IMaterialDescriptorGenerator materialGenerator = GetMaterialGenerator(renderPipeline); + var materialGenerator = GetMaterialDescriptorGenerator(renderPipeline); using (var data = new AutoGltfFileParser(scriptedImporter.assetPath).Parse()) using (var loader = new ImporterContext(data, extractedObjects, materialGenerator: materialGenerator)) @@ -94,5 +68,16 @@ namespace UniGLTF context.SetMainObject(root); } } + + private static IMaterialDescriptorGenerator GetMaterialDescriptorGenerator(ImporterRenderPipelineTypes renderPipeline) + { + return renderPipeline switch + { + ImporterRenderPipelineTypes.Auto => MaterialDescriptorGeneratorUtility .GetValidGltfMaterialDescriptorGenerator(), + ImporterRenderPipelineTypes.BuiltinRenderPipeline => MaterialDescriptorGeneratorUtility .GetGltfMaterialDescriptorGenerator(RenderPipelineTypes.BuiltinRenderPipeline), + ImporterRenderPipelineTypes.UniversalRenderPipeline => MaterialDescriptorGeneratorUtility .GetGltfMaterialDescriptorGenerator(RenderPipelineTypes.UniversalRenderPipeline), + _ => MaterialDescriptorGeneratorUtility.GetValidGltfMaterialDescriptorGenerator(), + }; + } } } diff --git a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ImporterRenderPipelineTypes.cs b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ImporterRenderPipelineTypes.cs new file mode 100644 index 000000000..0acad15f1 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ImporterRenderPipelineTypes.cs @@ -0,0 +1,9 @@ +namespace UniGLTF +{ + public enum ImporterRenderPipelineTypes + { + Auto = 0, + BuiltinRenderPipeline = 1, + UniversalRenderPipeline = 2, + } +} \ No newline at end of file diff --git a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ImporterRenderPipelineTypes.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ImporterRenderPipelineTypes.cs.meta new file mode 100644 index 000000000..fcc3507a5 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ImporterRenderPipelineTypes.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d4f38213d6e442ef986fd3e633991ba7 +timeCreated: 1722347490 \ No newline at end of file diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialDescriptorGeneratorUtility.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialDescriptorGeneratorUtility.cs index dee8cba3d..97dda7c77 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialDescriptorGeneratorUtility.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialDescriptorGeneratorUtility.cs @@ -4,7 +4,12 @@ namespace UniGLTF { public static IMaterialDescriptorGenerator GetValidGltfMaterialDescriptorGenerator() { - return RenderPipelineUtility.GetRenderPipelineType() switch + return GetGltfMaterialDescriptorGenerator(RenderPipelineUtility.GetRenderPipelineType()); + } + + public static IMaterialDescriptorGenerator GetGltfMaterialDescriptorGenerator(RenderPipelineTypes renderPipelineType) + { + return renderPipelineType switch { RenderPipelineTypes.UniversalRenderPipeline => new UrpGltfMaterialDescriptorGenerator(), RenderPipelineTypes.BuiltinRenderPipeline => new BuiltInGltfMaterialDescriptorGenerator(), From 6dba5bdf7199c391a781db7a1d1322369946e235 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Tue, 30 Jul 2024 23:12:02 +0900 Subject: [PATCH 15/16] VRM10 ScriptedImporter can detect project's RenderPipeline or select manually. --- .../VrmMaterialDescriptorGeneratorUtility.cs | 7 +++- .../ScriptedImporter/VrmScriptedImporter.cs | 17 ++------- .../VrmScriptedImporterImpl.cs | 37 ++++++++++--------- ...Vrm10MaterialDescriptorGeneratorUtility.cs | 7 +++- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialDescriptorGeneratorUtility.cs b/Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialDescriptorGeneratorUtility.cs index f13e9e92a..6aa838ca1 100644 --- a/Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialDescriptorGeneratorUtility.cs +++ b/Assets/VRM/Runtime/IO/MaterialIO/VrmMaterialDescriptorGeneratorUtility.cs @@ -6,7 +6,12 @@ namespace VRM { public static IMaterialDescriptorGenerator GetValidVrmMaterialDescriptorGenerator(glTF_VRM_extensions vrm) { - return RenderPipelineUtility.GetRenderPipelineType() switch + return GetVrmMaterialDescriptorGenerator(vrm, RenderPipelineUtility.GetRenderPipelineType()); + } + + public static IMaterialDescriptorGenerator GetVrmMaterialDescriptorGenerator(glTF_VRM_extensions vrm, RenderPipelineTypes renderPipelineType) + { + return renderPipelineType switch { RenderPipelineTypes.UniversalRenderPipeline => new UrpVrmMaterialDescriptorGenerator(vrm), RenderPipelineTypes.BuiltinRenderPipeline => new BuiltInVrmMaterialDescriptorGenerator(vrm), diff --git a/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporter.cs b/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporter.cs index be82aec15..2981e8ead 100644 --- a/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporter.cs +++ b/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporter.cs @@ -1,4 +1,5 @@ -using UnityEngine; +using UniGLTF; +using UnityEngine; #if UNITY_2020_2_OR_NEWER using UnityEditor.AssetImporters; #else @@ -15,23 +16,11 @@ namespace UniVRM10 public bool MigrateToVrm1 = default; [SerializeField] - public UniGLTF.RenderPipelineTypes RenderPipeline = default; + public ImporterRenderPipelineTypes RenderPipeline = default; public override void OnImportAsset(AssetImportContext ctx) { VrmScriptedImporterImpl.Import(this, ctx, MigrateToVrm1, RenderPipeline); } - - void OnValidate() - { - if (RenderPipeline == UniGLTF.RenderPipelineTypes.UniversalRenderPipeline) - { - if (Shader.Find(UniGLTF.UrpGltfPbrMaterialImporter.ShaderName) == null) - { - Debug.LogWarning("URP is not installed. Force to BuiltinRenderPipeline"); - RenderPipeline = UniGLTF.RenderPipelineTypes.BuiltinRenderPipeline; - } - } - } } } diff --git a/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporterImpl.cs b/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporterImpl.cs index 32ef5d600..395cc480b 100644 --- a/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporterImpl.cs +++ b/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporterImpl.cs @@ -15,23 +15,7 @@ namespace UniVRM10 { public static class VrmScriptedImporterImpl { - static IMaterialDescriptorGenerator GetMaterialDescriptorGenerator(RenderPipelineTypes renderPipeline) - { - var settings = Vrm10ProjectEditorSettings.instance; - if (settings.MaterialDescriptorGeneratorFactory != null) - { - return settings.MaterialDescriptorGeneratorFactory.Create(); - } - - return renderPipeline switch - { - RenderPipelineTypes.BuiltinRenderPipeline => new BuiltInVrm10MaterialDescriptorGenerator(), - RenderPipelineTypes.UniversalRenderPipeline => new UrpVrm10MaterialDescriptorGenerator(), - _ => throw new NotImplementedException() - }; - } - - static void Process(Vrm10Data result, ScriptedImporter scriptedImporter, AssetImportContext context, RenderPipelineTypes renderPipeline) + static void Process(Vrm10Data result, ScriptedImporter scriptedImporter, AssetImportContext context, ImporterRenderPipelineTypes renderPipeline) { // // Import(create unity objects) @@ -73,7 +57,7 @@ namespace UniVRM10 /// vrm0 だった場合に vrm1 化する /// /// normalize する - public static void Import(ScriptedImporter scriptedImporter, AssetImportContext context, bool doMigrate, RenderPipelineTypes renderPipeline) + public static void Import(ScriptedImporter scriptedImporter, AssetImportContext context, bool doMigrate, ImporterRenderPipelineTypes renderPipeline) { if (Symbols.VRM_DEVELOP) { @@ -113,5 +97,22 @@ namespace UniVRM10 return; } } + + private static IMaterialDescriptorGenerator GetMaterialDescriptorGenerator(ImporterRenderPipelineTypes renderPipeline) + { + var settings = Vrm10ProjectEditorSettings.instance; + if (settings.MaterialDescriptorGeneratorFactory != null) + { + return settings.MaterialDescriptorGeneratorFactory.Create(); + } + + return renderPipeline switch + { + ImporterRenderPipelineTypes.Auto => Vrm10MaterialDescriptorGeneratorUtility.GetValidVrm10MaterialDescriptorGenerator(), + ImporterRenderPipelineTypes.BuiltinRenderPipeline => Vrm10MaterialDescriptorGeneratorUtility.GetVrm10MaterialDescriptorGenerator(RenderPipelineTypes.BuiltinRenderPipeline), + ImporterRenderPipelineTypes.UniversalRenderPipeline => Vrm10MaterialDescriptorGeneratorUtility.GetVrm10MaterialDescriptorGenerator(RenderPipelineTypes.UniversalRenderPipeline), + _ => Vrm10MaterialDescriptorGeneratorUtility.GetValidVrm10MaterialDescriptorGenerator(), + }; + } } } \ No newline at end of file diff --git a/Assets/VRM10/Runtime/IO/Material/Vrm10MaterialDescriptorGeneratorUtility.cs b/Assets/VRM10/Runtime/IO/Material/Vrm10MaterialDescriptorGeneratorUtility.cs index d45c4741d..3dcdc745c 100644 --- a/Assets/VRM10/Runtime/IO/Material/Vrm10MaterialDescriptorGeneratorUtility.cs +++ b/Assets/VRM10/Runtime/IO/Material/Vrm10MaterialDescriptorGeneratorUtility.cs @@ -6,7 +6,12 @@ namespace UniVRM10 { public static IMaterialDescriptorGenerator GetValidVrm10MaterialDescriptorGenerator() { - return RenderPipelineUtility.GetRenderPipelineType() switch + return GetVrm10MaterialDescriptorGenerator(RenderPipelineUtility.GetRenderPipelineType()); + } + + public static IMaterialDescriptorGenerator GetVrm10MaterialDescriptorGenerator(RenderPipelineTypes renderPipelineType) + { + return renderPipelineType switch { RenderPipelineTypes.UniversalRenderPipeline => new UrpVrm10MaterialDescriptorGenerator(), RenderPipelineTypes.BuiltinRenderPipeline => new BuiltInVrm10MaterialDescriptorGenerator(), From 7fa6e894acfa423cb42957057cf77f93c49e091e Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Tue, 30 Jul 2024 23:12:33 +0900 Subject: [PATCH 16/16] remove experimental --- .../Editor/UniGLTF/ScriptedImporter/GltfScriptedImporterBase.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporterBase.cs b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporterBase.cs index 9cf0a2113..f467c9d3c 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporterBase.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/GltfScriptedImporterBase.cs @@ -19,7 +19,6 @@ namespace UniGLTF public ScriptedImporterAxes m_reverseAxis = default; [SerializeField] - [Header("Experimental")] public ImporterRenderPipelineTypes m_renderPipeline; ///