Commit 2c5b74b5 authored by Martin Flöser's avatar Martin Flöser

Cylinder and Sphere ported to new rendering stack

parent 81f5706f
This diff is collapsed.
uniform sampler2D winTexture;
uniform sampler2D sample;
uniform float textureWidth;
uniform float textureHeight;
uniform float opacity;
uniform float brightness;
uniform float saturation;
uniform float front;
uniform float useTexture;
varying vec2 varyingTexCoords;
vec2 pix2tex(vec2 pix)
{
......@@ -14,30 +14,14 @@ vec2 pix2tex(vec2 pix)
void main()
{
if( front > 0.0 && gl_FrontFacing )
discard;
if( front < 0.0 && !gl_FrontFacing )
discard;
if( useTexture > 0.0 )
{
// remove the shadow decoration quads
if( gl_TexCoord[0].x < 0.0 || gl_TexCoord[0].x > textureWidth ||
gl_TexCoord[0].y < 0.0 || gl_TexCoord[0].y > textureHeight )
discard;
vec4 tex = texture2D(winTexture, pix2tex(gl_TexCoord[0].xy));
if( saturation != 1.0 )
{
vec3 desaturated = tex.rgb * vec3( 0.30, 0.59, 0.11 );
desaturated = vec3( dot( desaturated, tex.rgb ));
tex.rgb = tex.rgb * vec3( saturation ) + desaturated * vec3( 1.0 - saturation );
}
tex.rgb = tex.rgb * opacity * brightness;
tex.a = tex.a * opacity;
gl_FragColor = tex;
}
else
vec4 tex = texture2D(sample, pix2tex(varyingTexCoords));
if( saturation != 1.0 )
{
gl_FragColor = gl_Color;
vec3 desaturated = tex.rgb * vec3( 0.30, 0.59, 0.11 );
desaturated = vec3( dot( desaturated, tex.rgb ));
tex.rgb = tex.rgb * vec3( saturation ) + desaturated * vec3( 1.0 - saturation );
}
// tex.rgb = tex.rgb * opacity * brightness;
// tex.a = tex.a * opacity;
gl_FragColor = tex;
}
......@@ -2,7 +2,7 @@
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.com>
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
......@@ -17,24 +17,33 @@ 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;
attribute vec4 vertex;
attribute vec2 texCoord;
varying vec2 varyingTexCoords;
void main()
{
gl_TexCoord[0].xy = gl_Vertex.xy;
vec4 vertex = vec4(gl_Vertex.x - ( width*0.5 - xCoord ), gl_Vertex.yzw);
float radian = radians(cubeAngle*0.5);
float radius = (width*0.5)*tan(radian);
float azimuthAngle = radians(vertex.x/(width*0.5)*(90.0 - cubeAngle*0.5));
vertex.x = width*0.5 - xCoord + radius * sin( azimuthAngle );
vertex.z = gl_Vertex.z + radius * cos( azimuthAngle ) - radius;
vec3 diff = (gl_Vertex.xyz - vertex.xyz)*timeLine;
vertex.xyz += diff;
gl_Position = gl_ModelViewProjectionMatrix * vertex;
gl_FrontColor = gl_Color;
varyingTexCoords = texCoord;
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 = transformedVertex*(windowTransformation*screenTransformation*modelview)*projection;
}
......@@ -2,7 +2,7 @@
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.com>
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
......@@ -17,29 +17,39 @@ 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 height;
uniform float cubeAngle;
uniform float xCoord;
uniform float yCoord;
uniform vec2 u_offset;
uniform float timeLine;
attribute vec4 vertex;
attribute vec2 texCoord;
varying vec2 varyingTexCoords;
void main()
{
gl_TexCoord[0].xy = gl_Vertex.xy;
vec3 vertex = vec3( gl_Vertex.xy - vec2( width*0.5 - xCoord, height*0.5 - yCoord ), gl_Vertex.z );
float radian = radians(cubeAngle*0.5);
float radius = (width*0.5)/cos(radian);
float zenithAngle = acos( vertex.y/radius );
float azimuthAngle = asin( vertex.x/radius );
vertex.z = radius * sin( zenithAngle ) * cos( azimuthAngle ) - radius*cos( radians( 90.0 - cubeAngle*0.5 ) );
vertex.x = radius * sin( zenithAngle ) * sin( azimuthAngle );
vertex.xy += vec2( width*0.5 - xCoord, height*0.5 - yCoord );
vec3 diff = (gl_Vertex.xyz - vertex.xyz)*timeLine;
vertex.xyz += diff;
gl_Position = gl_ModelViewProjectionMatrix * vec4( vertex, 1.0 );
gl_FrontColor = gl_Color;
varyingTexCoords = texCoord;
vec4 transformedVertex = vertex;
transformedVertex.x = transformedVertex.x - width;
transformedVertex.y = transformedVertex.y - height;
transformedVertex.xy = transformedVertex.xy + u_offset;
float radian = radians(cubeAngle);
float radius = (width)/cos(radian);
float zenithAngle = acos(transformedVertex.y/radius);
float azimuthAngle = asin(transformedVertex.x/radius);
transformedVertex.z = radius * sin( zenithAngle ) * cos( azimuthAngle ) - radius*cos( radians( 90.0 - cubeAngle ) );
transformedVertex.x = radius * sin( zenithAngle ) * sin( azimuthAngle );
transformedVertex.xy += vec2( width - u_offset.x, height - u_offset.y );
vec3 diff = (vertex.xyz - transformedVertex.xyz)*timeLine;
transformedVertex.xyz += diff;
gl_Position = transformedVertex*(windowTransformation*screenTransformation*modelview)*projection;
}
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