Skip to content

Commit

Permalink
blur: fix noise texture position
Browse files Browse the repository at this point in the history
  • Loading branch information
taj-ny committed Jun 29, 2024
1 parent 741d345 commit ec8fcb9
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ BlurEffect::BlurEffect()
m_upsamplePass.noiseLocation = m_upsamplePass.shader->uniformLocation("noise");
m_upsamplePass.noiseTextureLocation = m_upsamplePass.shader->uniformLocation("noiseTexture");
m_upsamplePass.noiseTextureSizeLocation = m_upsamplePass.shader->uniformLocation("noiseTextureSize");
m_upsamplePass.noiseTextureStartPositionLocation = m_upsamplePass.shader->uniformLocation("noiseTextureStartPosition");
m_upsamplePass.topCornerRadiusLocation = m_upsamplePass.shader->uniformLocation("topCornerRadius");
m_upsamplePass.bottomCornerRadiusLocation = m_upsamplePass.shader->uniformLocation("bottomCornerRadius");
m_upsamplePass.antialiasingLocation = m_upsamplePass.shader->uniformLocation("antialiasing");
Expand Down Expand Up @@ -1022,7 +1021,6 @@ void BlurEffect::blur(BlurRenderData &renderInfo, const RenderTarget &renderTarg
if (GLTexture *noiseTexture = ensureNoiseTexture()) {
m_upsamplePass.shader->setUniform(m_upsamplePass.noiseLocation, true);
m_upsamplePass.shader->setUniform(m_upsamplePass.noiseTextureSizeLocation, QVector2D(noiseTexture->width(), noiseTexture->height()));
m_upsamplePass.shader->setUniform(m_upsamplePass.noiseTextureStartPositionLocation, QVector2D(deviceBackgroundRect.topLeft()));
glUniform1i(m_upsamplePass.noiseTextureLocation, 1);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, noiseTexture->texture());
Expand Down
1 change: 0 additions & 1 deletion src/blur.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public Q_SLOTS:
int noiseLocation;
int noiseTextureLocation;
int noiseTextureSizeLocation;
int noiseTextureStartPositionLocation;

int topCornerRadiusLocation;
int bottomCornerRadiusLocation;
Expand Down
3 changes: 1 addition & 2 deletions src/shaders/upsample.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ uniform vec2 halfpixel;
uniform bool noise;
uniform sampler2D noiseTexture;
uniform vec2 noiseTextureSize;
uniform vec2 noiseTextureStartPosition;

varying vec2 uv;

Expand All @@ -24,7 +23,7 @@ void main(void)
sum /= 12.0;

if (noise) {
sum += vec4(texture2D(noiseTexture, (noiseTextureStartPosition.xy + gl_FragCoord.xy) / noiseTextureSize).rrr, 0.0);
sum += vec4(texture2D(noiseTexture, vec2(uv.x, 1.0 - uv.y) * blurSize / noiseTextureSize).rrr, 0.0);
}

gl_FragColor = roundedRectangle(uv * blurSize, sum.rgb);
Expand Down
3 changes: 1 addition & 2 deletions src/shaders/upsample_core.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ uniform vec2 halfpixel;
uniform bool noise;
uniform sampler2D noiseTexture;
uniform vec2 noiseTextureSize;
uniform vec2 noiseTextureStartPosition;

in vec2 uv;

Expand All @@ -28,7 +27,7 @@ void main(void)
sum /= 12.0;

if (noise) {
sum += vec4(texture2D(noiseTexture, (noiseTextureStartPosition.xy + gl_FragCoord.xy) / noiseTextureSize).rrr, 0.0);
sum += vec4(texture2D(noiseTexture, vec2(uv.x, 1.0 - uv.y) * blurSize / noiseTextureSize).rrr, 0.0);
}

fragColor = roundedRectangle(uv * blurSize, sum.rgb);
Expand Down

0 comments on commit ec8fcb9

Please sign in to comment.