Remove sRGB inline decoding.
See original GitHub issueI’m currently working on a PR to remove the inline sRGB decode from the shader. We want to do this to avoid wrong texture filtering which was discussed in earlier issues. The removal also simplifies the code base at various places (especially the WebGL 2 code paths).
The idea is to use SRGB8_ALPHA8
with WebGL 2 and a fallback for WebGL 1. In order to use SRGB8_ALPHA8
, textures have to be in RGBA format and must use unsigned byte which is true for most color textures. However, there are a couple of issues with that approach and I want to discuss them step by step. The first problem is processing compressed textures holding sRGB encoded values like in:
How should we handle this use case? Decoding compressed texels values on the CPU is by definition no option. If you do a separate render pass and decode the texture into a render target, we would loose the compression (unless we compress it again which is no good idea either).
As far as I understand we can only support compressed textures with sRGB values if formats like SRGB8_ALPHA8_ASTC_4x4_Format
are used. Or we have to keep the inline decode. Are there any other options?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:16 (5 by maintainers)
Top GitHub Comments
I’ve added a solution here: https://github.com/mrdoob/three.js/pull/23129/commits/57ac4776ac7328f7fd239c5b24b61a96171e8419
Should be easy to revert when the Chromium bug is solved.
Just for the protocol:
VideoTexture
does not usegl.texStorage2D()
right now and with the above commit noSRGB8_ALPHA8
format. The sRGB decode happens inline and only if the texture is assigned to themap
property.Yes, it can. However,
three.js
does not support them yet. After looking at the extensions the following sRGB formats could be added:WEBGL_compressed_texture_etc
COMPRESSED_SRGB8_ETC2
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2
.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
WEBGL_compressed_texture_s3tc_srgb
COMPRESSED_SRGB_S3TC_DXT1_EXT
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
EXT_texture_compression_bptc
COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT