Do gamma conversion manualy
Requesting sRGB capable framebuffer is unreliable
This commit is contained in:
@@ -87,9 +87,6 @@ ImageWidget::ImageWidget(Database *database, QWidget *parent) : QOpenGLWidget(pa
|
|||||||
});
|
});
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
#ifdef COLOR_MANAGMENT
|
|
||||||
setTextureFormat(GL_SRGB8_ALPHA8);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageWidget::~ImageWidget()
|
ImageWidget::~ImageWidget()
|
||||||
@@ -335,9 +332,6 @@ void ImageWidget::paintGL()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef COLOR_MANAGMENT
|
|
||||||
if(m_srgb)f->glEnable(GL_FRAMEBUFFER_SRGB);
|
|
||||||
#endif
|
|
||||||
m_vao->bind();
|
m_vao->bind();
|
||||||
m_image->bind(0);
|
m_image->bind(0);
|
||||||
m_program->bind();
|
m_program->bind();
|
||||||
@@ -347,10 +341,10 @@ void ImageWidget::paintGL()
|
|||||||
m_program->setUniformValue("zoom", 1.0f/m_scale);
|
m_program->setUniformValue("zoom", 1.0f/m_scale);
|
||||||
m_program->setUniformValue("bw", m_bwImg);
|
m_program->setUniformValue("bw", m_bwImg);
|
||||||
m_program->setUniformValue("invert", m_invert);
|
m_program->setUniformValue("invert", m_invert);
|
||||||
f->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
#ifdef COLOR_MANAGMENT
|
#ifdef COLOR_MANAGMENT
|
||||||
if(m_srgb)f->glDisable(GL_FRAMEBUFFER_SRGB);
|
m_program->setUniformValue("srgb", m_srgb);
|
||||||
#endif
|
#endif
|
||||||
|
f->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -406,7 +406,7 @@ void LoadRunable::run()
|
|||||||
{
|
{
|
||||||
QImage img(m_file);
|
QImage img(m_file);
|
||||||
#ifdef COLOR_MANAGMENT
|
#ifdef COLOR_MANAGMENT
|
||||||
if(img.colorSpace().isValid())
|
if(img.colorSpace().isValid() && img.colorSpace() != QColorSpace::SRgb)
|
||||||
img.convertToColorSpace(QColorSpace::SRgb);
|
img.convertToColorSpace(QColorSpace::SRgb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ int main(int argc, char *argv[])
|
|||||||
format.setMinorVersion(3);
|
format.setMinorVersion(3);
|
||||||
format.setOption(QSurfaceFormat::DebugContext);
|
format.setOption(QSurfaceFormat::DebugContext);
|
||||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
|
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
|
||||||
#ifdef COLOR_MANAGMENT
|
|
||||||
format.setColorSpace(QSurfaceFormat::sRGBColorSpace);
|
|
||||||
#endif
|
|
||||||
QSurfaceFormat::setDefaultFormat(format);
|
QSurfaceFormat::setDefaultFormat(format);
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|||||||
@@ -4,9 +4,17 @@ uniform sampler2D qt_Texture0;
|
|||||||
uniform vec3 mtf_param;
|
uniform vec3 mtf_param;
|
||||||
uniform bool bw;
|
uniform bool bw;
|
||||||
uniform bool invert;
|
uniform bool invert;
|
||||||
|
uniform bool srgb;
|
||||||
in vec2 qt_TexCoord0;
|
in vec2 qt_TexCoord0;
|
||||||
out vec4 color;
|
out vec4 color;
|
||||||
|
|
||||||
|
vec3 Linear2sRGB(vec3 color)
|
||||||
|
{
|
||||||
|
return mix(12.92 * color.rgb,
|
||||||
|
1.055 * pow(color, vec3(1.0 / 2.4)) - 0.055,
|
||||||
|
greaterThan(color, vec3(0.0031308)));
|
||||||
|
}
|
||||||
|
|
||||||
vec4 MTF(vec4 x, vec3 m)
|
vec4 MTF(vec4 x, vec3 m)
|
||||||
{
|
{
|
||||||
x = (x - m.x) / (m.z - m.x);
|
x = (x - m.x) / (m.z - m.x);
|
||||||
@@ -22,6 +30,8 @@ void main(void)
|
|||||||
|
|
||||||
if(invert)color = vec4(1.0) - color;
|
if(invert)color = vec4(1.0) - color;
|
||||||
|
|
||||||
|
if(srgb)color.rgb = Linear2sRGB(color.rgb);
|
||||||
|
|
||||||
if(any(lessThan(qt_TexCoord0, vec2(0.0))) || any(greaterThan(qt_TexCoord0, vec2(1.0))))
|
if(any(lessThan(qt_TexCoord0, vec2(0.0))) || any(greaterThan(qt_TexCoord0, vec2(1.0))))
|
||||||
color = vec4(0.0, 0.0, 0.0, 1.0);
|
color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user