Hi everyone,
I’m trying to export a GLB file from Unity.
I already have the data to instantiate the .glb in a glftImport object.
I just found glb export method.
There is only one problem, It seems mandatory to instantiate a gameobject and use those gameobject to generate the glb.
For performance reasons, I want to avoid the instantiation step.
Is it possible?
Thanks,
Can you elaborate on your use-case further please?
I cannot see a good reason to load a glTF only to serialize it back to glTF again. It would make sense if you could make edits to the data in this intermediate form, but that’s not possible nor intended atm.
Thanks
I need to show an avatar which can be stocked as a .glb in two places :
Right now, my server is not working so I emulate his behavior with my local machine.
I load the .glb from my false server if I can’t find it in my cache (at the regular place).
If I load the .glb from the server, I must save it in my cache so I don’t use bandwith the next time.
I use GtlfImport.Load
method with a file path to load my glb. It works well, but to save it in my cache I only found this Runtime Export | Unity glTFast | 5.2.0.
And to use this I need to instantiate my glb.
The solution was to use GltfImport.Load
with the override using bytes.
I read bytes from the glb on my false server then I use GltfImport.Load
with them.
After that I can save the glb in my cache with the same bytes. And instantiate my avatar when I want with the loaded GltfImport
.
Maybe this is the only viable solution when true server will be available.
However, having data in GltfImport
without being able to save them elsewhere bugged me out a little.
I don’t know if allowing to access bytes from GltfImport is a good idea but that was what I needed.
My solution works so we can close this thread.
Thanks for your attention.
Thanks for elaborating.
If I got it correctly then you’re asking if there’s a better way to cache a glTF’s (.glb) content than to just cache the original file.
TL;DR: No, that’s not possible at the moment. I recommend you continue to cache the entire glb file and maybe consider using separate files (.gltf +.bin + textures) as this loads more efficient from a buffer.
Disclaimer: The following are ideas that have been flowing in my head, but are not more than that: ideas. There are no plans to put the into reality as of now.
Afaik there’s no simple/built-in way to easily serialize glTFast’s output (which is Unity resources like GameObjects, Meshes, etc.) for re-instantiation later on. What could be done is serialize the data in an intermediate form that’s closer to the destination. Examples:
- Vertex buffer streams in it’s destination layout with coordinate space transform already applied.
- Textures (be it Jpeg, PNG or KTX) in decoded/transcoded format, so that they can be pushed to the GPU directly.
That intermediate format is sort of a Unity glTF with device specific content (e.g. textures in a GPU friendly format that might not work everywhere). A cache interface like that would indeed be nice, but adds complexity and there are no plans.
hth