Skip to content
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

sRGB ASTC formats not supported #18764

Closed
5 tasks done
YorickCobb opened this issue Feb 27, 2020 · 0 comments · Fixed by #18771
Closed
5 tasks done

sRGB ASTC formats not supported #18764

YorickCobb opened this issue Feb 27, 2020 · 0 comments · Fixed by #18771

Comments

@YorickCobb
Copy link

YorickCobb commented Feb 27, 2020

Description of the problem:

Three.js supports a number of ASTC formats, but not the complete set (ctrl+f "0x93D7"). The omission of the *_SRGB8_ALPHA8_* formats means that Three.js won't load properly-encoded sRGB ASTCs. This is because ASTC can encode RGB data as either linear or sRGB, but it can only encode the alpha channel as linear. When using sRGB encoding, the RGB and the Alpha channels are distinct and a different format, and thus enum, is used.

I've put together a somewhat crude example.

If line 50 calls getBase64ImgL(), it loads the KTX file containing the linearly-encoded ASTC. If your device doesn't support ASTC, you'll get the following, expected warnings:
2020-02-27
I also print out the texture object, and we can see that the texture's internal format is 37815, the enum for an RGBA 8x8 ASTC. (If your device does support the format, it should show up as the texture on the plane)

If line 50 instead calls getBase64ImgS() to load the sRGB texture, the error is different:
2020-02-27 (1)
The texture's format is 37847, which is the enum for an SRGB8_ALPHA8 8x8 ASTC but isn't defined as such by Three. Because Three.js doesn't even realize it's looking at an ASTC texture, there is also no warning about device compatibility (and it will still fail even if your device supports ASTC)

If #12939 is good indication, implementing these formats may be as easy as adding the appropriate enums to constants.js and WebGLUtils.js, but I don't have easy means to tinker with it myself.

I'm including the ASTC (actually, KTX) files I'm using, generated with PVRtexTool as a GUI for ASTCEnc.exe: ASTCTestSet.zip

Three.js version
  • Dev
  • r113
Browser
  • All of them
OS
  • All of them
  • Android (especially)
Hardware Requirements (graphics card, VR Device, ...)

ASTCs ought to work on Oculus Quest and most Android phones, but JSFiddle doesn't so if you want to see for yourself, it'll take some work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants