Warning, /plasma/libplasma/examples/applets/testshaders/contents/ui/WaterEffect.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 0008 0009 import org.kde.plasma.components as PlasmaComponents 0010 0011 // VertexPage 0012 0013 Item { 0014 id: waterRoot 0015 property alias sourceItem: effectsource.sourceItem 0016 property bool waving: true 0017 //anchors.top: parent.bottom 0018 anchors.top: iconCol.bottom 0019 width: sourceItem.width 0020 height: sourceItem.height 0021 0022 ShaderEffect { 0023 anchors.fill: parent 0024 property ShaderEffectSource source: effectsource 0025 property real f: 0 0026 property real f2: 0 0027 property real intensity: 1 0028 smooth: true 0029 0030 ShaderEffectSource { 0031 id: effectsource 0032 //hideSource: false 0033 //smooth: true 0034 sourceItem: mainItem 0035 } 0036 0037 fragmentShader: 0038 " 0039 varying highp vec2 qt_TexCoord0; 0040 uniform sampler2D source; 0041 uniform lowp float qt_Opacity; 0042 uniform highp float f; 0043 uniform highp float f2; 0044 uniform highp float intensity; 0045 0046 void main() { 0047 const highp float twopi = 3.141592653589 * 2.0; 0048 0049 highp float distanceFactorToPhase = pow(qt_TexCoord0.y + 0.5, 8.0) * 5.0; 0050 highp float ofx = sin(f * twopi + distanceFactorToPhase) / 100.0; 0051 highp float ofy = sin(f2 * twopi + distanceFactorToPhase * qt_TexCoord0.x) / 60.0; 0052 0053 highp float intensityDampingFactor = (qt_TexCoord0.x + 2.0) * (qt_TexCoord0.y + 0.2); 0054 highp float distanceFactor = (1.0 - qt_TexCoord0.y) * 4.0 * intensity * intensityDampingFactor; 0055 0056 ofx *= distanceFactor; 0057 ofy *= distanceFactor; 0058 0059 highp float x = qt_TexCoord0.x + ofx; 0060 highp float y = 1.0 - qt_TexCoord0.y + ofy; 0061 0062 highp float fake = (sin((ofy + ofx) * twopi) + 0.5) * 0.05 * (1.2 - qt_TexCoord0.y) * intensity * intensityDampingFactor; 0063 0064 highp vec4 pix = 0065 texture2D(source, vec2(x, y)) * 0.6 + 0066 texture2D(source, vec2(x-fake, y)) * 2.05 + 0067 texture2D(source, vec2(x, y-fake)) * 2.05 + 0068 texture2D(source, vec2(x+fake, y)) * 2.05 + 0069 texture2D(source, vec2(x, y+fake)) * 2.05; 0070 0071 highp float darken = 0.6 - (ofx - ofy) / 2.0; 0072 pix.b *= 1.2 * darken; 0073 pix.r *= 0.9 * darken; 0074 pix.g *= darken; 0075 0076 gl_FragColor = qt_Opacity * vec4(pix.r, pix.g, pix.b, 1.0); 0077 } 0078 " 0079 0080 NumberAnimation on f { 0081 running: waterRoot.waving 0082 loops: Animation.Infinite 0083 from: 0 0084 to: 1 0085 duration: 2410 0086 } 0087 NumberAnimation on f2 { 0088 running: waterRoot.waving 0089 loops: Animation.Infinite 0090 from: 0 0091 to: 1 0092 duration: 1754 0093 } 0094 } 0095 }