gpt4 book ai didi

c++ - GL_FRAMEBUFFER_SRGB 是否仅适用于前/后缓冲区?

转载 作者:行者123 更新时间:2023-11-28 04:54:04 33 4
gpt4 key购买 nike

我正在尝试使用 GL_FRAMEBUFFER_SRGB 将 sRGB 空间值写入帧缓冲区,但我发现 glEnable(GL_FRAMEBUFFER_SRGB) 的调用仅适用于前/后缓冲区,不适用于从纹理创建的其他帧缓冲区。

我的流水线是这样的:

  1. 首先是将场景渲染到 GL_RGB10_A2 缓冲区的场景阶段;
  2. 然后是渲染到 GL_RGB8(0x8051) 缓冲区的后处理阶段,
  3. 最终呈现到前/后缓冲区的后处理链。

我尝试为每个阶段执行 glEnable(GL_FRAMEBUFFER_SRGB)。由于所有渲染缓冲区都不是 sRGB 格式,所以下一阶段不会自动进行任何 sRGB 到线性转换,而且我也没有在着色器中进行任何转换,我应该期待最终结果会变得非常明亮,因为多重线性 -到 sRGB 转换。但它仅适用于渲染到前/后缓冲区的最后阶段,因此最终结果不会变得非常明亮。

我尝试了几种渲染缓冲区的格式(GL_RGB8、GL_RGBA8、GL_SRGB8_ALPHA8),但还是不行。

我是否遗漏了规范中的某些内容?在 win7 上使用 GTX750 和最新的驱动程序。

最佳答案

首先是OpenGL 4.6 Core Profile规范说(强调我的):

Section 17.3.6.1 Blend Equation

If FRAMEBUFFER_SRGB is enabled and the value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the framebuffer attachment corresponding to the destination buffer is SRGB (see section 9.2.3), the R, G, and B destination color values (after conversion from fixed-point to floating-point) are considered to be encoded for the sRGB color space and hence must be linearized prior to their use in blending. Each R, G, and B component is converted in the same fashion described for sRGB texture components in section 8.24.

If FRAMEBUFFER_SRGB is disabled or the value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING is not SRGB, no linearization is performed.

The resulting linearized R, G, and B and unmodified A values are recombined as the destination color used in blending computations. Table 17.1 provides the corresponding per-component

17.3.7 sRGB Conversion (occurs after blending)

If FRAMEBUFFER_SRGB is enabled and the value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the framebuffer attachment corresponding to the destination buffer is SRGB (see section 9.2.3), the R, G, and B values after blending are converted into the non-linear sRGB color space by computing [cs = sRGB(cl)] where cl is the R, G, or B element and cs is the result (effectively converted into an sRGB color space).

If FRAMEBUFFER_SRGB is disabled or the value of FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING is not SRGB, then cs = cl. The resulting cs values for R, G, and B, and the unmodified A form a new RGBA color value.

关于您的案例,有两件事对我来说很突出:

  1. 检查 GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 的值
  2. 部分过程仅在启用混合时才会发生。

OpenGL 的 sRGB 支持的主要目的是能够输出 sRGB 颜色并使它们在线性空间中正确混合。

关于c++ - GL_FRAMEBUFFER_SRGB 是否仅适用于前/后缓冲区?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47554628/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com