atteneder / glTFast

Efficient glTF 3D import / export package for Unity
Other
1.23k stars 250 forks source link

import compressed .glb/.gltf files as .zip ? #219

Open omaramen99 opened 3 years ago

omaramen99 commented 3 years ago

It takes relatively long time to import glb files through url then I found that 90% of the time is spent on downloading the file itself ,So I'm just wondering if I can import compressed glb file as .zip to reduce the downloading time ?

Looooong commented 3 years ago

I can think of two ways to reduce the download time:

1. Use the Draco mesh compression extension

This extension is better at compressing raw mesh data than using zlib. You can use this extension by installing the optional dependency. And finally, the glTF file must be regenerated to include this extension.

2. Customize the download behaviour using IDownloadProvider

As you said, you can zip the glTF file. Then you can implement custom IDownloadProvider to download and decompress the zip file in your code.


You can even combine the 2 methods together.

atteneder commented 3 years ago

Hi and thanks for the suggestion,

I second the suggestions from @Looooong and would add using KTX textures to the list.

Regarding compression: We'd have to start doing benchmarks on a reasonable set of test glTFs (measuring size and decompression speeds) to see what the actual benefit is. Besides gzip I'd be curious to test Brotli.

A good way to test this is to run WebGL build with a properly configured HTTP server, that supports compression (gzip or brotli).

andypoly commented 2 years ago

To add to this - the first thing we noticed on testing glb is they were like 3 times the size of an equivalent Unity asset bundle. When zipped it was 3 times smaller than before - this was just pure triangle data, not textures - and close to a desktop asset bundle size. So zipping the files for downloaded seemed sensible... or using draco There may be use cases for a single zipped glb file, cross platform, versus the painful platform-specific (though platform-optimised) assetbundle route then.

atteneder commented 2 years ago

To add to this - the first thing we noticed on testing glb is they were like 3 times the size of an equivalent Unity asset bundle. When zipped it was 3 times smaller than before - this was just pure triangle data, not textures - and close to a desktop asset bundle size.

Thanks for sharing. Making a proper comparison of glTF variants and asset bundles is definitely desirable.

There may be use cases for a single zipped glb file, cross platform, versus the painful platform-specific (though platform-optimised) assetbundle route then.

Absolutely!

I'm curious, on what platform(s) do you want to load zipped glTFs? I'm asking because if it's just WebGL, you can leave it up to HTTP's compression level (in other words to the server and browser), right?

andypoly commented 2 years ago

I'm curious, on what platform(s) do you want to load zipped glTFs? I'm asking because if it's just WebGL, you can leave it up to HTTP's compression level (in other words to the server and browser), right?

Yes (although I am not well-versed on web tech), but we use the same assets on a wide range of platforms - web, standalone, mobile