颜色空间。众所周知,RGB是三个范围在[0.0,1.0]内的值,它们代表颜色分量红色、绿色和蓝色的强度;这种强度被认为是线性的,对吗?
伽马。据我所知,伽马是一种将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值已经针对伽马值为2.2的监视器进行了校正,但监视器具有伽马值为2.8的值,那么我该如何进行伽马校正?
(1)以下是一些摘录以突出我的意思:
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.