diff --git a/Assets/VRM/Runtime/IO/VRMExporter.cs b/Assets/VRM/Runtime/IO/VRMExporter.cs
index 907b1aad9..edcdde0ef 100644
--- a/Assets/VRM/Runtime/IO/VRMExporter.cs
+++ b/Assets/VRM/Runtime/IO/VRMExporter.cs
@@ -28,10 +28,15 @@ namespace VRM
public VRMExporter(ExportingGltfData data, GltfExportSettings exportSettings, IAnimationExporter animationExporter = null) : base(
data, exportSettings, animationExporter: animationExporter)
{
- if (exportSettings == null || exportSettings.InverseAxis != Vrm0xSpecificationInverseAxis)
+ if (exportSettings == null)
{
throw new Exception($"VRM specification requires InverseAxis settings as {Vrm0xSpecificationInverseAxis}");
}
+ if (exportSettings.InverseAxis != Vrm0xSpecificationInverseAxis)
+ {
+ // migration 用に reverseX を許す
+ Debug.LogWarning($"VRM specification requires InverseAxis settings as {Vrm0xSpecificationInverseAxis}");
+ }
_gltf.extensionsUsed.Add(glTF_VRM_extensions.ExtensionName);
}
diff --git a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs
index e93cbcbf1..270966a4a 100644
--- a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs
+++ b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs
@@ -672,7 +672,7 @@ namespace UniVRM10
};
}
- static int? ExportMeta(UniGLTF.Extensions.VRMC_vrm.VRMC_vrm vrm, VRM10ObjectMeta meta, ITextureExporter textureExporter)
+ public static int? ExportMeta(UniGLTF.Extensions.VRMC_vrm.VRMC_vrm vrm, VRM10ObjectMeta meta, ITextureExporter textureExporter)
{
vrm.Meta.Name = meta.Name;
vrm.Meta.Version = meta.Version;
diff --git a/Assets/VRM10/Runtime/Migration/MigrationApi.cs b/Assets/VRM10/Runtime/Migration/MigrationApi.cs
new file mode 100644
index 000000000..170e9a377
--- /dev/null
+++ b/Assets/VRM10/Runtime/Migration/MigrationApi.cs
@@ -0,0 +1,20 @@
+using System;
+
+namespace UniVRM10
+{
+ public static class MigrationApi
+ {
+ ///
+ /// マイグレーションの公開API
+ ///
+ /// MigrationVrm とその関連実装は、internal で runtime import 専用
+ ///
+ ///
+ ///
+ ///
+ public static byte[] Migrate(byte[] vrm0bytes, VRM10ObjectMeta meta)
+ {
+ return MigrationVrm.Migrate(vrm0bytes, meta);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/VRM10/Runtime/Migration/MigrationApi.cs.meta b/Assets/VRM10/Runtime/Migration/MigrationApi.cs.meta
new file mode 100644
index 000000000..96948be1d
--- /dev/null
+++ b/Assets/VRM10/Runtime/Migration/MigrationApi.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: be52b15d95590934b93e744181762dfe
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/VRM10/Runtime/Migration/MigrationVrm.cs b/Assets/VRM10/Runtime/Migration/MigrationVrm.cs
index b4bc5e288..2b69bc2d0 100644
--- a/Assets/VRM10/Runtime/Migration/MigrationVrm.cs
+++ b/Assets/VRM10/Runtime/Migration/MigrationVrm.cs
@@ -15,11 +15,11 @@ namespace UniVRM10
///
static internal class MigrationVrm
{
- public static byte[] Migrate(byte[] src)
+ public static byte[] Migrate(byte[] src, VRM10ObjectMeta meta = null)
{
using (var data = new GlbBinaryParser(src, "migration").Parse())
{
- return Migrate(data);
+ return Migrate(data, meta);
}
}
@@ -35,7 +35,10 @@ namespace UniVRM10
return (min, max);
}
- public static byte[] Migrate(GltfData data)
+ /// vrm0 をパースしたデータ
+ /// migration 時に合成するライセンス情報
+ ///
+ public static byte[] Migrate(GltfData data, VRM10ObjectMeta meta = null)
{
// VRM0 -> Unity
var model = ModelReader.Read(data, VrmLib.Coordinates.Vrm0);
@@ -51,7 +54,7 @@ namespace UniVRM10
gltf.extensionsUsed.Remove("VRM");
}
- return MigrateVrm(gltf, bin, data.Json.ParseAsJson()["extensions"]["VRM"]);
+ return MigrateVrm(gltf, bin, data.Json.ParseAsJson()["extensions"]["VRM"], meta);
}
///
@@ -68,7 +71,7 @@ namespace UniVRM10
}
}
- static byte[] MigrateVrm(glTF gltf, ArraySegment bin, JsonNode vrm0)
+ static byte[] MigrateVrm(glTF gltf, ArraySegment bin, JsonNode vrm0, VRM10ObjectMeta meta)
{
var meshToNode = CreateMeshToNode(gltf);
@@ -80,8 +83,24 @@ namespace UniVRM10
};
gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_vrm.VRMC_vrm.ExtensionName);
- // meta (required)
- vrm1.Meta = MigrationVrmMeta.Migrate(gltf, vrm0["meta"]);
+ if (meta == null)
+ {
+ // migrate from vrm-0.x
+ vrm1.Meta = MigrationVrmMeta.Migrate(gltf, vrm0["meta"]);
+ }
+ else
+ {
+ // inject from arg
+ vrm1.Meta = new UniGLTF.Extensions.VRMC_vrm.Meta
+ {
+ LicenseUrl = Vrm10Exporter.LICENSE_URL_JA,
+ AllowExcessivelySexualUsage = false,
+ AllowExcessivelyViolentUsage = false,
+ AllowPoliticalOrReligiousUsage = false,
+ AllowRedistribution = false,
+ };
+ Vrm10Exporter.ExportMeta(vrm1, meta, null);
+ }
// humanoid (required)
vrm1.Humanoid = MigrationVrmHumanoid.Migrate(vrm0["humanoid"]);
diff --git a/Assets/VRM_BOTH_Samples.meta b/Assets/VRM_BOTH_Samples.meta
new file mode 100644
index 000000000..e49c92f00
--- /dev/null
+++ b/Assets/VRM_BOTH_Samples.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: c99f52afa0263124e87a9016b287a244
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/VRM_BOTH_Samples/MigrateExporter.meta b/Assets/VRM_BOTH_Samples/MigrateExporter.meta
new file mode 100644
index 000000000..d58306d74
--- /dev/null
+++ b/Assets/VRM_BOTH_Samples/MigrateExporter.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 158a2cd31973b9a4faba49afbbb8bbc6
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/VRM_BOTH_Samples/MigrateExporter/MigrateExporter.cs b/Assets/VRM_BOTH_Samples/MigrateExporter/MigrateExporter.cs
new file mode 100644
index 000000000..d381f9d0d
--- /dev/null
+++ b/Assets/VRM_BOTH_Samples/MigrateExporter/MigrateExporter.cs
@@ -0,0 +1,56 @@
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using UnityEngine;
+
+[DisallowMultipleComponent]
+public class MigrateExporter : MonoBehaviour
+{
+ [SerializeField]
+ UniVRM10.VRM10ObjectMeta _meta = new UniVRM10.VRM10ObjectMeta();
+
+ async void OnGUI()
+ {
+ // validate
+ foreach (var validation in _meta.Validate(null))
+ {
+ GUILayout.Label("meta validation: " + validation.Message);
+ if (!validation.CanExport)
+ {
+ GUI.enabled = false;
+ }
+ }
+
+ if (GUILayout.Button("migrate"))
+ {
+ var path = UnityEditor.EditorUtility.OpenFilePanel("load vrm-0.x", null, "vrm");
+ if (string.IsNullOrEmpty(path))
+ {
+ return;
+ }
+
+ Debug.Log(path);
+ var bytes = File.ReadAllBytes(path);
+
+ // load
+ var vrm0Instance = await VRM.VrmUtility.LoadBytesAsync(path, bytes);
+
+ // export設定
+ var exportConfig = new UniGLTF.GltfExportSettings
+ {
+ };
+ // export vrm0
+ var vrm0 = VRM.VRMExporter.Export(exportConfig,
+ vrm0Instance.gameObject, new VRMShaders.RuntimeTextureSerializer());
+ var vrm0bytes = vrm0.ToGlbBytes();
+
+ // migrate to vrm1
+ var vrm1Bytes = UniVRM10.MigrationApi.Migrate(vrm0bytes, _meta);
+ var pathObj = VRMShaders.PathObject.FromFullPath(path);
+ var newPath = pathObj.Parent.Child(pathObj.Stem + ".10.vrm");
+ newPath.WriteAllBytes(vrm1Bytes);
+ Debug.Log($"export to: {newPath}");
+ }
+ }
+}
diff --git a/Assets/VRM_BOTH_Samples/MigrateExporter/MigrateExporter.cs.meta b/Assets/VRM_BOTH_Samples/MigrateExporter/MigrateExporter.cs.meta
new file mode 100644
index 000000000..727096df7
--- /dev/null
+++ b/Assets/VRM_BOTH_Samples/MigrateExporter/MigrateExporter.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 057dcb5c6b50f574795f903ac5989b8d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/VRM_BOTH_Samples/MigrateExporter/MigrateExporter.unity b/Assets/VRM_BOTH_Samples/MigrateExporter/MigrateExporter.unity
new file mode 100644
index 000000000..56fa2bc1e
--- /dev/null
+++ b/Assets/VRM_BOTH_Samples/MigrateExporter/MigrateExporter.unity
@@ -0,0 +1,271 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!29 &1
+OcclusionCullingSettings:
+ m_ObjectHideFlags: 0
+ serializedVersion: 2
+ m_OcclusionBakeSettings:
+ smallestOccluder: 5
+ smallestHole: 0.25
+ backfaceThreshold: 100
+ m_SceneGUID: 00000000000000000000000000000000
+ m_OcclusionCullingData: {fileID: 0}
+--- !u!104 &2
+RenderSettings:
+ m_ObjectHideFlags: 0
+ serializedVersion: 9
+ m_Fog: 0
+ m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
+ m_FogMode: 3
+ m_FogDensity: 0.01
+ m_LinearFogStart: 0
+ m_LinearFogEnd: 300
+ m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
+ m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
+ m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
+ m_AmbientIntensity: 1
+ m_AmbientMode: 0
+ m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
+ m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
+ m_HaloStrength: 0.5
+ m_FlareStrength: 1
+ m_FlareFadeSpeed: 3
+ m_HaloTexture: {fileID: 0}
+ m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
+ m_DefaultReflectionMode: 0
+ m_DefaultReflectionResolution: 128
+ m_ReflectionBounces: 1
+ m_ReflectionIntensity: 1
+ m_CustomReflection: {fileID: 0}
+ m_Sun: {fileID: 0}
+ m_IndirectSpecularColor: {r: 0.12731749, g: 0.13414757, b: 0.1210787, a: 1}
+ m_UseRadianceAmbientProbe: 0
+--- !u!157 &3
+LightmapSettings:
+ m_ObjectHideFlags: 0
+ serializedVersion: 12
+ m_GIWorkflowMode: 1
+ m_GISettings:
+ serializedVersion: 2
+ m_BounceScale: 1
+ m_IndirectOutputScale: 1
+ m_AlbedoBoost: 1
+ m_EnvironmentLightingMode: 0
+ m_EnableBakedLightmaps: 1
+ m_EnableRealtimeLightmaps: 0
+ m_LightmapEditorSettings:
+ serializedVersion: 12
+ m_Resolution: 2
+ m_BakeResolution: 40
+ m_AtlasSize: 1024
+ m_AO: 0
+ m_AOMaxDistance: 1
+ m_CompAOExponent: 1
+ m_CompAOExponentDirect: 0
+ m_ExtractAmbientOcclusion: 0
+ m_Padding: 2
+ m_LightmapParameters: {fileID: 0}
+ m_LightmapsBakeMode: 1
+ m_TextureCompression: 1
+ m_FinalGather: 0
+ m_FinalGatherFiltering: 1
+ m_FinalGatherRayCount: 256
+ m_ReflectionCompression: 2
+ m_MixedBakeMode: 2
+ m_BakeBackend: 1
+ m_PVRSampling: 1
+ m_PVRDirectSampleCount: 32
+ m_PVRSampleCount: 512
+ m_PVRBounces: 2
+ m_PVREnvironmentSampleCount: 256
+ m_PVREnvironmentReferencePointCount: 2048
+ m_PVRFilteringMode: 1
+ m_PVRDenoiserTypeDirect: 1
+ m_PVRDenoiserTypeIndirect: 1
+ m_PVRDenoiserTypeAO: 1
+ m_PVRFilterTypeDirect: 0
+ m_PVRFilterTypeIndirect: 0
+ m_PVRFilterTypeAO: 0
+ m_PVREnvironmentMIS: 1
+ m_PVRCulling: 1
+ m_PVRFilteringGaussRadiusDirect: 1
+ m_PVRFilteringGaussRadiusIndirect: 5
+ m_PVRFilteringGaussRadiusAO: 2
+ m_PVRFilteringAtrousPositionSigmaDirect: 0.5
+ m_PVRFilteringAtrousPositionSigmaIndirect: 2
+ m_PVRFilteringAtrousPositionSigmaAO: 1
+ m_ExportTrainingData: 0
+ m_TrainingDataDestination: TrainingData
+ m_LightProbeSampleCountMultiplier: 4
+ m_LightingDataAsset: {fileID: 0}
+ m_LightingSettings: {fileID: 0}
+--- !u!196 &4
+NavMeshSettings:
+ serializedVersion: 2
+ m_ObjectHideFlags: 0
+ m_BuildSettings:
+ serializedVersion: 2
+ agentTypeID: 0
+ agentRadius: 0.5
+ agentHeight: 2
+ agentSlope: 45
+ agentClimb: 0.4
+ ledgeDropHeight: 0
+ maxJumpAcrossDistance: 0
+ minRegionArea: 2
+ manualCellSize: 0
+ cellSize: 0.16666667
+ manualTileSize: 0
+ tileSize: 256
+ accuratePlacement: 0
+ maxJobWorkers: 0
+ preserveTilesOutsideBounds: 0
+ debug:
+ m_Flags: 0
+ m_NavMeshData: {fileID: 0}
+--- !u!1 &540916040
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 540916043}
+ - component: {fileID: 540916042}
+ - component: {fileID: 540916041}
+ m_Layer: 0
+ m_Name: Camera
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!81 &540916041
+AudioListener:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 540916040}
+ m_Enabled: 1
+--- !u!20 &540916042
+Camera:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 540916040}
+ m_Enabled: 1
+ serializedVersion: 2
+ m_ClearFlags: 1
+ m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
+ m_projectionMatrixMode: 1
+ m_GateFitMode: 2
+ m_FOVAxisMode: 0
+ m_SensorSize: {x: 36, y: 24}
+ m_LensShift: {x: 0, y: 0}
+ m_FocalLength: 50
+ m_NormalizedViewPortRect:
+ serializedVersion: 2
+ x: 0
+ y: 0
+ width: 1
+ height: 1
+ near clip plane: 0.3
+ far clip plane: 1000
+ field of view: 60
+ orthographic: 0
+ orthographic size: 5
+ m_Depth: 0
+ m_CullingMask:
+ serializedVersion: 2
+ m_Bits: 4294967295
+ m_RenderingPath: -1
+ m_TargetTexture: {fileID: 0}
+ m_TargetDisplay: 0
+ m_TargetEye: 3
+ m_HDR: 1
+ m_AllowMSAA: 1
+ m_AllowDynamicResolution: 0
+ m_ForceIntoRT: 0
+ m_OcclusionCulling: 1
+ m_StereoConvergence: 10
+ m_StereoSeparation: 0.022
+--- !u!4 &540916043
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 540916040}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 4.9861307, y: -1.2857006, z: -12.386837}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_RootOrder: 1
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!1 &2054562369
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 2054562371}
+ - component: {fileID: 2054562370}
+ m_Layer: 0
+ m_Name: MigrateExporter
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!114 &2054562370
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 2054562369}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 057dcb5c6b50f574795f903ac5989b8d, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ _meta:
+ Name: MigrateExporter
+ Version:
+ Authors:
+ - MigrateExporterAuthor0
+ CopyrightInformation:
+ ContactInformation:
+ References: []
+ ThirdPartyLicenses:
+ Thumbnail: {fileID: 0}
+ AvatarPermission: 0
+ ViolentUsage: 0
+ SexualUsage: 0
+ CommercialUsage: 0
+ PoliticalOrReligiousUsage: 0
+ AntisocialOrHateUsage: 0
+ CreditNotation: 0
+ Redistribution: 0
+ Modification: 0
+ OtherLicenseUrl:
+--- !u!4 &2054562371
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 2054562369}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0, y: 0, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_RootOrder: 0
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
diff --git a/Assets/VRM_BOTH_Samples/MigrateExporter/MigrateExporter.unity.meta b/Assets/VRM_BOTH_Samples/MigrateExporter/MigrateExporter.unity.meta
new file mode 100644
index 000000000..2a586fcdc
--- /dev/null
+++ b/Assets/VRM_BOTH_Samples/MigrateExporter/MigrateExporter.unity.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 5c0c00c31e7afc64bbdfaf0286ac1f5d
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/VRM_BOTH_Samples/MigrateExporter/README.md b/Assets/VRM_BOTH_Samples/MigrateExporter/README.md
new file mode 100644
index 000000000..ca0648b31
--- /dev/null
+++ b/Assets/VRM_BOTH_Samples/MigrateExporter/README.md
@@ -0,0 +1,24 @@
+# Migration
+
+- for runtime
+- Convert export vrm0 model directly to vrm1
+- input: vrm0 hierarchy + vrm1 meta
+- output: vrm1 binary
+
+## detail
+
+最初に vrm0 モデルをエクスポートします。
+このとき後で vrm1 化する前提で通常とは別の設定にします。
+
+- 正規化しない
+- z+ もしくは 左手系のまま進める
+- divided vertex buffer(glb 向けに実装済み)
+
+得られた、vrm0 バイナリを migrate します。
+このとき、vrm1 の meta を外部から注入することで
+ユーザー入力無しでの migration で `完全な` vrm1 を出力します。
+
+結果に対して vrm1 バリデーション。
+
+- https://github.com/vrm-c/glTF-Validator/pull/1
+
diff --git a/Assets/VRM_BOTH_Samples/MigrateExporter/README.md.meta b/Assets/VRM_BOTH_Samples/MigrateExporter/README.md.meta
new file mode 100644
index 000000000..2703b0002
--- /dev/null
+++ b/Assets/VRM_BOTH_Samples/MigrateExporter/README.md.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 07cbd8332c1ad0645b7a7d2b51456558
+TextScriptImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant: