Closed LorenzoMarnat closed 1 year ago
From what I know, the most used algorithms to compress geometries are meshoptimizer and draco. Draco is more popular and it performs better on geometries (while meshopt performs better on animations). The official draco transcoder is in C++ but there seems to be a python wrapping (don't know what it's worth though). Threejs and itowns can decode gltf with draco encoded geometries (see this and this).
Regarding textures, ktx v2 container for basisu (Basis Universal) textures seems to currently be the most efficient in the gltf ecosystem (supported by threejs and itowns with a few modifications (I will open a PR with these)).
Some interesting links about KTX2 and Basis Universal:
One good tool to transform gltf files and to apply such transformations is gltf-transform but it's written in JS, sadly for py3dtiles :)
Using quality
parameter when saving atlases as images seems to be an easy way to reduce the size of the images (the images must be saved as JPEG).
atlasImg.save(Path(Texture.folder, 'tiles', 'ATLAS_' + str(tile_number) + '.jpeg'), quality=10)
With quality=10
, the quality of the images will be reduced by 90%. Here's an example (the first picture is 10% quality, the second 100%):
Lowering the quality by 90% reduces the size of the atlases by ~90%. The CityTiler also computes the 3DTiles faster. In UD-Viz, the 3DTiles load faster and the quality difference between 100% and 10% is not very noticeable.
quality
could become a CL option. I'll make some tests and benchmarks.
Ah very cool that there is an option offered by pillow!! I used to reduce image quality with imagemagick beforehand, but exposing such an option to the CLI could be a good option :)
Some interisting benchmarks from 3D Tiles 1.1 Community Standard Justification
Nice!! Too bad they haven't tried glb + ktx2/basis/etc1s + draco which achieves the best results from similar tests I did. Also, do you know the compression level of the jpeg files ?
For some reason, they didnt try ktx2/basis/etc1s + draco. I didn't found why.
For jpeg, they use 80% quality
Thanks for the clarifications! JPEG achieves nice results! Too bad they don't show screenshots of each case to also compare the results visually
The following tests were made with the CityTIler on one CityGML building. Its original texture is a JPEG of 25.6 Mo. The 3D Tiles are loaded in UD-Viz. The computation time is the time taken to compute the atlas (not the whole process).
Impact of the --quality
flag (that will be implemented with this PR) on the size of the JPEG images.
Quality (%) | Size on disk (Mo) | Loading Time (ms) | Computation Time (s) |
---|---|---|---|
100 | 27,5 | 540 | 1.09 |
99 | 24,2 | 510 | 1.08 |
97 | 17,9 | 450 | 1.04 |
95 | 14,4 | 400 | 1.03 |
90 | 10 | 360 | 1.02 |
80 | 6,81 | ||
70 | 5,48 | ||
60 | 4,66 | ||
50 | 4,13 | 300 | 1.0 |
40 | 3,63 | ||
30 | 3,12 | ||
20 | 2,49 | ||
10 | 1,73 | 270 | 1.0 |
1 | 1,03 | 260 | 0.96 |
Impact of the --compress_level
flag (that will be implemented with this PR) on the size of the PNG images.
Compress level | Size on disk (Mo) | Loading Time (ms) | Computation Time (s) |
---|---|---|---|
0 | 162 | 900 | 1.99 |
1 | 60,6 | 1073 | 3.54 |
2 | 60,5 | 3.93 | |
3 | 59,9 | 4.44 | |
6 | 58,1 | 8.81 | |
9 | 58 | 1085 | 14.34 |
Downsizing images seems to be a very efficient way to reduce the size of the images AND RAM usage. See texture LODs issue
Issues in Oslandia's Py3DTiles:
We should be able to create compressed 3DTiles (geometries and textures).
Some tests to compress 3DTiles have been made with JS tools (see this doc)
About Pillow image compression.
compress_level
could become a parameter of py3dtilers