esperecyan / VRMConverterForVRChat

https://pokemori.booth.pm/items/1025226
Mozilla Public License 2.0
189 stars 23 forks source link

Allow bones to be renamed to proper names when converting from VRChat to VRM #51

Open SorcererPonse opened 2 years ago

SorcererPonse commented 2 years ago

So on this avatar: Fina

There is an error when attempting to create an avatar from the VRM file: http://puu.sh/JnPug/41c3be814d.png

Would it be possible for there to be some way to rename the bones during the conversion process? Since this avatar has a large list of bones named like this:

http://puu.sh/JnPvO/0889c41622.png

and then some, it would likely be a lot easier if they could be batch renamed instead of having to rename each one individually.

esperecyan commented 2 years ago

Is the VRM file that causes this error the VRM prefab right after import? The avatar in the link already looks like an avatar for VRChat, is there a VRM file included? For now, please copy and paste the full text of each error.

SorcererPonse commented 2 years ago

The VRM prefab after import is what causes the issue, the converter itself is able to properly convert it into a VRM file. There is no VRM file included, one must be made from the avatar in order to have one, which is what I did. The solution I found was to manually modify the FBX file and rename all of the bones and vertex groups to their proper names in order to convert the avatar into a VRM. My apologies for my wording as well; I am not creating a VRChat avatar from a VRM file, but rather a VRM file from a VRChat avatar. For now, here are the errors that this specific avatar causes:

AvatarBuilder 'Fina_PB(Clone)(normalized)': Ambiguous Transform 'Armature/HipsBone/LeftUpperLegBone' and 'AvaterSetting/PB_colider/LeftUpperLegBone' found in hierarchy for human bone 'LeftUpperLeg'. Transform name mapped to a human bone must be unique.
UnityEngine.AvatarBuilder:BuildHumanAvatar (UnityEngine.GameObject,UnityEngine.HumanDescription)
UniHumanoid.AvatarDescription:CreateAvatar (UnityEngine.Transform) (at Library/PackageCache/com.vrmc.gltf@0.99.4/Runtime/UniHumanoid/AvatarDescription.cs:125)
VRM.VRMBoneNormalizer/<>c__DisplayClass1_0:<Execute>b__0 (UnityEngine.GameObject,UnityEngine.GameObject,System.Collections.Generic.Dictionary`2<UnityEngine.Transform, UnityEngine.Transform>) (at Library/PackageCache/com.vrmc.univrm@0.99.4/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs:105)
UniGLTF.MeshUtility.BoneNormalizer:NormalizeHierarchy (UnityEngine.GameObject,UniGLTF.MeshUtility.BoneNormalizer/CreateAvatarFunc) (at Library/PackageCache/com.vrmc.gltf@0.99.4/Runtime/MeshUtility/BoneNormalizer.cs:29)
UniGLTF.MeshUtility.BoneNormalizer:Execute (UnityEngine.GameObject,UniGLTF.MeshUtility.BoneNormalizer/CreateAvatarFunc) (at Library/PackageCache/com.vrmc.gltf@0.99.4/Runtime/MeshUtility/BoneNormalizer.cs:493)
VRM.VRMBoneNormalizer:Execute (UnityEngine.GameObject,bool) (at Library/PackageCache/com.vrmc.univrm@0.99.4/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs:70)
Esperecyan.Unity.VRMConverterForVRChat.VRChatToVRM.VRChatToVRMConverter:Convert (string,string,UnityEngine.GameObject,VRM.VRMMetaObject,System.Collections.Generic.IDictionary`2<Esperecyan.Unity.VRMConverterForVRChat.VRChatToVRM.ExpressionPreset, Esperecyan.Unity.VRMConverterForVRChat.VRChatToVRM.VRChatExpressionBinding>,bool) (at Library/PackageCache/jp.pokemori.vrm-converter-for-vrchat@38.2.0/Editor/VRChatToVRM/VRChatToVRMConverter.cs:132)
Esperecyan.Unity.VRMConverterForVRChat.UI.VRChatToVRMWizard:OnWizardCreate () (at Library/PackageCache/jp.pokemori.vrm-converter-for-vrchat@38.2.0/Editor/UI/VRChatToVRMWizard.cs:315)
UnityEngine.GUIUtility:ProcessEvent (int,intptr)

