kwin/effects/cube/data/cylinder.vert
Martin Gräßlin a728823fbe Fix passing matrixes to the shaders
QMatrix4x4 accepts data in row-major order, but returns them in
column-major order, which is not documented and because of that
I expected them to be in row-major order.
This commit fixes it and rewrites the shaders to apply the matrix
multiplications in the right order.
REVIEW: 100759
2011-03-06 09:13:31 +01:00

51 lines
1.9 KiB
GLSL

/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2008, 2011 Martin Gräßlin <kde@martin-graesslin.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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 <http://www.gnu.org/licenses/>.
*********************************************************************/
uniform mat4 projection;
uniform mat4 modelview;
uniform mat4 screenTransformation;
uniform mat4 windowTransformation;
uniform float width;
uniform float cubeAngle;
uniform float xCoord;
uniform float timeLine;
uniform float textureWidth;
uniform float textureHeight;
attribute vec4 vertex;
attribute vec2 texCoord;
varying vec2 varyingTexCoords;
void main()
{
varyingTexCoords = texCoord / vec2(textureWidth, textureHeight);
vec4 transformedVertex = vec4(vertex.x - ( width - xCoord ), vertex.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;
vec3 diff = (vertex.xyz - transformedVertex.xyz)*timeLine;
transformedVertex.xyz += diff;
gl_Position = projection*(modelview*screenTransformation*windowTransformation)*transformedVertex;
}