Skip to content

Commit

Permalink
Merge pull request #170 from taj-ny/static-blur-scale
Browse files Browse the repository at this point in the history
static-blur: remove unnecessary scale uniform from the shader
  • Loading branch information
taj-ny authored Jan 16, 2025
2 parents 668452e + 617ffa6 commit f7bb683
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
8 changes: 3 additions & 5 deletions src/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ BlurEffect::BlurEffect()
m_texture.textureSizeLocation = m_texture.shader->uniformLocation("textureSize");
m_texture.texStartPosLocation = m_texture.shader->uniformLocation("texStartPos");
m_texture.blurSizeLocation = m_texture.shader->uniformLocation("blurSize");
m_texture.scaleLocation = m_texture.shader->uniformLocation("scale");
m_texture.topCornerRadiusLocation = m_texture.shader->uniformLocation("topCornerRadius");
m_texture.bottomCornerRadiusLocation = m_texture.shader->uniformLocation("bottomCornerRadius");
m_texture.antialiasingLocation = m_texture.shader->uniformLocation("antialiasing");
Expand Down Expand Up @@ -985,14 +984,13 @@ void BlurEffect::blur(BlurRenderData &renderInfo, const RenderTarget &renderTarg

QRectF screenGeometry;
if (m_currentScreen) {
screenGeometry = m_currentScreen->geometryF();
screenGeometry = scaledRect(m_currentScreen->geometryF(), viewport.scale());
}

m_texture.shader->setUniform(m_texture.mvpMatrixLocation, projectionMatrix);
m_texture.shader->setUniform(m_texture.textureSizeLocation, QVector2D(staticBlurTexture->size().width(), staticBlurTexture->size().height()));
m_texture.shader->setUniform(m_texture.texStartPosLocation, QVector2D(backgroundRect.x() - screenGeometry.x(), backgroundRect.y() - screenGeometry.y()));
m_texture.shader->setUniform(m_texture.blurSizeLocation, QVector2D(backgroundRect.width(), backgroundRect.height()));
m_texture.shader->setUniform(m_texture.scaleLocation, (float)viewport.scale());
m_texture.shader->setUniform(m_texture.texStartPosLocation, QVector2D(deviceBackgroundRect.x() - screenGeometry.x(), deviceBackgroundRect.y() - screenGeometry.y()));
m_texture.shader->setUniform(m_texture.blurSizeLocation, QVector2D(deviceBackgroundRect.width(), deviceBackgroundRect.height()));
m_texture.shader->setUniform(m_texture.topCornerRadiusLocation, topCornerRadius);
m_texture.shader->setUniform(m_texture.bottomCornerRadiusLocation, bottomCornerRadius);
m_texture.shader->setUniform(m_texture.antialiasingLocation, m_settings.roundedCorners.antialiasing);
Expand Down
1 change: 0 additions & 1 deletion src/blur.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ public Q_SLOTS:
int mvpMatrixLocation;
int textureSizeLocation;
int texStartPosLocation;
int scaleLocation;

int topCornerRadiusLocation;
int bottomCornerRadiusLocation;
Expand Down
3 changes: 1 addition & 2 deletions src/shaders/texture.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
uniform sampler2D texUnit;
uniform vec2 textureSize;
uniform vec2 texStartPos;
uniform float scale;

varying vec2 uv;

void main(void)
{
vec2 tex = (texStartPos.xy + vec2(uv.x, 1.0 - uv.y) * blurSize) / textureSize * scale;
vec2 tex = (texStartPos.xy + vec2(uv.x, 1.0 - uv.y) * blurSize) / textureSize;
gl_FragColor = roundedRectangle(uv * blurSize, texture2D(texUnit, tex).rgb);
}
3 changes: 1 addition & 2 deletions src/shaders/texture_core.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
uniform sampler2D texUnit;
uniform vec2 textureSize;
uniform vec2 texStartPos;
uniform float scale;

in vec2 uv;

out vec4 fragColor;

void main(void)
{
vec2 tex = (texStartPos.xy + vec2(uv.x, 1.0 - uv.y) * blurSize) / textureSize * scale;
vec2 tex = (texStartPos.xy + vec2(uv.x, 1.0 - uv.y) * blurSize) / textureSize;
fragColor = roundedRectangle(uv * blurSize, texture(texUnit, tex).rgb);
}

0 comments on commit f7bb683

Please sign in to comment.