AvatarBuilder 'temporary(Clone)(normalized)': Required human bone 'Hips' not found
UnityEngine.AvatarBuilder:BuildHumanAvatar (UnityEngine.GameObject,UnityEngine.HumanDescription)
UniHumanoid.AvatarDescription:CreateAvatar (UnityEngine.Transform) (at Library/PackageCache/com.vrmc.gltf@0.99.4/Runtime/UniHumanoid/AvatarDescription.cs:125)
VRM.VRMBoneNormalizer/<>c__DisplayClass1_0:<Execute>b__0 (UnityEngine.GameObject,UnityEngine.GameObject,System.Collections.Generic.Dictionary`2<UnityEngine.Transform, UnityEngine.Transform>) (at Library/PackageCache/com.vrmc.univrm@0.99.4/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs:105)
UniGLTF.MeshUtility.BoneNormalizer:NormalizeHierarchy (UnityEngine.GameObject,UniGLTF.MeshUtility.BoneNormalizer/CreateAvatarFunc) (at Library/PackageCache/com.vrmc.gltf@0.99.4/Runtime/MeshUtility/BoneNormalizer.cs:29)
UniGLTF.MeshUtility.BoneNormalizer:Execute (UnityEngine.GameObject,UniGLTF.MeshUtility.BoneNormalizer/CreateAvatarFunc) (at Library/PackageCache/com.vrmc.gltf@0.99.4/Runtime/MeshUtility/BoneNormalizer.cs:493)
VRM.VRMBoneNormalizer:Execute (UnityEngine.GameObject,bool) (at Library/PackageCache/com.vrmc.univrm@0.99.4/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs:70)
VRM.VRMEditorExporter:Export (UnityEngine.GameObject,VRM.VRMMetaObject,VRM.VRMExportSettings,System.Collections.Generic.List`1<UnityEngine.GameObject>) (at Library/PackageCache/com.vrmc.univrm@0.99.4/Editor/Format/VRMEditorExporter.cs:199)
VRM.VRMEditorExporter:Export (UnityEngine.GameObject,VRM.VRMMetaObject,VRM.VRMExportSettings) (at Library/PackageCache/com.vrmc.univrm@0.99.4/Editor/Format/VRMEditorExporter.cs:24)
Esperecyan.Unity.VRMConverterForVRChat.VRChatToVRM.VRChatToVRMConverter:Convert (string,string,UnityEngine.GameObject,VRM.VRMMetaObject,System.Collections.Generic.IDictionary`2<Esperecyan.Unity.VRMConverterForVRChat.VRChatToVRM.ExpressionPreset, Esperecyan.Unity.VRMConverterForVRChat.VRChatToVRM.VRChatExpressionBinding>,bool) (at Library/PackageCache/jp.pokemori.vrm-converter-for-vrchat@38.2.0/Editor/VRChatToVRM/VRChatToVRMConverter.cs:179)
Esperecyan.Unity.VRMConverterForVRChat.UI.VRChatToVRMWizard:OnWizardCreate () (at Library/PackageCache/jp.pokemori.vrm-converter-for-vrchat@38.2.0/Editor/UI/VRChatToVRMWizard.cs:315)
UnityEngine.GUIUtility:ProcessEvent (int,intptr)

AvatarBuilder 'VRM': Required human bone 'LeftUpperLeg' not found
UnityEngine.AvatarBuilder:BuildHumanAvatar (UnityEngine.GameObject,UnityEngine.HumanDescription)
UniHumanoid.AvatarDescription:CreateAvatar (UnityEngine.Transform) (at Library/PackageCache/com.vrmc.gltf@0.99.4/Runtime/UniHumanoid/AvatarDescription.cs:125)
VRM.VRMImporterContext:LoadHumanoid () (at Library/PackageCache/com.vrmc.univrm@0.99.4/Runtime/IO/VRMImporterContext.cs:249)
VRM.VRMImporterContext/<OnLoadHierarchy>d__4:MoveNext () (at Library/PackageCache/com.vrmc.univrm@0.99.4/Runtime/IO/VRMImporterContext.cs:48)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start<VRM.VRMImporterContext/<OnLoadHierarchy>d__4> (VRM.VRMImporterContext/<OnLoadHierarchy>d__4&)
VRM.VRMImporterContext:OnLoadHierarchy (VRMShaders.IAwaitCaller,System.Func`2<string, System.IDisposable>)
UniGLTF.ImporterContext/<LoadAsync>d__28:MoveNext () (at Library/PackageCache/com.vrmc.gltf@0.99.4/Runtime/UniGLTF/IO/ImporterContext.cs:122)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<UniGLTF.RuntimeGltfInstance>:Start<UniGLTF.ImporterContext/<LoadAsync>d__28> (UniGLTF.ImporterContext/<LoadAsync>d__28&)
UniGLTF.ImporterContext:LoadAsync (VRMShaders.IAwaitCaller,System.Func`2<string, System.IDisposable>)
UniGLTF.ImporterContextExtensions:Load (UniGLTF.ImporterContext) (at Library/PackageCache/com.vrmc.gltf@0.99.4/Runtime/UniGLTF/IO/ImporterContextExtensions.cs:15)
VRM.vrmAssetPostprocessor/<>c__DisplayClass2_0:<ImportVrmAndCreatePrefab>b__0 (System.Collections.Generic.IEnumerable`1<UniGLTF.UnityPath>) (at Library/PackageCache/com.vrmc.univrm@0.99.4/Editor/Format/vrmAssetPostprocessor.cs:85)
UniGLTF.TextureExtractor/<>c__DisplayClass12_0:<ExtractTextures>b__0 () (at Library/PackageCache/com.vrmc.gltf@0.99.4/Editor/UniGLTF/ScriptedImporter/TextureExtractor.cs:106)
UnityEditor.EditorApplication:Internal_CallDelayFunctions ()

