Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Unmaintained
KDE Workspace
Commits
2c5b74b5
Commit
2c5b74b5
authored
Jan 09, 2011
by
Martin Flöser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cylinder and Sphere ported to new rendering stack
parent
81f5706f
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
209 additions
and
211 deletions
+209
-211
kwin/effects/cube/cube.cpp
kwin/effects/cube/cube.cpp
+146
-151
kwin/effects/cube/data/cylinder.frag
kwin/effects/cube/data/cylinder.frag
+11
-27
kwin/effects/cube/data/cylinder.vert
kwin/effects/cube/data/cylinder.vert
+23
-14
kwin/effects/cube/data/sphere.vert
kwin/effects/cube/data/sphere.vert
+29
-19
No files found.
kwin/effects/cube/cube.cpp
View file @
2c5b74b5
This diff is collapsed.
Click to expand it.
kwin/effects/cube/data/cylinder.frag
View file @
2c5b74b5
uniform
sampler2D
winTextur
e
;
uniform
sampler2D
sampl
e
;
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
;
}
kwin/effects/cube/data/cylinder.vert
View file @
2c5b74b5
...
...
@@ -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
v
ertex
=
vec4
(
gl_V
ertex
.
x
-
(
width
*
0
.
5
-
xCoord
),
gl_V
ertex
.
yzw
);
float
radian
=
radians
(
cubeAngle
*
0
.
5
);
float
radius
=
(
width
*
0
.
5
)
*
tan
(
radian
);
float
azimuthAngle
=
radians
(
v
ertex
.
x
/
(
width
*
0
.
5
)
*
(
90
.
0
-
cubeAngle
*
0
.
5
));
v
ertex
.
x
=
width
*
0
.
5
-
xCoord
+
radius
*
sin
(
azimuthAngle
);
v
ertex
.
z
=
gl_V
ertex
.
z
+
radius
*
cos
(
azimuthAngle
)
-
radius
;
vec3
diff
=
(
gl_V
ertex
.
xyz
-
v
ertex
.
xyz
)
*
timeLine
;
v
ertex
.
xyz
+=
diff
;
gl_Position
=
gl_ModelViewProjectionMatrix
*
vertex
;
gl_
FrontColor
=
gl_Color
;
varying
TexCoord
s
=
texCoord
;
vec4
transformedV
ertex
=
vec4
(
v
ertex
.
x
-
(
width
-
xCoord
),
v
ertex
.
yzw
);
float
radian
=
radians
(
cubeAngle
);
float
radius
=
(
width
)
*
tan
(
radian
);
float
azimuthAngle
=
radians
(
transformedV
ertex
.
x
/
(
width
)
*
(
90
.
0
-
cubeAngle
));
transformedV
ertex
.
x
=
width
-
xCoord
+
radius
*
sin
(
azimuthAngle
);
transformedV
ertex
.
z
=
v
ertex
.
z
+
radius
*
cos
(
azimuthAngle
)
-
radius
;
vec3
diff
=
(
v
ertex
.
xyz
-
transformedV
ertex
.
xyz
)
*
timeLine
;
transformedV
ertex
.
xyz
+=
diff
;
gl_
Position
=
transformedVertex
*
(
windowTransformation
*
screenTransformation
*
modelview
)
*
projection
;
}
kwin/effects/cube/data/sphere.vert
View file @
2c5b74b5
...
...
@@ -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
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment