-
Notifications
You must be signed in to change notification settings - Fork 3.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
EXT_texture_avif implementation #13370
Conversation
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.
Engine Capabilities should have a new flag to specify whether AVIF is supported on the current platform.
The extension should be disabled if AVIF is supported in engine.getCaps()
const NAME = "EXT_texture_avif"; | ||
|
||
/** | ||
* [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_texture_avif/README.md) |
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.
Would be great to drop a comment to say Experimental Support as the spec is still evolving.
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.
A link to the PR would be useful as well :-) cause the provided spec link is not available so far
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.
Probably should remove the dead link for now. Once the PR is merged, we can update this comment. For now, maybe point to the PR's file for the specification?
Thanks a lot for the Contrib @leon I love where this is going |
@sebavan I added the PR link temporarily. I modelled the PR after how WebP was implemented in glTF. |
AVIF might not be as widly supported as webp ??? |
@sebavan the backstory of why I decided to try to also add avif. I have been keeping my eye on the image formats for a long time, jpeg xl looked really promising as the replacement for png, jpeg, gif. but then google pulled the plug on jpeg xl from chrome 110. Recent thoughtone of the biggest proponents to having something like this is transfer size. What do you think, is it a good or bad idea to add avif support? |
I like the overall approach :-) but I am super n00b with image formats. Let me add @bghgary to the thread for this part. Regarding this specific implementation, as long as AVIF is not generalized in all browsers, I am just wondering if we should feature proof it ? |
In three.js they check for support in the texture loader. https://github.com/mrdoob/three.js/pull/25173/files We try loading a img with a base64 encoded 1x1 px Same as how they check for webp support. Maybe we should do something like that? As for the extension it has fallback support, where you can have both avif and a png. |
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.
Looks good from a code perspective besides some minor issues. Adding a test for this would be good also, but maybe don't do it until the spec is close to final?
const NAME = "EXT_texture_avif"; | ||
|
||
/** | ||
* [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_texture_avif/README.md) |
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.
Probably should remove the dead link for now. Once the PR is merged, we can update this comment. For now, maybe point to the PR's file for the specification?
case ImageMimeType.AVIF: | ||
return ".avif"; |
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.
Probably should update this also?
Babylon.js/packages/dev/serializers/src/glTF/2.0/glTFMaterialExporter.ts
Lines 1089 to 1102 in ad4785d
// Preserve texture mime type if defined | |
const textureMimeType = (babylonTexture as Texture).mimeType; | |
if (textureMimeType) { | |
switch (textureMimeType) { | |
case "image/jpeg": | |
case "image/png": | |
case "image/webp": | |
mimeType = textureMimeType as ImageMimeType; | |
break; | |
default: | |
Tools.Warn("Unsupported media type: ${textureMimeType}"); | |
break; | |
} | |
} |
We should have this conversation on the glTF side, which looks like is already happening. |
@leon let me move as a draft until the GLTF group is taking a decision. This is still being discussed actively. |
@bghgary any progress on this one from the group ? |
No, it hasn't been on the agenda recently. |
Still in discussion within the GLTF group so not closing. |
This pull request has been marked as stale because it has been inactive for more than 14 days. Please update to "unstale". |
This pull request has been marked as stale because it has been inactive for more than 14 days. Please update to "unstale". |
My Christmas contribution is trying to get AVIF support in GLTF, Babylon and Three.
I Did a PR for the GLTF spec which you can find here
KhronosGroup/glTF#2235
I have also done a PR for three here
mrdoob/three.js#25171
My thoughts are the following.
Chrome recently gave up on jpeg xl which I personally thought was the superior replacement for gif, png, jpeg, webp.
The next best format after jpeg xl is avif, and since jpeg xl isn't happening I thought I could do a drive trying to improve the file size of gltf files by getting avif support.
Solution
Add the not yet merged KhronosGroup/glTF#2235 EXT_texture_avif as a supported extension.