diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp
index d36b0980a2..40f6767f54 100644
--- a/effects/cube/cube.cpp
+++ b/effects/cube/cube.cpp
@@ -298,7 +298,6 @@ void CubeEffect::slotWallPaperLoaded()
void CubeEffect::slotResetShaders()
{
- ShaderManager::instance()->resetShader(cylinderShader, ShaderManager::GenericShader);
ShaderManager::instance()->resetShader(sphereShader, ShaderManager::GenericShader);
}
@@ -315,33 +314,19 @@ bool CubeEffect::loadShader()
return false;
}
- cylinderShader = ShaderManager::instance()->loadVertexShader(ShaderManager::GenericShader, cylinderVertexshader);
+ QFile cvf(cylinderVertexshader);
+ if (!cvf.open(QIODevice::ReadOnly)) {
+ qCCritical(KWINEFFECTS) << "The cylinder shader couldn't be opened!";
+ return false;
+ }
+
+ cylinderShader = ShaderManager::instance()->generateCustomShader(ShaderTrait::MapTexture | ShaderTrait::AdjustSaturation | ShaderTrait::Modulate, cvf.readAll(), QByteArray());
if (!cylinderShader->isValid()) {
qCCritical(KWINEFFECTS) << "The cylinder shader failed to load!";
return false;
} else {
ShaderBinder binder(cylinderShader);
cylinderShader->setUniform("sampler", 0);
- QMatrix4x4 projection;
- float fovy = 60.0f;
- float aspect = 1.0f;
- float zNear = 0.1f;
- float zFar = 100.0f;
- float ymax = zNear * tan(fovy * M_PI / 360.0f);
- float ymin = -ymax;
- float xmin = ymin * aspect;
- float xmax = ymax * aspect;
- projection.frustum(xmin, xmax, ymin, ymax, zNear, zFar);
- cylinderShader->setUniform(GLShader::ProjectionMatrix, projection);
- QMatrix4x4 modelview;
- float scaleFactor = 1.1 * tan(fovy * M_PI / 360.0f) / ymax;
- modelview.translate(xmin * scaleFactor, ymax * scaleFactor, -1.1);
- const QSize screenSize = effects->virtualScreenSize();
- modelview.scale((xmax - xmin)*scaleFactor / screenSize.width(), -(ymax - ymin)*scaleFactor / screenSize.height(), 0.001);
- cylinderShader->setUniform(GLShader::ModelViewMatrix, modelview);
- const QMatrix4x4 identity;
- cylinderShader->setUniform(GLShader::ScreenTransformation, identity);
- cylinderShader->setUniform(GLShader::WindowTransformation, identity);
QRect rect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop());
cylinderShader->setUniform("width", (float)rect.width() * 0.5f);
}
diff --git a/effects/cube/data/1.10/cylinder.vert b/effects/cube/data/1.10/cylinder.vert
index 3c4ed0ada3..549108da30 100644
--- a/effects/cube/data/1.10/cylinder.vert
+++ b/effects/cube/data/1.10/cylinder.vert
@@ -17,33 +17,30 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*********************************************************************/
-uniform mat4 projection;
-uniform mat4 modelview;
-uniform mat4 screenTransformation;
-uniform mat4 windowTransformation;
+uniform mat4 modelViewProjectionMatrix;
uniform float width;
uniform float cubeAngle;
uniform float xCoord;
uniform float timeLine;
-attribute vec4 vertex;
-attribute vec2 texCoord;
+attribute vec4 position;
+attribute vec4 texcoord;
-varying vec2 varyingTexCoords;
+varying vec2 texcoord0;
void main()
{
- varyingTexCoords = texCoord;
- vec4 transformedVertex = vec4(vertex.x - ( width - xCoord ), vertex.yzw);
+ texcoord0 = texcoord.st;
+ vec4 transformedVertex = vec4(position.x - ( width - xCoord ), position.yzw);
float radian = radians(cubeAngle);
float radius = (width)*tan(radian);
float azimuthAngle = radians(transformedVertex.x/(width)*(90.0 - cubeAngle));
transformedVertex.x = width - xCoord + radius * sin( azimuthAngle );
- transformedVertex.z = vertex.z + radius * cos( azimuthAngle ) - radius;
+ transformedVertex.z = position.z + radius * cos( azimuthAngle ) - radius;
- vec3 diff = (vertex.xyz - transformedVertex.xyz)*timeLine;
+ vec3 diff = (position.xyz - transformedVertex.xyz)*timeLine;
transformedVertex.xyz += diff;
- gl_Position = projection*(modelview*screenTransformation*windowTransformation)*transformedVertex;
+ gl_Position = modelViewProjectionMatrix*transformedVertex;
}
diff --git a/effects/cube/data/1.40/cylinder.vert b/effects/cube/data/1.40/cylinder.vert
index 123739201f..a286126828 100644
--- a/effects/cube/data/1.40/cylinder.vert
+++ b/effects/cube/data/1.40/cylinder.vert
@@ -18,33 +18,30 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*********************************************************************/
#version 140
-uniform mat4 projection;
-uniform mat4 modelview;
-uniform mat4 screenTransformation;
-uniform mat4 windowTransformation;
+uniform mat4 modelViewProjectionMatrix;
uniform float width;
uniform float cubeAngle;
uniform float xCoord;
uniform float timeLine;
-in vec4 vertex;
-in vec2 texCoord;
+in vec4 position;
+in vec4 texcoord;
-out vec2 varyingTexCoords;
+out vec2 texcoord0;
void main()
{
- varyingTexCoords = texCoord;
- vec4 transformedVertex = vec4(vertex.x - ( width - xCoord ), vertex.yzw);
+ texcoord0 = texcoord.st;
+ vec4 transformedVertex = vec4(position.x - ( width - xCoord ), position.yzw);
float radian = radians(cubeAngle);
float radius = (width)*tan(radian);
float azimuthAngle = radians(transformedVertex.x/(width)*(90.0 - cubeAngle));
transformedVertex.x = width - xCoord + radius * sin( azimuthAngle );
- transformedVertex.z = vertex.z + radius * cos( azimuthAngle ) - radius;
+ transformedVertex.z = position.z + radius * cos( azimuthAngle ) - radius;
- vec3 diff = (vertex.xyz - transformedVertex.xyz)*timeLine;
+ vec3 diff = (position.xyz - transformedVertex.xyz)*timeLine;
transformedVertex.xyz += diff;
- gl_Position = projection*(modelview*screenTransformation*windowTransformation)*transformedVertex;
+ gl_Position = modelViewProjectionMatrix*transformedVertex;
}