diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp index 2e5fdf9eea..943a766143 100644 --- a/effects/cube/cube.cpp +++ b/effects/cube/cube.cpp @@ -901,6 +901,7 @@ void CubeEffect::paintCap(bool frontFirst, float zOffset) capShader = true; ShaderManager::instance()->pushShader(m_capShader); m_capShader->setUniform("u_opacity", cubeOpacity); + m_capShader->setUniform("u_mirror", 1); if (reflectionPainting) { m_capShader->setUniform("screenTransformation", m_reflectionMatrix*m_rotationMatrix); } else { @@ -970,6 +971,7 @@ void CubeEffect::paintCap(bool frontFirst, float zOffset) capMatrix.translate(0.0, -rect.height(), 0.0); if (capShader) { m_capShader->setUniform("windowTransformation", capMatrix); + m_capShader->setUniform("u_mirror", 0); } else { #ifndef KWIN_HAVE_OPENGLES glMatrixMode( GL_TEXTURE ); diff --git a/effects/cube/data/cube-cap.glsl b/effects/cube/data/cube-cap.glsl index a3d6959d00..f106ea46e8 100644 --- a/effects/cube/data/cube-cap.glsl +++ b/effects/cube/data/cube-cap.glsl @@ -1,14 +1,24 @@ uniform sampler2D sample; uniform vec4 u_capColor; uniform float u_opacity; +uniform int u_mirror; varying vec2 varyingTexCoords; +vec2 mirrorTex(vec2 coords) { + vec2 mirrored = coords; + if (u_mirror != 0) { + mirrored.t = mirrored.t * (-1.0) + 1.0; + } + return mirrored; +} + void main() { vec4 color = u_capColor; - vec4 tex = texture2D(sample, varyingTexCoords); - if (varyingTexCoords.s < 0.0 || varyingTexCoords.s > 1.0 || - varyingTexCoords.t < 0.0 || varyingTexCoords.t > 1.0) { + vec2 texCoord = mirrorTex(varyingTexCoords); + vec4 tex = texture2D(sample, texCoord); + if (texCoord.s < 0.0 || texCoord.s > 1.0 || + texCoord.t < 0.0 || texCoord.t > 1.0) { tex = u_capColor; } color.rgb = tex.rgb*tex.a + color.rgb*(1.0-tex.a);