summaryrefslogtreecommitdiff
path: root/tests/shaders/glsl-gnome-shell-dim-window.shader_test
blob: ff1479ccee40ac853e9549dafa0a24b64bd34465 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
[require]
GLSL >= 1.10

[vertex shader]
varying vec4 texcoords;

void main()
{
	gl_Position = gl_Vertex;
	texcoords = (gl_Vertex + 1.0) / 2.0;
}

[fragment shader]
/* This shader came from gnome-shell, which is GPLv2+.  This copyright
 * notice was constructed from the git logs of that file plus the
 * top-level COPYING file, as it did not explicitly include the
 * notice.
 */
/*
    Copyright (C) 2010 Maxim Ermilov <zaspire@rambler.ru>

    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
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    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, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#version 110
uniform sampler2D sampler0;
uniform float fraction;
uniform float height;
const float c = -0.5;
const float border_max_height = 60.0;
varying vec4 texcoords;

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()
{
    vec4 color = texture2D(sampler0, texcoords.xy);
    float y = height * texcoords.y;

    // To reduce contrast, blend with a mid gray
    gl_FragColor = color * contrast - off * c;

    // We only fully dim at a distance of BORDER_MAX_HEIGHT from the edge and
    // when the fraction is 1.0. For other locations and fractions we linearly
    // interpolate back to the original undimmed color.
    gl_FragColor = color + (gl_FragColor - color) * min(y / border_max_height, 1.0);
    gl_FragColor = color + (gl_FragColor - color) * fraction;
}

[test]
uniform int sampler0 0
uniform float fraction 1.0
uniform float height 60.0
texture rgbw 0 (8, 8)
draw rect -1 -1 2 2
relative probe rgb (0.0, 0.0) (1.0, 0.0, 0.0)
relative probe rgb (1.0, 0.0) (0.0, 1.0, 0.0)
relative probe rgb (0.0, 0.499) (0.90825, 0.15835, 0.15835)
relative probe rgb (1.0, 0.499) (0.15835, 0.90825, 0.15835)
relative probe rgb (0.0, 1.0) (0.3165, 0.3165, 0.8165)
relative probe rgb (1.0, 1.0) (0.8165, 0.8165, 0.8165)