【发布时间】:2011-06-18 17:52:35
【问题描述】:
色彩空间。好了,大家都知道RGB了:在[0.0,1.0]范围内归一化的三个值,分别代表颜色分量Red Green Blue的强度;这个强度是线性的,不是吗?
伽玛。据我所知,gamma 是将 RGB 颜色分量映射到另一个值的函数。谷歌搜索,我看到了线性函数和非线性函数...... 线性函数似乎可以缩放 RGB 分量,因此似乎可以调整图像亮度;非线性函数似乎可以“解压缩”较暗/较亮的组件。
现在,我开始实现一个图像查看器,它将不同的图像格式显示为纹理。我想修改这些图像的伽玛,所以我应该建立一个片段着色器并在纹理四边形上运行。很好,但是如何确定正确的伽马校正?
OpenGL 使用线性 RGB 颜色空间,使用浮点组件。实际上,我可以从这些值(具有特殊的浮点精度)开始计算伽玛校正值,因此它们在钳制伽玛校正值后显示。
首先,我将确定伽马斜坡。我怎么能确定呢? (分析或使用查找表)
然后,我开始研究OpenGL扩展EXT_framebuffer_sRGB,它似乎与扩展EXT_texture_sRGB非常相关。
EXT_texture_sRGB 引入了一种新的纹理格式,用于将文本值线性化到 RGB 线性空间中。 (脚注1)通过这种方式,我知道sRGB色彩空间并将其用作线性RGB色彩空间。
相反,EXT_framebuffer_sRGB 扩展允许我将线性 RGB 值编码到 sRGB 帧缓冲区,而无需担心。
...
等等,所有这些信息是为了什么?如果我可以使用 sRGB 帧缓冲区并加载 sRGB 纹理,则无需 sRGB 转换即可处理该纹理...为什么要更正伽玛?
即使在 sRGB 缓冲区上,我也可以同样校正伽玛吗?或者我最好不要?以及亮度和对比度:它们应该在伽马校正之前还是之后应用?
这是很多信息,我现在感到困惑。希望你们中的某个人能更多地向我解释所有这些概念!谢谢。
...
还有一个问题。如果设备伽玛不同于“标准”2.2,我如何“累积”不同的伽玛校正?我不知道是否清楚:如果图像 RGB 值已经针对 gamma 值为 2.2 的显示器进行了校正,但显示器的 gamma 值为 2.8,我该如何校正 gamma?
(1) 这里有一些摘录来强调我的意思:
sRGB 色彩空间基于典型(非线性)显示器 在光线昏暗的办公室中预期的特征。它一直 由国际电工委员会 (IEC) 标准化 为 IEC 61966-2-1。 sRGB色彩空间大致对应2.2 伽玛校正。
此扩展是否提供任何类型的 sRGB 帧缓冲格式 或保证使用 sRGB 纹理渲染的图像“看起来不错” 何时输出到支持 sRGB 颜色空间的设备?
RESOLVED: No. Whether the displayed framebuffer is displayed to a monitor that faithfully reproduces the sRGB color space is beyond the scope of this extension. This involves the gamma correction and color calibration of the physical display device. With this extension, artists can author content in an sRGB color space and provide that sRGB content for use as texture imagery that can be properly converted to linear RGB and filtered as part of texturing in a way that preserves the sRGB distribution of precision, but that does NOT mean sRGB pixels are output to the framebuffer. Indeed, this extension provides texture formats that convert sRGB to linear RGB as part of filtering. With programmable shading, an application could perform a linear RGB to sRGB conversion just prior to emitting color values from the shader. Even so, OpenGL blending (other than simple modulation) will perform linear math operations on values stored in a non-linear space which is technically incorrect for sRGB-encoded colors. One way to think about these sRGB texture formats is that they simply provide color components with a distribution of values distributed to favor precision towards 0 rather than evenly distributing the precision with conventional non-sRGB formats such as GL_RGB8.
【问题讨论】:
-
我会说我将在不适合消费者的显示器上渲染,但它实际上专门用于 HDR 图像处理。目前我没有显示器规格,但我怀疑我应该在渲染期间应用伽马校正。
标签: opengl rgb gamma srgb gamma-distribution