I want to remove unnecessary materials or textures in order to reduce the size of the USDZ model I have. How can I manipulate this model with swift?
or, I can try any advice to reduce the size of the USDZ model
I want to remove unnecessary materials or textures in order to reduce the size of the USDZ model I have. How can I manipulate this model with swift?
or, I can try any advice to reduce the size of the USDZ model
USDZ is a dcc format that's not optimized for GPU use. It's a dcc transfer format that Pixar designed for maintaining high-quality assets for their films. Unlike GLTF, the data is completely stored as uncompressed floats. You can use ModelIO to compress all the vertices. Then write that out as a GLTF or usable asset format of your own design.
Then the image data is jpg/png. Jpg should never be used with 3d models, unless you like normals to ring. And png can't represent the 7 image types that most gpus need. So then you need to turn those png textures into ktx or ktx2 files, and then BC compress for desktop or ASTC/ETC compress them for mobile.
Hello,
There are certainly meaningful ways for you to reduce the size of the USDZ model. The majority of the size (both on disk and in-memory) is likely going to come from the textures in the model.
So, you could write an app, using either SceneKit or Model I/O, that reads in the original model, downsamples the textures to a smaller resolution (of course this comes with a cost to visual quality of the model), and then writes out the new model using the downsampled textures.
Another way that you can reduce the size would be to apply a mesh decimation algorithm on the mesh itself, to reduce the number of verts and polygons in the mesh (while still attempting to preserve the original mesh's topology), and then write out the new model. This too could be implemented in either SceneKit or Model I/O, but for the majority of models, it probably wouldn't result in as significant a reduction as downsampling the textures would.
You also mention that you're open to removing the materials entirely, that would certainly have a significant impact on the size of the model, and would be relatively simple to implement in SceneKit compared to the other options I mentioned. You could load the model as an SCNReferenceNode, create a flattenedClone(), replace the clone's materials with an empty array, add the clone to an empty SCNScene, and then write the SCNScene as a new usdz.