We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
如 #1227 描述, 现在引擎 shader 中采样的纹理有很多 gammaToLinear 的操作,如果支持硬件级别的 sRGB 纹理格式,有以下优点:
gammaToLinear
pow
pow(2.2)
ext.SRGB_EXT
gl2.SRGB8
ext.SRGB_ALPHA_EXT
gl2.SRGB8_ALPHA8
只有 WebGL2.0 的 SRGB8_ALPHA8格式才支持自动生成 Mipmap,否则会报以下错误:
SRGB8_ALPHA8
这个是 WebGL 底层的缺陷,无法绕过去。
调研结果:Threejs 检查报错,不强制禁止;Babylonjs 不检查也不强制禁止;
我们可以判断当前环境 sRGB 是否支持 mipmap,如果不支持的话,引擎做以下处理:
generateMipmap
TEXTURE_MIN_FILTER
gl.NEAREST
gl.LINEAR
调研结果:
sRGB
sRGB 开关
一般跟视觉相关的纹理都需要 sRGB 格式,用户可以选中纹理,自己切换为 sRGB 格式,以下引擎内置的纹理也需要改为 sRGB:
camera_OpaqueTexture
The text was updated successfully, but these errors were encountered:
zhuxudong
No branches or pull requests
背景和价值
如 #1227 描述, 现在引擎 shader 中采样的纹理有很多
gammaToLinear
的操作,如果支持硬件级别的 sRGB 纹理格式,有以下优点:pow
等计算指令次数。pow(2.2)
更准确,保证美术资源色彩一致性。gammaToLinear
那一坨代码了 (关键问题和解决方案
1. 兼容性问题
ext.SRGB_EXT
对标gl2.SRGB8
;ext.SRGB_ALPHA_EXT
对标gl2.SRGB8_ALPHA8
;在生成 MSAA 时,使用gl2.SRGB8_ALPHA8
。2. Mipmap 支持问题
只有 WebGL2.0 的
SRGB8_ALPHA8
格式才支持自动生成 Mipmap,否则会报以下错误:这个是 WebGL 底层的缺陷,无法绕过去。
调研结果:Threejs 检查报错,不强制禁止;Babylonjs 不检查也不强制禁止;
我们可以判断当前环境 sRGB 是否支持 mipmap,如果不支持的话,引擎做以下处理:
generateMipmap
。TEXTURE_MIN_FILTER
为gl.NEAREST
或者gl.LINEAR
。3. 开关设计
调研结果:
sRGB
开关。sRGB 开关
。4. 哪些纹理需要 sRGB 格式
一般跟视觉相关的纹理都需要 sRGB 格式,用户可以选中纹理,自己切换为 sRGB 格式,以下引擎内置的纹理也需要改为 sRGB:
camera_OpaqueTexture
。5. 压缩纹理
WEBGL_compressed_texture_s3tc_srgb
附录
The text was updated successfully, but these errors were encountered: