1/**************************************************************************** 2** 3** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies). 4** Contact: http://www.qt.io/licensing/ 5** 6** This file is part of the Qt Mobility Components. 7** 8** $QT_BEGIN_LICENSE:LGPL21$ 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 The Qt Company. For licensing terms 14** and conditions see http://www.qt.io/terms-conditions. For further 15** information use the contact form at http://www.qt.io/contact-us. 16** 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 or version 3 as published by the Free 20** Software Foundation and appearing in the file LICENSE.LGPLv21 and 21** LICENSE.LGPLv3 included in the packaging of this file. Please review the 22** following information to ensure the GNU Lesser General Public License 23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and 24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 25** 26** As a special exception, The Qt Company gives you certain additional 27** rights. These rights are described in The Qt Company LGPL Exception 28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 29** 30** $QT_END_LICENSE$ 31** 32****************************************************************************/ 33 34// Based on "Graphics Shaders: Theory and Practice" (http://cgeducation.org/ShadersBook/) 35 36uniform float dividerValue; 37uniform float mixLevel; 38uniform float resS; 39uniform float resT; 40 41uniform sampler2D source; 42uniform lowp float qt_Opacity; 43varying vec2 qt_TexCoord0; 44 45void main() 46{ 47 vec2 uv = qt_TexCoord0.xy; 48 vec4 c = vec4(0.0); 49 if (uv.x < dividerValue) { 50 vec2 st = qt_TexCoord0.st; 51 vec3 irgb = texture2D(source, st).rgb; 52 vec2 stp0 = vec2(1.0 / resS, 0.0); 53 vec2 st0p = vec2(0.0 , 1.0 / resT); 54 vec2 stpp = vec2(1.0 / resS, 1.0 / resT); 55 vec2 stpm = vec2(1.0 / resS, -1.0 / resT); 56 const vec3 W = vec3(0.2125, 0.7154, 0.0721); 57 float i00 = dot(texture2D(source, st).rgb, W); 58 float im1m1 = dot(texture2D(source, st-stpp).rgb, W); 59 float ip1p1 = dot(texture2D(source, st+stpp).rgb, W); 60 float im1p1 = dot(texture2D(source, st-stpm).rgb, W); 61 float ip1m1 = dot(texture2D(source, st+stpm).rgb, W); 62 float im10 = dot(texture2D(source, st-stp0).rgb, W); 63 float ip10 = dot(texture2D(source, st+stp0).rgb, W); 64 float i0m1 = dot(texture2D(source, st-st0p).rgb, W); 65 float i0p1 = dot(texture2D(source, st+st0p).rgb, W); 66 float h = -1.0*im1p1 - 2.0*i0p1 - 1.0*ip1p1 + 1.0*im1m1 + 2.0*i0m1 + 1.0*ip1m1; 67 float v = -1.0*im1m1 - 2.0*im10 - 1.0*im1p1 + 1.0*ip1m1 + 2.0*ip10 + 1.0*ip1p1; 68 float mag = 1.0 - length(vec2(h, v)); 69 vec3 target = vec3(mag, mag, mag); 70 c = vec4(target, 1.0); 71 } else { 72 c = texture2D(source, qt_TexCoord0); 73 } 74 gl_FragColor = qt_Opacity * c; 75} 76