我在使用带有 WebGL2 的 sRGB 纹理时遇到问题。我正在尝试加载纹理并将其显示为全屏四边形,但图像显示不正确(太暗。)
纹理加载代码如下。
const texture0 = await (() => {
const image = new Image()
const promise = new Promise(resolve => image.onload = () => {
const texture = gl.createTexture()
gl.bindTexture(gl.TEXTURE_2D, texture)
gl.texStorage2D(gl.TEXTURE_2D, 1, gl.SRGB8_ALPHA8, 256, 256)
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 256, 256, gl.RGBA, gl.UNSIGNED_BYTE, image)
resolve(texture)
})
image.src = "./images/texture.png"
return promise
})()
我在想它可能与帧缓冲区的编码有关,但我确实在 WebGL 中看到了 glEnable(GL_FRAMEBUFFER_SRGB) 的等价物。