Commit 82c51400 authored by Martin Flöser's avatar Martin Flöser
Browse files

Mirror bottom cube cap in shader.

parent 902a5e41
......@@ -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 );
......
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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment