1
/****************************************************************************
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the Qt Mobility Components.
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
42
// Based on "Graphics Shaders: Theory and Practice" (http://cgeducation.org/ShadersBook/)
44
uniform float dividerValue;
45
uniform float mixLevel;
49
uniform sampler2D source;
50
uniform lowp float qt_Opacity;
51
varying vec2 qt_TexCoord0;
55
vec2 uv = qt_TexCoord0.xy;
57
if (uv.x < dividerValue) {
58
vec2 st = qt_TexCoord0.st;
59
vec3 irgb = texture2D(source, st).rgb;
60
vec2 stp0 = vec2(1.0 / resS, 0.0);
61
vec2 st0p = vec2(0.0 , 1.0 / resT);
62
vec2 stpp = vec2(1.0 / resS, 1.0 / resT);
63
vec2 stpm = vec2(1.0 / resS, -1.0 / resT);
64
const vec3 W = vec3(0.2125, 0.7154, 0.0721);
65
float i00 = dot(texture2D(source, st).rgb, W);
66
float im1m1 = dot(texture2D(source, st-stpp).rgb, W);
67
float ip1p1 = dot(texture2D(source, st+stpp).rgb, W);
68
float im1p1 = dot(texture2D(source, st-stpm).rgb, W);
69
float ip1m1 = dot(texture2D(source, st+stpm).rgb, W);
70
float im10 = dot(texture2D(source, st-stp0).rgb, W);
71
float ip10 = dot(texture2D(source, st+stp0).rgb, W);
72
float i0m1 = dot(texture2D(source, st-st0p).rgb, W);
73
float i0p1 = dot(texture2D(source, st+st0p).rgb, W);
74
float h = -1.0*im1p1 - 2.0*i0p1 - 1.0*ip1p1 + 1.0*im1m1 + 2.0*i0m1 + 1.0*ip1m1;
75
float v = -1.0*im1m1 - 2.0*im10 - 1.0*im1p1 + 1.0*ip1m1 + 2.0*ip10 + 1.0*ip1p1;
76
float mag = 1.0 - length(vec2(h, v));
77
vec3 target = vec3(mag, mag, mag);
78
c = vec4(target, 1.0);
80
c = texture2D(source, qt_TexCoord0);
82
gl_FragColor = qt_Opacity * c;