Exception: fail to create avatar
VRM.VRMImporterContext.LoadHumanoid () (at Library/PackageCache/com.vrmc.univrm@0.99.4/Runtime/IO/VRMImporterContext.cs:252)
VRM.VRMImporterContext+<OnLoadHierarchy>d__4.MoveNext () (at Library/PackageCache/com.vrmc.univrm@0.99.4/Runtime/IO/VRMImporterContext.cs:48)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Runtime.CompilerServices.TaskAwaiter.GetResult () (at <eae584ce26bc40229c1b1aa476bfa589>:0)
UniGLTF.ImporterContext+<LoadAsync>d__28.MoveNext () (at Library/PackageCache/com.vrmc.gltf@0.99.4/Runtime/UniGLTF/IO/ImporterContext.cs:122)
Rethrow as AggregateException: One or more errors occurred.
Rethrow as AggregateException: One or more errors occurred.
UniGLTF.ImporterContextExtensions.Load (UniGLTF.ImporterContext self) (at Library/PackageCache/com.vrmc.gltf@0.99.4/Runtime/UniGLTF/IO/ImporterContextExtensions.cs:22)
VRM.vrmAssetPostprocessor+<>c__DisplayClass2_0.<ImportVrmAndCreatePrefab>b__0 (System.Collections.Generic.IEnumerable`1[T] texturePaths) (at Library/PackageCache/com.vrmc.univrm@0.99.4/Editor/Format/vrmAssetPostprocessor.cs:85)
UniGLTF.TextureExtractor+<>c__DisplayClass12_0.<ExtractTextures>b__0 () (at Library/PackageCache/com.vrmc.gltf@0.99.4/Editor/UniGLTF/ScriptedImporter/TextureExtractor.cs:106)
UnityEditor.EditorApplication.Internal_CallDelayFunctions () (at <a259d3c004024353a2c217da97495055>:0)
esperecyan commented 2 years ago

I have confirmed the problem. This problem seems to have already been fixed in the latest version of UniVRM. In other words, it is caused by the fact that the Unity version that the VRChat SDK depends on is far too old that UniVRM cannot be updated.

esperecyan commented 2 years ago

I was mistaken that this does not happen with the latest UniVRM. If I export with UniVRM-0.105.0, the broken VRM is generated, although the renaming did indeed take place. I think it is probably a problem in UniVRM, but I trying to find out.