mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-02 06:26:00 +01:00
Improve the control of shadow_render_power & make it less confusin.
This commit is contained in:
parent
7579e03b64
commit
4a2ba088ae
3 changed files with 19 additions and 19 deletions
|
@ -79,7 +79,7 @@ void CConfigManager::setDefaultVars() {
|
||||||
configValues["decoration:no_blur_on_oversized"].intValue = 0;
|
configValues["decoration:no_blur_on_oversized"].intValue = 0;
|
||||||
configValues["decoration:drop_shadow"].intValue = 1;
|
configValues["decoration:drop_shadow"].intValue = 1;
|
||||||
configValues["decoration:shadow_range"].intValue = 4;
|
configValues["decoration:shadow_range"].intValue = 4;
|
||||||
configValues["decoration:shadow_render_power"].intValue = 3;
|
configValues["decoration:shadow_render_power"].floatValue = 0.5f;
|
||||||
configValues["decoration:shadow_ignore_window"].intValue = 1;
|
configValues["decoration:shadow_ignore_window"].intValue = 1;
|
||||||
configValues["decoration:shadow_offset"].vecValue = Vector2D();
|
configValues["decoration:shadow_offset"].vecValue = Vector2D();
|
||||||
configValues["decoration:col.shadow"].intValue = 0xee1a1a1a;
|
configValues["decoration:col.shadow"].intValue = 0xee1a1a1a;
|
||||||
|
|
|
@ -1038,9 +1038,9 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl
|
||||||
RASSERT((box->width > 0 && box->height > 0), "Tried to render shadow with width/height < 0!");
|
RASSERT((box->width > 0 && box->height > 0), "Tried to render shadow with width/height < 0!");
|
||||||
RASSERT(m_pCurrentWindow, "Tried to render shadow without a window!");
|
RASSERT(m_pCurrentWindow, "Tried to render shadow without a window!");
|
||||||
|
|
||||||
static auto *const PSHADOWPOWER = &g_pConfigManager->getConfigValuePtr("decoration:shadow_render_power")->intValue;
|
static auto *const PSHADOWPOWER = &g_pConfigManager->getConfigValuePtr("decoration:shadow_render_power")->floatValue;
|
||||||
|
|
||||||
const auto SHADOWPOWER = std::clamp((int)*PSHADOWPOWER, 1, 4);
|
const auto SHADOWPOWER = std::max(*PSHADOWPOWER , 0.0f); // TODO: we should do that only once at startup and if the config changed
|
||||||
|
|
||||||
const auto col = m_pCurrentWindow->m_cRealShadowColor.col();
|
const auto col = m_pCurrentWindow->m_cRealShadowColor.col();
|
||||||
|
|
||||||
|
@ -1069,7 +1069,7 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl
|
||||||
glUniform2f(m_RenderData.pCurrentMonData->m_shSHADOW.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y);
|
glUniform2f(m_RenderData.pCurrentMonData->m_shSHADOW.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y);
|
||||||
glUniform2f(m_RenderData.pCurrentMonData->m_shSHADOW.bottomRight, (float)BOTTOMRIGHT.x, (float)BOTTOMRIGHT.y);
|
glUniform2f(m_RenderData.pCurrentMonData->m_shSHADOW.bottomRight, (float)BOTTOMRIGHT.x, (float)BOTTOMRIGHT.y);
|
||||||
glUniform2f(m_RenderData.pCurrentMonData->m_shSHADOW.fullSize, (float)FULLSIZE.x, (float)FULLSIZE.y);
|
glUniform2f(m_RenderData.pCurrentMonData->m_shSHADOW.fullSize, (float)FULLSIZE.x, (float)FULLSIZE.y);
|
||||||
glUniform1f(m_RenderData.pCurrentMonData->m_shSHADOW.radius, range + round);
|
glUniform1f(m_RenderData.pCurrentMonData->m_shSHADOW.radius, round);
|
||||||
glUniform1f(m_RenderData.pCurrentMonData->m_shSHADOW.range, range);
|
glUniform1f(m_RenderData.pCurrentMonData->m_shSHADOW.range, range);
|
||||||
glUniform1f(m_RenderData.pCurrentMonData->m_shSHADOW.shadowPower, SHADOWPOWER);
|
glUniform1f(m_RenderData.pCurrentMonData->m_shSHADOW.shadowPower, SHADOWPOWER);
|
||||||
|
|
||||||
|
|
|
@ -14,14 +14,14 @@ uniform float radius;
|
||||||
uniform float range;
|
uniform float range;
|
||||||
uniform float shadowPower;
|
uniform float shadowPower;
|
||||||
|
|
||||||
float pixAlphaRoundedDistance(float distanceToCorner) {
|
float pixAlphaRoundedDistance(float distanceToRadiusCenter) {
|
||||||
if (distanceToCorner > radius) {
|
float distanceToCorner = distanceToRadiusCenter - radius;
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (distanceToCorner > radius - range) {
|
if (distanceToCorner > range)
|
||||||
return pow((range - (distanceToCorner - radius + range)) / range, shadowPower); // i think?
|
return 0.0;
|
||||||
}
|
|
||||||
|
if (distanceToCorner > 0.0)
|
||||||
|
return 1.0 - pow(distanceToCorner / range, shadowPower);
|
||||||
|
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
@ -66,15 +66,15 @@ void main() {
|
||||||
float distanceL = pixCoord[0];
|
float distanceL = pixCoord[0];
|
||||||
float distanceR = fullSize[0] - pixCoord[0];
|
float distanceR = fullSize[0] - pixCoord[0];
|
||||||
|
|
||||||
// get the smallest
|
// get the distance to the closest edge
|
||||||
float smallest = min(min(distanceT, distanceB), min(distanceL, distanceR));
|
float distanceToEdge = range - min(min(distanceT, distanceB), min(distanceL, distanceR));
|
||||||
|
|
||||||
if (smallest < range) {
|
if (distanceToEdge > 0.0) {
|
||||||
pixColor[3] = pixColor[3] * pow((smallest / range), shadowPower);
|
pixColor[3] *= 1.0 - pow(distanceToEdge / range, shadowPower);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixColor[3] == 0.0) {
|
if (pixColor[3] == 0.0) { // TODO: is this necessary?
|
||||||
discard; return;
|
discard; return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue