Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static-blur: remove unnecessary scale uniform from the shader #170

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
Loading