Hi,
I tried to reduce the vram size of my model so I used gltf transform quantize on it.
Unfortunately that broke the whole geometry. The object is weirdly shaped like a cube.
Am I missing something?
I am using 0.160.0
Thanks
Hi,
I tried to reduce the vram size of my model so I used gltf transform quantize on it.
Unfortunately that broke the whole geometry. The object is weirdly shaped like a cube.
Am I missing something?
I am using 0.160.0
Thanks
I would suggest checking the model on a three.js-based viewer like three.js editor. If it works correctly there then there’s something different about your code, and you’d likely need to post that code (or ideally a demo) if you need help. If it looks wrong in the viewer then there’s probably something wrong with the quantized model and I would file a bug at GitHub · Where software is built instead.
Thanks!
It was definitely my fault. I was applying a matrix to the geometry which broke it.
My overall problem is still not solved though. My plan was to reduce vram since I expected benefits for the USDZExporter. I try to export a huge model but iOS crashes.
Does quantize even influence the exporter? Or do I have other options to export the model to usdz without crashing on iOS?
Best
It’s not obvious to me whether quantization in a glTF source file would reduce the file size of a USDZ export or not. three.js writes ASCII-encoded (not binary) USDZ files, the file is likely to be larger than the source glTF/GLB, my guess would be that the quantization is not represented in the output USDZ file.
Do you have textures on the model? If so I would test without those, to be sure only the geometry is a factor.
I made some tests. Quantization definitely helped so export the scene to usdz. Separating huge models into smaller ones also helped.
Are there any other methods to reduce vram in general? I am not using textures so ktx2 isn’t an option.
It’s not obvious that VRAM of the scene loaded in three.js is related to your crashes on iOS, if you’re seeing a crash only when exporting to a USDZ file. You might need to narrow things down – does the crash happen while generating the USDZ file? Or only when trying to open that USDZ file in iOS? If the USDZ file is created successfully, how large is it? Does it load in some USDZ viewers and not others?
Oh, it’s not? Some how this helped though.
On desktop everything works fine so it’s not a problem with the exporter itself.
On iOS it crashes while generating the usdz before trying to use quicklook.
Initially the usdz was around 300MB. After quantization it’s around 150MB.
As mentioned it still crashed if I try to covert one huge model. After splitting it into two object it worked. I already wondered why this helped because the vram is the same.
There’s a lot happening in that glTF → three.js → USDZ → iOS Quick Look workflow.
I think the root here might be that USDZExporter needs to encode the whole model as a string, and every device has some maximum string length. I don’t know the current limits on different iOS devices but a 300 MB string might easily be too much. Try "a".repeat(300_000_000)
on your iOS device, to generate a 300 MB string, does it manage that? See: Javascript string size limit: 256 MB for me - is it the same for all browsers? - Stack Overflow
Vertex quantization might incidentally reduce the length of the encoded USDZ string, but that’s an indirect solution and there might be more direct fixes… if the original file was much smaller and you think the USDZExporter is doing something wrong (duplicating objects? duplicating vertices?) you could file a bug, or perhaps inspect the plaintext file and and see if anything looks suspicious, or share an example file here.
I just tested it.
"a".repeat(300_000_000)
works fine on my iPhone. It even works with 500k. I cannot test much higher values since I receive an error about invalid string length but 300-500k definitely should be enough for handling my scene as a string.
What other reasons are the for crashing the export?
Unfortunately I cannot share the model due to NDA.
EDIT:
I made some further tests. My test object has around 750k vertices and the resulting usdz is around 75MB.
If I try to export it it always crashes. I don’t try to load the usdz via quicklook I just export it.
I tried to split the geometry into 100k vertices chunks. Then the export works 80% of the time. Only sometimes it crashes.
If I use 50k chunks the export works but the model isn’t shown in quicklook.
Okay I am still stuck with this.
With another model I create an usdz around 150MB. The export works fine but as soon as I try to load it via quicklook my iphone crashes.
Is there any change to use ar with complex models on iphones?
Best