kwin/effects/lookingglass/data/lookingglass.frag
Martin Gräßlin 863726a085 LookingGlass ported to GLES.
LookingGlass does not inherit ShaderEffect any more and uses just a
fragment shader. It still renders to a FBO, this could probably be
improved.
2011-01-30 14:12:05 +01:00

25 lines
580 B
GLSL

uniform sampler2D sample;
uniform vec2 u_cursor;
uniform float u_zoom;
uniform float u_radius;
uniform vec2 u_textureSize;
varying vec2 varyingTexCoords;
#define PI 3.14159
void main()
{
vec2 d = u_cursor - varyingTexCoords;
float dist = sqrt(d.x*d.x + d.y*d.y);
vec2 texcoord = varyingTexCoords;
if (dist < u_radius) {
float disp = sin(dist / u_radius * PI) * (u_zoom - 1.0) * 20.0;
texcoord += d / dist * disp;
}
texcoord = texcoord/u_textureSize;
texcoord.t = 1.0 - texcoord.t;
gl_FragColor = texture2D(sample, texcoord);
}