Mirror bottom cube cap in shader.
This commit is contained in:
parent
75a1ee7aa8
commit
ef7fd87d65
2 changed files with 15 additions and 3 deletions
|
@ -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 );
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue