prefrontalcortex / UnityGLTF

Runtime GLTF Loader for Unity3D
MIT License
163 stars 41 forks source link

WEBGL Export of animation runtime. #80

Closed PabloMonfort closed 1 year ago

PabloMonfort commented 1 year ago

Hi there, nice work you guys im just impressed. We have this working fine on editor but im wondering if you guys know what can be the problem that the glb lost the animation when we export it via webgl, coz after send the bytearray via unitywebrequest.post

Animation seems stop working , some how backend developer denied that can be a backend problem, but im still not sure whats going on , how can i debug this too any ideas? the glb works but just animation get broken if i compare with the editor runtime export that send to appdata folder... so we are not still sure if its a issue or not but would be nice some help if anyone knows. i can send both files maby if ask to my boss if you guys help to figure a solution maby i can send the model in private or something ? thanks.

PabloMonfort commented 1 year ago

Timeline recorder track for exporting animations at runtime Lossless keyframe optimization on export (animation is baked but redundant keyframes are removed) ? i think this is what happend in webgl? is there a way i can disable that so i can see the whole animation in a WEBGL runtime export ? thanks. i have reproduce the issue or unwanted behaviour in webgl. the bytes are shorter then in editor export result. like half less and then animation of glb from webgl end ups with much less data and it dosnt play the animation loop when i open it with viewer. would be really nice to some one can help around this.

hybridherbst commented 1 year ago

I'm not quite sure if I understand your description right.

Runtime export requires a Timeline recorder track or using the GltfRecorder, either via the provided component or directly from code. I'm not aware of differences in behaviour between using these methods in the Editor and inside WebGL.

Do you get actual logs / errors?

PabloMonfort commented 1 year ago

I'm not quite sure if I understand your description right.

Runtime export requires a Timeline recorder track or using the GltfRecorder, either via the provided component or directly from code. I'm not aware of differences in behaviour between using these methods in the Editor and inside WebGL.

Do you get actual logs / errors?

well i will be really glad if you can provide me a Runtime export using the GltfRecorder EXAMPLE coz i have not seen one in the samples directory and im not sure how that works, i used the SendByteArray method and have check using localhost php due in the django is other backend developer . but i have reproduce same thing, it export well the glb, only that in runtime webgl dosnt arrive well the animation. it just broke some how. i have try to test the GltfRecorder but it dosnt work at all, i have try with simple skinnedmesh and was not even able to export from editor.(then i tought it should not work on runtime if dosnt work on editor) at least i made mistake to not test that, it was giving error with any test i have try, i have try all settings neither... it gives error after end recording saying something like this :

Exception: Accessors can not have a count of 0.
UnityGLTF.GLTFSceneExporter.ExportAccessor (System.Single[] arr) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/sceneexporter/exporteraccessors.cs:467)
UnityGLTF.GLTFSceneExporter.AddAnimationData (UnityEngine.Object animatedObject, System.String propertyName, GLTF.Schema.GLTFAnimation animation, System.Single[] times, System.Object[] values) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/sceneexporter/exporteranimationpointer.cs:471)
UnityGLTF.Timeline.GLTFRecorder.CollectAndProcessAnimation (UnityGLTF.GLTFSceneExporter gltfSceneExporter, GLTF.Schema.GLTFAnimation anim, System.Boolean calculateTranslationBounds, UnityEngine.Bounds& translationBounds) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/timeline/gltfrecorder.cs:457)
UnityGLTF.Timeline.GLTFRecorder.PostExport (UnityGLTF.GLTFSceneExporter exporter, GLTF.Schema.GLTFRoot gltfRoot) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/timeline/gltfrecorder.cs:360)
UnityGLTF.GLTFSceneExporter.SaveGLBToStream (System.IO.Stream stream, System.String sceneName) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/gltfsceneexporter.cs:617)
UnityGLTF.Timeline.GLTFRecorder.EndRecording (System.IO.Stream stream, System.String sceneName, UnityGLTF.GLTFSettings settings) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/timeline/gltfrecorder.cs:347)
UnityGLTF.Timeline.GLTFRecorder.EndRecording (System.String filename, System.String sceneName, UnityGLTF.GLTFSettings settings) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/timeline/gltfrecorder.cs:316)
UnityGLTF.GLTFRecorderComponent.StopRecording () (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/gltfrecordercomponent.cs:73)
UnityGLTF.GLTFRecorderComponent.ToggleRecording () (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/gltfrecordercomponent.cs:87)
UnityGLTF.GLTFRecorderComponent.<Start>b__16_0 (UnityEngine.InputSystem.InputAction+CallbackContext _) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/gltfrecordercomponent.cs:99)
UnityEngine.InputSystem.Utilities.DelegateHelpers.InvokeCallbacksSafe[TValue] (UnityEngine.InputSystem.Utilities.CallbackArray`1[System.Action`1[TValue]]& callbacks, TValue argument, System.String callbackName, System.Object context) (at ./library/packagecache/com.unity.inputsystem@1.4.4/inputsystem/utilities/delegatehelpers.cs:46)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)
PabloMonfort commented 1 year ago

