Paste P499

Masterwork From Distant Lands
ActivePublic

Authored by davidedmundson on Dec 3 2019, 2:10 PM.
diff --git a/libkwineffects/kwinglutils.cpp b/libkwineffects/kwinglutils.cpp
index 5f7b13b63..b07e6b2b2 100644
--- a/libkwineffects/kwinglutils.cpp
+++ b/libkwineffects/kwinglutils.cpp
@@ -347,6 +347,7 @@ void GLShader::resolveLocations()
mFloatLocation[Saturation] = uniformLocation("saturation");
mColorLocation[Color] = uniformLocation("geometryColor");
+ mVec4Location[TextureClamp] = uniformLocation("textureClamp");
mLocationsResolved = true;
}
@@ -877,14 +878,19 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const
} else if (traits & ShaderTrait::UniformColor)
stream << "uniform vec4 geometryColor;\n";
+ stream << "uniform vec4 textureClamp;\n";
+
if (output != QByteArrayLiteral("gl_FragColor"))
stream << "\nout vec4 " << output << ";\n";
stream << "\nvoid main(void)\n{\n";
if (traits & ShaderTrait::MapTexture) {
- if (traits & (ShaderTrait::Modulate | ShaderTrait::AdjustSaturation)) {
- stream << " vec4 texel = " << textureLookup << "(sampler, texcoord0);\n";
+ stream << "vec2 texcoordC = texcoord0;\n";
+ stream << "texcoordC.x = clamp(texcoordC.x, textureClamp.x, textureClamp.z);\n";
+ stream << "texcoordC.y = clamp(texcoordC.y, textureClamp.y, textureClamp.w);\n";
+ if (traits & (ShaderTrait::Modulate | ShaderTrait::AdjustSaturation)) {
+ stream << " vec4 texel = " << textureLookup << "(sampler, texcoordC);\n";
if (traits & ShaderTrait::Modulate)
stream << " texel *= modulation;\n";
if (traits & ShaderTrait::AdjustSaturation)
diff --git a/libkwineffects/kwinglutils.h b/libkwineffects/kwinglutils.h
index d0adbdd16..25ce93307 100644
--- a/libkwineffects/kwinglutils.h
+++ b/libkwineffects/kwinglutils.h
@@ -129,6 +129,7 @@ public:
enum Vec4Uniform {
ModulationConstant,
+ TextureClamp,
Vec4UniformCount
};
diff --git a/plugins/scenes/opengl/scene_opengl.cpp b/plugins/scenes/opengl/scene_opengl.cpp
index 9f54c407b..7488e203d 100644
--- a/plugins/scenes/opengl/scene_opengl.cpp
+++ b/plugins/scenes/opengl/scene_opengl.cpp
@@ -1505,6 +1505,18 @@ void SceneOpenGL2Window::performPaint(int mask, QRegion region, WindowPaintData
nodes[i].texture->setWrapMode(GL_CLAMP_TO_EDGE);
nodes[i].texture->bind();
+ if (i == ContentLeaf) {
+ QRectF bufferRect = clientShape().boundingRect();
+ bufferRect.adjust(0.5, 0.5, -0.5, -0.5); //force half texel correction at edges.
+ float u1Clamp = bufferRect.left() / geometry().width();
+ float v1Clamp = bufferRect.top() / geometry().height();
+ float u2Clamp = bufferRect.right() / geometry().width();
+ float v2Clamp = bufferRect.bottom() / geometry().height();
+ shader->setUniform(GLShader::TextureClamp, QVector4D({u1Clamp, v1Clamp, u2Clamp, v2Clamp}));
+ } else {
+ shader->setUniform(GLShader::TextureClamp, QVector4D({0, 0, 1, 1}));
+ }
+
vbo->draw(region, primitiveType, nodes[i].firstVertex, nodes[i].vertexCount, m_hardwareClipping);
}
davidedmundson edited the content of this paste. (Show Details)Dec 3 2019, 2:10 PM
davidedmundson changed the title of this paste from untitled to Masterwork From Distant Lands.
davidedmundson edited the content of this paste. (Show Details)Dec 3 2019, 2:38 PM
davidedmundson edited the content of this paste. (Show Details)Dec 3 2019, 3:02 PM