Optimizing mesh in Editor to speed up builds

I have a large GLTF file with textures that are not KTX, it’s about 160mb and production builds with it take a good 5-10minutes sometimes, development builds absolutely chug.

I was looking into options as I use GLTFPack https://github.com/zeux/meshoptimizer to use mesh_opt_compression and ktx compression on meshes but those usually wouldn’t load back into Unity due to GLTFast and Unity not supporting the extensions used. I assume the same issue occurs with UnityGLTF? We also had the issue of Blender not supporting mesh_opt_compression to reimport and edit those optimized meshes. Is there a workflow you would suggest for this issue? I assume I can at least convert the textures in the model to ktx which should import to Unity but mesh_opt_compression extension isn’t supported I assume?

Original Post on Discord

by user 103054507105067008

Yep just checked and UnityGLTF doesn’t support importing mesh_opt_compress extension using compressed GLTF files in Editor

by user 103054507105067008

@marcel :cactus: do we have the approach to keep compressed assets as-is documented already?

That would be huge if it is doable just for rebuild times

by user 103054507105067008

@ROBYER1 yes, we support bringing precompressed assets that are copied and loaded as-is
If you want to see them in Unity you have to use glTFast as importer though, but that can just live in the same project

E.g. our website uses that for the Bike and Songs of Cultures assets which are already packed:

This is the main issue with importing compressed files with GLTFast, I did see there was an issue for it on their git

by user 103054507105067008

Adding a GltfObject to the pre-compressed Glb object in the hierarchy should work

That extension is supported in glTFast for +2 years or so, you’ll need the right additional package installed same as with draco: GitHub - atteneder/glTFast: Efficient glTF 3D import / export package for Unity

by user 103054507105067008

OK; so steps would be

  • install the required additional packages for glTFast to support loading your files (e.g. draco, meshopt, ktx) as usual
  • just drag the asset into the scene
  • in the scene, add GltfObject to that asset
  • if you export that scene the referenced file will be copied verbatim and loaded as-is

That’s just what I needed, thanks!
Does UnityGLTF support mesh_opt_compression also?

by user 103054507105067008

Not right now, no. UnityGLTF development efforts are focussed on export, there’s no real use in maintaining two entirely separate import implementations since glTFast is pretty mich feature complete

We did however align with Andreas (glTFast developer) on the two packages being compatible in the same project and you can even switch the importer directly on each asset as needed.

Makes sense, just wondered in case we can keep projects just using one, nice that the packages work friendly together

by user 103054507105067008