inner glow cm

This commit is contained in:
UjinT34 2026-04-26 19:41:51 +03:00
parent acdcbaa796
commit 1b441e97f8
3 changed files with 24 additions and 82 deletions

View file

@ -2335,14 +2335,12 @@ void CHyprOpenGLImpl::renderInnerGlow(const CBox& box, int round, float rounding
blend(true);
const bool IS_ICC = g_pHyprRenderer->workBufferImageDescription()->value().icc.present;
const bool skipCM = !m_cmSupported || !g_pHyprRenderer->workBufferImageDescription()->needsCM(getDefaultImageDescription());
auto shader = useShader(getShaderVariant(SH_FRAG_INNER_GLOW, skipCM ? 0 : SH_FEAT_CM | (IS_ICC ? SH_FEAT_ICC : SH_FEAT_TONEMAP | SH_FEAT_SDR_MOD)));
if (!skipCM)
passCMUniforms(shader, getDefaultImageDescription());
auto shader = useShader(getShaderVariant(SH_FRAG_INNER_GLOW, globalFeatures()));
shader->setUniformMatrix3fv(SHADER_PROJ, 1, GL_TRUE, glMatrix.getMatrix());
shader->setUniformFloat4(SHADER_COLOR, col.r, col.g, col.b, col.a * a);
const auto converted = convertColor(col, DEFAULT_SRGB_IMAGE_DESCRIPTION, g_pHyprRenderer->workBufferImageDescription());
shader->setUniformFloat4(SHADER_COLOR, converted.r, converted.g, converted.b, converted.a * a);
shader->setUniformFloat4(SHADER_COLOR_SRGB, col.r, col.g, col.b, col.a * a);
const auto TOPLEFT = Vector2D(round, round);
const auto BOTTOMRIGHT = Vector2D(newBox.width - round, newBox.height - round);

View file

@ -8,10 +8,7 @@ precision highp float;
in vec4 v_color;
in vec2 v_texcoord;
uniform int sourceTF; // eTransferFunction
uniform int targetTF; // eTransferFunction
uniform mat3 targetPrimariesXYZ;
uniform vec4 colorSRGB;
uniform vec2 topLeft;
uniform vec2 bottomRight;
uniform vec2 fullSize;
@ -20,38 +17,22 @@ uniform float roundingPower;
uniform float range;
uniform float shadowPower;
#if USE_CM
#include "cm_helpers.glsl"
#include "CM.glsl"
#endif
#include "inner_glow.glsl"
layout(location = 0) out vec4 fragColor;
#if USE_MIRROR
layout(location = 1) out vec4 mirrorColor;
#endif
void main() {
vec4 pixColor = v_color;
fragColor = getInnerGlow(pixColor, v_texcoord, radius, roundingPower, topLeft, fullSize, range, shadowPower, bottomRight
#if USE_CM
,
sourceTF, targetTF, convertMatrix, srcTFRange, dstTFRange
#if USE_ICC
,
iccLut3D, iccLutSize
#if USE_MIRROR
vec4[2] pixColors =
#else
#if USE_TONEMAP || USE_SDR_MOD
,
targetPrimariesXYZ
fragColor =
#endif
#if USE_TONEMAP
,
maxLuminance, dstMaxLuminance, dstRefLuminance, srcRefLuminance
getInnerGlow(pixColor, colorSRGB, v_texcoord, radius, roundingPower, topLeft, fullSize, range, shadowPower, bottomRight);
#if USE_MIRROR
fragColor = pixColors[0];
mirrorColor = pixColors[1];
#endif
#if USE_SDR_MOD
,
sdrSaturation, sdrBrightnessMultiplier
#endif
#endif
#endif
);
}

View file

@ -5,8 +5,6 @@
#ifndef INNER_GLOW_GLSL
#define INNER_GLOW_GLSL
#include "cm_helpers.glsl"
float innerGlowAlpha(float distFromEdge, float range, float glowPower) {
if (distFromEdge >= range)
return 0.0;
@ -26,29 +24,7 @@ float innerGlowSmin(float a, float b, float k) {
return min(a, b) - h * h * h * k * (1.0 / 6.0);
}
vec4 getInnerGlow(vec4 pixColor, vec2 v_texcoord, float radius, float roundingPower, vec2 topLeft, vec2 fullSize, float range, float glowPower, vec2 bottomRight
#if USE_CM
,
int sourceTF, int targetTF, mat3 convertMatrix, vec2 srcTFRange, vec2 dstTFRange
#if USE_ICC
,
highp sampler3D iccLut3D, float iccLutSize
#else
#if USE_TONEMAP || USE_SDR_MOD
,
mat3 targetPrimariesXYZ
#endif
#if USE_TONEMAP
,
float maxLuminance, float dstMaxLuminance, float dstRefLuminance, float srcRefLuminance
#endif
#if USE_SDR_MOD
,
float sdrSaturation, float sdrBrightnessMultiplier
#endif
#endif
#endif
) {
vec4 getInnerGlow(vec4 pixColor, vec4 colorSRGB, vec2 v_texcoord, float radius, float roundingPower, vec2 topLeft, vec2 fullSize, float range, float glowPower, vec2 bottomRight) {
vec2 pixCoord = fullSize * v_texcoord;
// clip to the rounded rectangle shape using actual SDF
@ -79,28 +55,15 @@ vec4 getInnerGlow(vec4 pixColor, vec2 v_texcoord, float radius, float roundingPo
// premultiply
pixColor.rgb *= pixColor[3];
#if USE_CM
pixColor = doColorManagement(pixColor, sourceTF, targetTF, convertMatrix, srcTFRange, dstTFRange
#if USE_ICC
,
iccLut3D, iccLutSize
#if USE_MIRROR
vec4[2] pixColors;
pixColors[0] = pixColor;
pixColors[1] = colorSRGB;
pixColors[1].a = pixColor.a;
pixColors[1].rgb *= pixColors[1].a;
return pixColors;
#else
#if USE_TONEMAP || USE_SDR_MOD
,
targetPrimariesXYZ
#endif
#if USE_TONEMAP
,
maxLuminance, dstMaxLuminance, dstRefLuminance, srcRefLuminance
#endif
#if USE_SDR_MOD
,
sdrSaturation, sdrBrightnessMultiplier
#endif
#endif
);
#endif
return pixColor;
#endif
}
#endif