Babylon.js icon indicating copy to clipboard operation
Babylon.js copied to clipboard

EXT_texture_avif implementation

Open leon opened this issue 3 years ago • 11 comments

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 https://github.com/KhronosGroup/glTF/pull/2235

I have also done a PR for three here https://github.com/mrdoob/three.js/issues/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 https://github.com/KhronosGroup/glTF/pull/2235 EXT_texture_avif as a supported extension.

leon avatar Dec 22 '22 09:12 leon

Thanks a lot for the Contrib @leon I love where this is going

sebavan avatar Dec 22 '22 20:12 sebavan

@sebavan I added the PR link temporarily.

I modelled the PR after how WebP was implemented in glTF. I could not find any references to webp in getCaps(), are you sure we need to add it there?

leon avatar Dec 25 '22 08:12 leon

AVIF might not be as widly supported as webp ???

sebavan avatar Jan 02 '23 17:01 sebavan

@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, first it was jpeg 2000, then flif then flif was merged into jpeg xl and parallel to jpeg xl the av1 video encoding got released and based on that the avif format.

jpeg xl looked really promising as the replacement for png, jpeg, gif.

but then google pulled the plug on jpeg xl from chrome 110. and webp2 seems to only be experimental. which makes me believe avif is going to win (if jpeg xl doesn't get added back to chrome again)

Recent thought

one of the biggest proponents to having something like this is transfer size. But as someone pointed out, it's still big in the gpu and using basis universal + ktx2 is probably a better solution. The problem there is tooling support. maybe I should try getting ktx2 / basis support in blender instead...

What do you think, is it a good or bad idea to add avif support?

leon avatar Jan 03 '23 14:01 leon

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 ?

sebavan avatar Jan 03 '23 15:01 sebavan

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 And check if the size is 1px

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. But when using glb it defeats the purpose of having smaller downloads.

leon avatar Jan 03 '23 15:01 leon

What do you think, is it a good or bad idea to add avif support?

We should have this conversation on the glTF side, which looks like is already happening.

bghgary avatar Jan 03 '23 20:01 bghgary

@leon let me move as a draft until the GLTF group is taking a decision. This is still being discussed actively.

sebavan avatar Jan 23 '23 16:01 sebavan

@bghgary any progress on this one from the group ?

sebavan avatar Feb 14 '23 00:02 sebavan

No, it hasn't been on the agenda recently.

bghgary avatar Feb 14 '23 16:02 bghgary

Still in discussion within the GLTF group so not closing.

sebavan avatar May 15 '23 19:05 sebavan

This pull request has been marked as stale because it has been inactive for more than 14 days. Please update to "unstale".

github-actions[bot] avatar Mar 14 '24 00:03 github-actions[bot]

This pull request has been marked as stale because it has been inactive for more than 14 days. Please update to "unstale".

github-actions[bot] avatar Mar 30 '24 00:03 github-actions[bot]