all what i need is a skinnedmesh animation loop .glb idle animating in a loop and i need to export it in a webgl then send it to backend using bytes. the only trouble actually is that we use yeah the function SendGlb and the bytearray one but both show same behavior and end up with a weird animation where its just 1 frame, and at same times says its has 0 animation so kind weird result but yeah we dont use gltfrecorder,

GLTFRECORDER CANT BE SURE THAT WORKS IN EDITOR ( SORRY ABOUT UPPERCASE)

how can be sure that gltfrecorder work in runtime if dosnt work in editor? the error that gives is the above one

Exception: Accessors can not have a count of 0..... etc etc

so actually we keep the one that barely works that is the same that works very nice with animation from editor , the sendGlbByteArray() do you know about any example about this? really need this thanks.

hybridherbst commented 1 year ago

Hey, can you please make sure to structure your responses a bit? Proper punctuation, using code tags and so on? It's really hard to read.

Which versions of Unity / Render Pipeline / UnityGLTF are you using? We're using GltfRecorder runtime export in production for a long time, including for skinned meshes - I know it works :) - so I'd like to learn more about your setup.

GltfRecorder works the same in Editor and at Runtime. If you have a particular mesh that doesn't work, please upload the file so I can take a look.

PabloMonfort commented 1 year ago

Can you share a simple example for GltfRecorder runtime export would be really great a demo, that's all what im asking coz i cant see any example about it. Specially to export skinnedmesh with an animation or animations would be really great, since i cant export to glb from runtime webgl didnt find possible yet, just need you guys show up how to do this since no example there. I have search the entire web, just want a example thats all.

