-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for KTX2 texture compression to gltf-model #5101
Conversation
docs/components/gltf-model.md
Outdated
basis_transcoder.wasm — WebAssembly transcoder. | ||
|
||
These files are available from the three.js repository, under | ||
[examples/js/libs/basis][basis]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see [basis]
defined in the document, similar to [blender]
. I guess you want to include something like
[basis]: https://github.com/mrdoob/three.js/tree/dev/examples/js/libs/basis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, bad syntax. Corrected w/ link to that file folder.
Thanks! How common is KTX2 these days? My only concern is adding this as a hard dependency if it's not used much. |
Yeah I noticed this comment above all the As for how common it is, the Mozilla Hubs team has implemented KTX2 and even ships the .wasm with their client (while this PR relies on optional remotely hosted .wasm and .js files). I know it's popular and relied-on by their team and community. As noted above, |
I can't guess at number of models in the wild using KTX2, certainly models found in sources like Sketchfab won't include it. But KTX2 represents a 4-8x GPU memory savings compared to JPEG, PNG, or WebP — that's a big help in avoiding out-of-memory crashes on mobile devices. Size on disk/network is more variable, but often also improves. We do use KTX2 at the NYT, more for reasons of memory and GPU upload speed. |
Wonder if there's a way we can come up with to lazy load the dependencies when KTX2 is used |
The larger WASM binary is already lazy-loaded, but the JS parts that are not so easy to fetch I expect. |
… .wasm and .js files
I'm an artist in the Hubs community and I try to use KTX2 whenever I can. It's very helpful! |
Yeah, since it's the developer's decision to include/exclude Anyway, A-Frame includes Draco in the same way, and to me KTX2 is just as useful, if not moreso b/c it optimizes memory use, not just network/disk use. Supporting the most popular geometry and texture compression libraries for gltf side by side makes a lot of sense, and it can't grow in popularity if major frameworks don't support it. If something better and more standardized comes along this can always be removed in its favor. The cost of a few dormant lines of JS when not in use seems pretty low. Just my two cents! |
Thanks! Great work! |
This PR was working with super-three r141, but in the meantime aframe master switched to super-three r144 and the UMD build of |
Also see mrdoob/three.js#24593 (comment) — more UMD+CJS files may be removed by the end of this year. I believe an ESM-based build process would be ideal looking forward. |
Great work here, thank you @jameskane05! |
Thanks so much for doing that work veincent. We're all in debt to you! |
Description:
This addresses #4919 by adding THREE.KTX2Loader to the A-Frame gltf-model system. It works just like the DracoLoader, in that you have to provide it with a link to a hosted transcoder library folder, which must contain two files:
basis_transcoder.wasm
andbasis_transcoder.js
, as documented in thegltf-model.md
. These files are available from the three.js repository, underexamples/js/libs/basis
.This also extends an example scene to include an asset with a compressed texture (made with
gltf-transform etc1s grip.glb grip-compressed.glb
command). This is a small asset from my upcoming game, which is linked to from Glitch.com hosting. Let me know if there is a preferred asset to use for this example or if it should be moved to within the project somehow instead of remotely hosted. Also let me know if there are other stylistic or convention things I missed. Otherwise looking forward to having access to this feature!