minimal wasm build for glTF extension support #782
Replies: 8 comments 1 reply
-
Most people working in JavaScript write their own file parser and use the There is also a collection of transcoders handwritten in wasm downloadable from https://github.com/KhronosGroup/Basis-Universal-Transcoders. Currently only UASTC to ASTC, BC7, R8, RG8, and RGBA8 transcoding is supported. I don't know the exact size but they should be smaller than the equivalents from msc_basis_transcoder. The release package of KTX-Software-4.3.0-alpha3-Web-libktx.zip contains the full libktx compiled to wasm so includes the ASTC, ETC1S/Basis-Lz and UASTC encoders and zstd and zlib deflators as well as functions for assembling and writing KTX files. The zipped file is 338kb. It is possible to build to build with Emscripten the read-only library |
Beta Was this translation helpful? Give feedback.
-
Thank you much for the comprehensive summary of options. I used unzipped sizes because the comparison is with unzipped but minified framework totals which is what is used to balance overall functionality with code size. Do you think it would be possible with reasonable effort to build such a further reduced I tried some emscripten building with https://github.com/BinomialLLC/basis_universal/blob/master/webgl/transcoder/ and will try |
Beta Was this translation helpful? Give feedback.
-
If ASTC is sufficient you may want to work with @wasimabbas-arm who is preparing to propose a texture_ASTC extension to the glTF WG. The objection most likely to be raised is that it is not cross platform so data to the contrary will be welcome. The advantage is that no transcoder is needed. The disadvantage is larger file & transmission sizes, compared to UASTC, because the encoder does not currently have RDO (rate-distortion optimization) to condition its output for more effective lossless supercompression.
Yes. Both ETC1S/Basis-Lz and UASTC can be transcoded to ASTC.
Yes. libktx.js currently links with the read -only library so you don't need to worry about that. See line 838 in the root
GL_UPLOAD adds the function to upload the texture to WebGL via Emscripten's OpenGL ES support. You may want to use this. To remove additional transcoders you will need to edit the root The easiest way to build the wasm stuff is to installer docker then use |
Beta Was this translation helpful? Give feedback.
-
Thanks again, especially for the detailed build explanations. As a first step, I could use the docker build script on codespaces successfully and will go from there. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, I did not get very far after adding
I could run |
Beta Was this translation helpful? Give feedback.
-
I could update |
Beta Was this translation helpful? Give feedback.
-
I could also use I also tried recommended |
Beta Was this translation helpful? Give feedback.
-
I am sorry for my lack of response over the past weeks. There should probably be stub functions that return I don't understand what you mean about the |
Beta Was this translation helpful? Give feedback.
-
We are trying to get a sense of what a minimal libktx.js/wasm build would look which only include the features needed to support the glTF basisu/ktx2 extension.
The current libktx.js and libktx.wasm are 900kb combined which is larger than complete 3d js frameworks in their entirety.
I think these builds are read only/decode only already but hopefully there would be opportunities to reduce library size much further. So any guidance or examples for limited builds would be welcomed.
https://github.com/BinomialLLC/basis_universal/blob/master/webgl/transcoder/build/basis_transcoder.wasm is 460kb which is also huge. I think these transcoders supersede the transcoders built into libktx ? This also appears to have ktx2 parsing.
https://github.com/BinomialLLC/basis_universal/blob/master/webgl/transcoder/CMakeLists.txt#L44 has a list of compiler target options which may already be a minimal set for glTF support ? Of course, this is another repo but the repos seem closely related.
We are aware of the Three and Babylon implementations but would be happy to reduce performance/quality or even support for some formats in exchange for less complexity and code size.
So any feedback or thoughts are much appreciated, Andreas
Beta Was this translation helpful? Give feedback.
All reactions