-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
GLTFLoader: Add EXT_texture_avif
support.
#25173
Conversation
I can confirm Chrome does support avif when loaded via |
@Mugen87 I added the missing ctor and added an example for the AVIF loader. It works on Mac Ventura with Chrome 108 |
If you add a new example, you have to generate a E2E screenshot via |
Context for reviewers — At this stage Thoughts on AVIF — AVIF may offer better compression on disk and over the network compared to WebP, PNG, and JPEG in many cases. I haven't compared to WebP2. Users should be aware that (like PNG, JPEG, or WebP) AVIF must be fully decompressed on the GPU, which brings some performance vs. quality vs. network size tradeoffs. KTX2 / Basis Universal remains the best option for textures that remain compressed on the GPU. AVIF will likely be the best option for minimizing network size. AVIF has some useful features that, unfortunately, we probably cannot support in WebGL at this time, including:
These would require changes to browser APIs, or shipping a JavaScript or WASM decoder with three.js, which seems out of scope for now. HDR and wide-gamut color spaces may become available later with WebGPU. Adding AVIF feels like a good thing to me. The cost is low and there's already strong support for the format. See Using Modern Image Formats: AVIF And WebP for a deeper dive. |
EXT_texture_avif
support.
To be able to do proper demos without having to resort to manually copying base64 into gltf files, I went ahead and implemented AVIF support in gltf-pipeline. I did a test where I compressed the DamagedHelmet with avif using squoosh. I changed the example to use this model instead of my cube, since the DamagedHelmet is a good reference model. |
Experimental implementation in glTF Transform, for testing purposes: # install
npm install --global @gltf-transform/cli@avif
# compress textures
gltf-transform avif input.glb output.glb Related: |
@donmccurdy Are you fine when this PR gets merged? |
@Mugen87 maybe let's skip the demo for now, unless/until we can do something more illustrative than the DamagedHelmet scene? Otherwise yes — this looks good to me! |
Agreed, another demo without the helmet would be better but at least for testing/validation purposes I think it's okay for now. |
Related issue: #25171
Description
Adds support for the yet to be merged EXT_texture_avif gltf extension
KhronosGroup/glTF#2235
The test to see if the browser is supported is a 1x1 px avif file created in PS and then run through squoosh to get the smallest possible size (305bytes)
and then base64 converted.
I'm not sure if we can get an even smalled image, but this was as small as I could get it.
I tested it in edge which doesn't support avif yet, and in chrome and both work as expected.