From 824438949e60ad6d6fefdfa37f0af8fbe0849934 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 2 Aug 2025 16:21:01 +0200 Subject: [PATCH] renderer: apply default luma for reverting back to srgb fixes #11315 --- src/render/OpenGL.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 420e997e..65cd4c65 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -1593,9 +1593,9 @@ void CHyprOpenGLImpl::renderTextureInternal(SP tex, const CBox& box, c tex->setTexParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR); } - const auto imageDescription = m_renderData.surface.valid() && m_renderData.surface->m_colorManagement.valid() ? - m_renderData.surface->m_colorManagement->imageDescription() : - (data.cmBackToSRGB ? data.cmBackToSRGBSource->m_imageDescription : SImageDescription{}); + auto imageDescription = m_renderData.surface.valid() && m_renderData.surface->m_colorManagement.valid() ? + m_renderData.surface->m_colorManagement->imageDescription() : + (data.cmBackToSRGB ? data.cmBackToSRGBSource->m_imageDescription : SImageDescription{}); const bool skipCM = !*PENABLECM || !m_cmSupported /* CM unsupported or disabled */ || (imageDescription == m_renderData.pMonitor->m_imageDescription && !data.cmBackToSRGB) /* Source and target have the same image description */ @@ -1610,9 +1610,12 @@ void CHyprOpenGLImpl::renderTextureInternal(SP tex, const CBox& box, c if (shader == &m_shaders->m_shCM) { shader->setUniformInt(SHADER_TEX_TYPE, texType); - if (data.cmBackToSRGB) + if (data.cmBackToSRGB) { + // revert luma changes to avoid black screenshots. + // this will likely not be 1:1, and might cause screenshots to be too bright, but it's better than pitch black. + imageDescription.luminances = {}; passCMUniforms(*shader, imageDescription, NColorManagement::SImageDescription{}, true, -1, -1); - else + } else passCMUniforms(*shader, imageDescription); }