2010-09-11 19:41:47 +00:00
|
|
|
#version 110
|
2011-09-17 07:06:00 +00:00
|
|
|
uniform sampler2D tex;
|
2010-09-11 01:30:50 +00:00
|
|
|
uniform float fraction;
|
|
|
|
uniform float height;
|
|
|
|
const float c = -0.2;
|
|
|
|
const float border_max_height = 60.0;
|
|
|
|
|
|
|
|
mat4 contrast = mat4 (1.0 + c, 0.0, 0.0, 0.0,
|
|
|
|
0.0, 1.0 + c, 0.0, 0.0,
|
|
|
|
0.0, 0.0, 1.0 + c, 0.0,
|
|
|
|
0.0, 0.0, 0.0, 1.0);
|
|
|
|
vec4 off = vec4(0.633, 0.633, 0.633, 0);
|
|
|
|
void main()
|
|
|
|
{
|
2011-09-17 07:06:00 +00:00
|
|
|
vec4 color = texture2D(tex, cogl_tex_coord_in[0].xy);
|
|
|
|
float y = height * cogl_tex_coord_in[0].y;
|
2010-09-11 01:30:50 +00:00
|
|
|
|
|
|
|
// To reduce contrast, blend with a mid gray
|
2011-09-20 18:21:45 +00:00
|
|
|
cogl_color_out = color * contrast - off * c * color.a;
|
2010-09-11 01:30:50 +00:00
|
|
|
|
2011-09-20 18:21:45 +00:00
|
|
|
// We only fully dim at a distance of BORDER_MAX_HEIGHT from the top and
|
2010-09-11 01:30:50 +00:00
|
|
|
// when the fraction is 1.0. For other locations and fractions we linearly
|
2011-09-17 19:56:59 +00:00
|
|
|
// interpolate back to the original undimmed color, so the top of the window
|
|
|
|
// is at full color.
|
2011-09-20 18:21:45 +00:00
|
|
|
cogl_color_out = color + (cogl_color_out - color) * max(min(y / border_max_height, 1.0), 0.0);
|
2011-09-17 07:06:00 +00:00
|
|
|
cogl_color_out = color + (cogl_color_out - color) * fraction;
|
2010-09-11 01:30:50 +00:00
|
|
|
}
|