mirror of
https://github.com/hyprwm/Hyprland
synced 2026-05-07 15:38:05 +02:00
use precalculated cm for shadows
This commit is contained in:
parent
573440b6fd
commit
acdcbaa796
5 changed files with 15 additions and 89 deletions
|
|
@ -2243,14 +2243,12 @@ void CHyprOpenGLImpl::renderRoundedShadow(const CBox& box, int round, float roun
|
|||
|
||||
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_SHADOW, skipCM ? 0 : SH_FEAT_CM | (IS_ICC ? SH_FEAT_ICC : SH_FEAT_TONEMAP | SH_FEAT_SDR_MOD) | globalFeatures()));
|
||||
if (!skipCM)
|
||||
passCMUniforms(shader, getDefaultImageDescription());
|
||||
auto shader = useShader(getShaderVariant(SH_FRAG_SHADOW, 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(range + round, range + round);
|
||||
const auto BOTTOMRIGHT = Vector2D(newBox.width - (range + round), newBox.height - (range + round));
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ void CShader::getUniformLocations() {
|
|||
|
||||
m_uniformLocations[SHADER_PROJ] = getUniform("proj");
|
||||
m_uniformLocations[SHADER_COLOR] = getUniform("color");
|
||||
m_uniformLocations[SHADER_COLOR_SRGB] = getUniform("colorSRGB");
|
||||
m_uniformLocations[SHADER_ALPHA_MATTE] = getUniform("texMatte");
|
||||
m_uniformLocations[SHADER_TEX_TYPE] = getUniform("texType");
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
enum eShaderUniform : uint8_t {
|
||||
SHADER_PROJ = 0,
|
||||
SHADER_COLOR,
|
||||
SHADER_COLOR_SRGB,
|
||||
SHADER_ALPHA_MATTE,
|
||||
SHADER_TEX_TYPE,
|
||||
SHADER_SOURCE_TF,
|
||||
|
|
|
|||
|
|
@ -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 windowTopLeft;
|
||||
|
|
@ -23,11 +20,6 @@ uniform float range;
|
|||
uniform float shadowPower;
|
||||
uniform float thick;
|
||||
|
||||
#if USE_CM
|
||||
#include "cm_helpers.glsl"
|
||||
#include "CM.glsl"
|
||||
#endif
|
||||
|
||||
#include "shadow.glsl"
|
||||
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
|
@ -41,29 +33,7 @@ void main() {
|
|||
#else
|
||||
fragColor =
|
||||
#endif
|
||||
getShadow(pixColor, v_texcoord, radius, roundingPower, topLeft, fullSize, range, shadowPower, bottomRight, windowTopLeft, windowBottomRight, thick
|
||||
#if USE_CM
|
||||
,
|
||||
sourceTF, targetTF, convertMatrix, srcTFRange, dstTFRange
|
||||
#if USE_ICC
|
||||
,
|
||||
iccLut3D, iccLutSize
|
||||
#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
|
||||
);
|
||||
getShadow(pixColor, colorSRGB, v_texcoord, radius, roundingPower, topLeft, fullSize, range, shadowPower, bottomRight, windowTopLeft, windowBottomRight, thick);
|
||||
#if USE_MIRROR
|
||||
fragColor = pixColors[0];
|
||||
mirrorColor = pixColors[1];
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#ifndef SHADOW_GLSL
|
||||
#define SHADOW_GLSL
|
||||
|
||||
#include "cm_helpers.glsl"
|
||||
#include "rounding.glsl"
|
||||
|
||||
float pixAlphaRoundedDistance(float distanceToCorner, float radius, float range, float shadowPower) {
|
||||
|
|
@ -54,30 +53,8 @@ vec4[2]
|
|||
#else
|
||||
vec4
|
||||
#endif
|
||||
getShadow(vec4 pixColor, vec2 v_texcoord, float borderRadius, float roundingPower, vec2 topLeft, vec2 fullSize, float range, float shadowPower, vec2 bottomRight,
|
||||
vec2 windowTopLeft, vec2 windowBottomRight, float windowRadius
|
||||
#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
|
||||
) {
|
||||
getShadow(vec4 pixColor, vec4 colorSRGB, vec2 v_texcoord, float borderRadius, float roundingPower, vec2 topLeft, vec2 fullSize, float range, float shadowPower, vec2 bottomRight,
|
||||
vec2 windowTopLeft, vec2 windowBottomRight, float windowRadius) {
|
||||
float radius = range + borderRadius;
|
||||
float originalAlpha = pixColor[3];
|
||||
|
||||
|
|
@ -144,33 +121,12 @@ vec4
|
|||
// premultiply
|
||||
pixColor.rgb *= pixColor[3];
|
||||
|
||||
#if USE_CM
|
||||
#if USE_MIRROR
|
||||
vec4[2] pixColors =
|
||||
#else
|
||||
pixColor =
|
||||
#endif
|
||||
doColorManagement(pixColor, sourceTF, targetTF, convertMatrix, srcTFRange, dstTFRange
|
||||
#if USE_ICC
|
||||
,
|
||||
iccLut3D, iccLutSize
|
||||
#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
|
||||
#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
|
||||
return pixColor;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue