213833fc7f
This fixes the artefacts appearing when only part of the screen is updated. This version also brings ton of optimizations which might well increase performance 2 or 3 times on slower cards: - Windows are not drawn twice anymore. Now they're drawn only to render target and later changed parts of the render target are copied back onto screen. - Shaders have been optimized. Some calculations moved from pixel shader to vertex shader. - For ARGB windows, if window's opacity is 0 then it will stay transparent instead of being replaced by blurred background. - Blur effect should now play nicer with other effects, e.g. shadows. svn path=/trunk/KDE/kdebase/workspace/; revision=748502
40 lines
1.1 KiB
GLSL
40 lines
1.1 KiB
GLSL
uniform sampler2D windowTex;
|
|
uniform sampler2D backgroundTex;
|
|
uniform float textureWidth;
|
|
uniform float textureHeight;
|
|
uniform float opacity;
|
|
uniform float saturation;
|
|
uniform float brightness;
|
|
|
|
|
|
// Converts pixel coordinates to texture coordinates
|
|
vec2 pix2tex(vec2 pix)
|
|
{
|
|
return vec2(pix.x / textureWidth, pix.y / textureHeight);
|
|
}
|
|
|
|
// Returns color of the window at given texture coordinate, taking into
|
|
// account brightness and saturation, but not opacity
|
|
vec4 windowColor(vec2 texcoord)
|
|
{
|
|
vec4 color = texture2D(windowTex, texcoord);
|
|
// Apply saturation
|
|
float grayscale = dot(vec3(0.30, 0.59, 0.11), color.rgb);
|
|
color.rgb = mix(vec3(grayscale), color.rgb, saturation);
|
|
// Apply brightness
|
|
color.rgb = color.rgb * brightness;
|
|
// and return
|
|
return color;
|
|
}
|
|
|
|
void main()
|
|
{
|
|
vec2 blurtexcoord = pix2tex(gl_FragCoord.xy);
|
|
|
|
vec4 winColor = windowColor(gl_TexCoord[0].xy);
|
|
vec3 tex = mix(texture2D(backgroundTex, blurtexcoord).rgb,
|
|
winColor.rgb, winColor.a * opacity);
|
|
|
|
gl_FragColor = vec4(tex, pow(winColor.a, 0.2));
|
|
}
|
|
|