I think either of those fixes are OK as a local patch. Will need to think more about what kind of fix could be merged into KTX2Loader, and hopefully find out why ETC2 and ASTC support are still missing on the latest Apple devices. Filed an issue here:
opened 06:11PM - 27 Nov 21 UTC
Mentioned in the forums ([Basis textures with alpha appearing fully black and wh… ite on some iPads...](https://discourse.threejs.org/t/basis-textures-with-alpha-appearing-fully-black-and-white-on-some-ipads-and-older-mobile-devices-when-rgb-pvrtc-4bppv1-format-is-used/22575)), KTX2Loader may select ETC1 as the transcoding target for textures containing alpha, meaning that the alpha channel is skipped. KTX2Loader selects a transcode target based on the weights defined here:
https://github.com/mrdoob/three.js/blob/244c8f1cdae7feffd1c577446b45161849a057ee/examples/jsm/loaders/KTX2Loader.js#L475-L482
On macOS, this example looks fine in Chrome and Firefox for me, but not in Safari: https://threejs.org/examples/?q=ktx2#webgl_loader_texture_ktx2
<img width="659" alt="Screen Shot 2021-11-27 at 9 55 55 AM" src="https://user-images.githubusercontent.com/1848368/143691777-9c673aa6-192a-4757-a23e-6f329fdca0d5.png">
The dark upper right corner shows that alpha is lost. Notably, when transcoding an ETC1S texture, priority of ETC1 is higher than priority of DXT. That would make sense if the texture didn't have alpha, but not if it did — you need ETC2 for alpha.
There's an 'easy' fix for this – we could just skip ETC1 and go to the next highest priority target format for textures with alpha. But, I was under the impression that iOS and macOS devices should support more formats than this. I'm using an M1 chip, which _should_ support practically every GPU texture format under the sun ([Khronos WebGL Guidelines](https://github.com/KhronosGroup/3D-Formats-Guidelines/blob/main/KTXDeveloperGuideWebGL.md#platform-support-table), April 2021). As of June, Safari was [running WebGL on Metal via ANGLE](https://twitter.com/grorgwork/status/1402307966817116161). It seems really unfortunate that we can't get ETC2 or ASTC support on the latest Apple devices, and I thought that was on the roadmap. Anyone know if I've missed something there?
1 Like