GLTFRecorder component give error to me no matter what i have try with any settings Exception: Accessors can not have a count of 0. UnityGLTF.GLTFSceneExporter.ExportAccessor (System.Single[] arr) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/sceneexporter/exporteraccessors.cs:467) UnityGLTF.GLTFSceneExporter.AddAnimationData (UnityEngine.Object animatedObject, System.String propertyName, GLTF.Schema.GLTFAnimation animation, System.Single[] times, System.Object[] values) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/sceneexporter/exporteranimationpointer.cs:471) UnityGLTF.Timeline.GLTFRecorder.CollectAndProcessAnimation (UnityGLTF.GLTFSceneExporter gltfSceneExporter, GLTF.Schema.GLTFAnimation anim, System.Boolean calculateTranslationBounds, UnityEngine.Bounds& translationBounds) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/timeline/gltfrecorder.cs:457) UnityGLTF.Timeline.GLTFRecorder.PostExport (UnityGLTF.GLTFSceneExporter exporter, GLTF.Schema.GLTFRoot gltfRoot) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/timeline/gltfrecorder.cs:360) UnityGLTF.GLTFSceneExporter.SaveGLBToStream (System.IO.Stream stream, System.String sceneName) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/gltfsceneexporter.cs:617) UnityGLTF.Timeline.GLTFRecorder.EndRecording (System.IO.Stream stream, System.String sceneName, UnityGLTF.GLTFSettings settings) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/timeline/gltfrecorder.cs:347) UnityGLTF.Timeline.GLTFRecorder.EndRecording (System.String filename, System.String sceneName, UnityGLTF.GLTFSettings settings) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/timeline/gltfrecorder.cs:316) UnityGLTF.GLTFRecorderComponent.StopRecording () (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/gltfrecordercomponent.cs:73) UnityGLTF.GLTFRecorderComponent.ToggleRecording () (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/gltfrecordercomponent.cs:87) UnityGLTF.GLTFRecorderComponent.<Start>b__16_0 (UnityEngine.InputSystem.InputAction+CallbackContext _) (at ./library/packagecache/org.khronos.unitygltf@e0b6a81d7e/runtime/scripts/gltfrecordercomponent.cs:99) UnityEngine.InputSystem.Utilities.DelegateHelpers.InvokeCallbacksSafe[TValue] (UnityEngine.InputSystem.Utilities.CallbackArray1[System.Action1[TValue]]& callbacks, TValue argument, System.String callbackName, System.Object context) (at ./library/packagecache/com.unity.inputsystem@1.4.4/inputsystem/utilities/delegatehelpers.cs:46) UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*) UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)

thats the error gives GLTFRecorder to me , no matter what i try, i have try legacy , generic, humanoid, all of them give me a .glb file with 0KB so useless glb togheter with that error up there.

Sorry dont know well how to use tags in github.

hybridherbst commented 1 year ago

You haven't responded to my question: Which versions of Unity / Render Pipeline / UnityGLTF are you using?

PabloMonfort commented 1 year ago

Unity version = 2022.2.3f1 Render pipeline = URP UnityGLTF https://github.com/prefrontalcortex/UnityGLTF last version ( i have checked this coz I can see the last push on the repo) GLTFRecorder didnt work to me, gives error i wrote up there. Exception: Accessors can not have a count of 0.

hybridherbst commented 1 year ago

Thanks! Can you please share a model where that happens?

PabloMonfort commented 1 year ago

Well not really. I can create a repo with the issue and send you an invite if you want. its very small due i have made a new proyect just for see this. Let me know if you are interest on that way.

i have sent you an invite to the repo image

then 0KB

image

Thanks for your help.

PabloMonfort commented 1 year ago

Were you able to see the repo? the issue is there you can reproduce it. Please let me know asap in case i will send your model, but can reproduce the issue. it should happen with any model i believe since any model i test it happens.

PabloMonfort commented 1 year ago

@hybridherbst did you check the repo? the model and all the issue is there, any news around this? sorry to bother you but would be nice to know if you have received the invite of repo at least? thanks.

hybridherbst commented 1 year ago

I received the repository - thanks! However it's gonna be a few days until I can look at the issue. Thanks for your patience.

PabloMonfort commented 1 year ago

No problem take your time its nice to hear from you! hope you find a solution to this coz i didnt , thanks and good luck.

hybridherbst commented 1 year ago
PabloMonfort commented 1 year ago

thank you, should i update the plugin via package manager to get the fix or manually patch that line of code of the blendshape == 0 return?

Btw can i delete the repo of the issue now just let me know ifts ok and thank for your effort on this.

hybridherbst commented 1 year ago

I'll most likely make a new release over the next days (so there's a new version in PackMan). Feel free to test before that and let me know if there are other issues!

PabloMonfort commented 1 year ago

I'll most likely make a new release over the next days (so there's a new version in PackMan). Feel free to test before that and let me know if there are other issues!

i have confirm myself that work this time the result give me some kb finally and i can see the animation on the web viewer, thanks m8. You can close this if want, take care have fun!.