summaryrefslogtreecommitdiffstats
path: root/examples/declarative/shadereffects
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/shadereffects')
-rw-r--r--examples/declarative/shadereffects/main.cpp77
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/Curtain.qml106
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/CurtainEffect.qml97
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/DropShadow.qml117
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/DropShadowEffect.qml174
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/Grayscale.qml77
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/GrayscaleEffect.qml62
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/ImageMask.qml143
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/ImageMaskEffect.qml60
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/RadialWave.qml85
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/RadialWaveEffect.qml81
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/Water.qml60
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/WaterEffect.qml126
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/Curtain.jpgbin0 -> 16112 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/DropShadow.jpgbin0 -> 12975 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/Grayscale.jpgbin0 -> 19048 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/ImageMask.jpgbin0 -> 18751 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/RadialWave.jpgbin0 -> 41406 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/Water.jpgbin0 -> 17751 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/back.pngbin0 -> 370 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/bg.jpgbin0 -> 10189 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/desaturate.jpgbin0 -> 203942 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/drop_shadow.pngbin0 -> 219220 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/fabric.jpgbin0 -> 163431 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/flower.pngbin0 -> 219220 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/image1.jpgbin0 -> 115770 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/image2.jpgbin0 -> 45837 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/qt-logo.pngbin0 -> 22746 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/shader_effects.jpgbin0 -> 4906 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/sky.jpgbin0 -> 36734 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/toolbar.pngbin0 -> 342 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/images/wave.jpgbin0 -> 176681 bytes
-rw-r--r--examples/declarative/shadereffects/qml/shadereffects/main.qml160
-rw-r--r--examples/declarative/shadereffects/shadereffects.pro46
-rw-r--r--examples/declarative/shadereffects/shadereffects.qmlproject16
35 files changed, 1487 insertions, 0 deletions
diff --git a/examples/declarative/shadereffects/main.cpp b/examples/declarative/shadereffects/main.cpp
new file mode 100644
index 00000000..4e70e821
--- /dev/null
+++ b/examples/declarative/shadereffects/main.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlapplicationviewer.h"
+#include <QtGui/QApplication>
+#include <QtOpenGL>
+#include <QDeclarativeView>
+#include <QDeclarativeEngine>
+
+int main(int argc, char *argv[])
+{
+// Depending on which is the recommended way for the platform, either use
+// opengl graphics system or paint into QGLWidget.
+#ifdef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM
+ QApplication::setGraphicsSystem("opengl");
+#endif
+
+ QApplication app(argc, argv);
+ QmlApplicationViewer viewer;
+
+#ifndef SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM
+ QGLFormat format = QGLFormat::defaultFormat();
+ format.setSampleBuffers(false);
+ format.setSwapInterval(1);
+ QGLWidget* glWidget = new QGLWidget(format);
+ glWidget->setAutoFillBackground(false);
+ viewer.setViewport(glWidget);
+#endif
+
+ viewer.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
+ viewer.setAttribute(Qt::WA_OpaquePaintEvent);
+ viewer.setAttribute(Qt::WA_NoSystemBackground);
+ viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
+ viewer.setMainQmlFile(QLatin1String("qml/shadereffects/main.qml"));
+ QObject::connect(viewer.engine(), SIGNAL(quit()), &viewer, SLOT(close()));
+ viewer.showExpanded();
+
+ return app.exec();
+}
diff --git a/examples/declarative/shadereffects/qml/shadereffects/Curtain.qml b/examples/declarative/shadereffects/qml/shadereffects/Curtain.qml
new file mode 100644
index 00000000..fc350290
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/Curtain.qml
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import Qt.labs.shaders 1.0
+
+Item {
+ id: main
+ anchors.fill: parent
+
+ Rectangle{
+ id: bg
+ anchors.fill: parent
+ color: "black"
+ }
+
+ Image {
+ source: "images/qt-logo.png"
+ anchors.centerIn: parent
+ }
+
+ Image {
+ id: fabric
+ anchors.fill: parent
+ source: "images/fabric.jpg"
+ fillMode: Image.Tile
+ }
+
+ CurtainEffect {
+ id: curtain
+ anchors.fill: fabric
+ bottomWidth: topWidth
+ source: ShaderEffectSource { sourceItem: fabric; hideSource: true }
+
+ Behavior on bottomWidth {
+ SpringAnimation { easing.type: Easing.OutElastic; velocity: 250; mass: 1.5; spring: 0.5; damping: 0.05}
+ }
+
+ SequentialAnimation on topWidth {
+ id: topWidthAnim
+ loops: Animation.Infinite
+
+ NumberAnimation { to: 360; duration: 1000 }
+ PauseAnimation { duration: 2000 }
+ NumberAnimation { to: 180; duration: 1000 }
+ PauseAnimation { duration: 2000 }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+
+ onPressed: {
+ topWidthAnim.stop()
+ curtain.topWidth = mouseX;
+ }
+
+ onReleased: {
+ topWidthAnim.restart()
+ }
+
+ onPositionChanged: {
+ if (pressed) {
+ curtain.topWidth = mouseX;
+ }
+ }
+ }
+}
diff --git a/examples/declarative/shadereffects/qml/shadereffects/CurtainEffect.qml b/examples/declarative/shadereffects/qml/shadereffects/CurtainEffect.qml
new file mode 100644
index 00000000..3f398f15
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/CurtainEffect.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import Qt.labs.shaders 1.0
+
+ShaderEffectItem {
+ anchors.fill: parent
+ property variant source
+ meshResolution: Qt.size(50, 50)
+
+ property real topWidth: width / 2
+ property real bottomWidth: width / 2
+ property real originalWidth: width
+ property real originalHeight: height
+ property real amplitude: 0.1
+
+ vertexShader: "
+ attribute highp vec4 qt_Vertex;
+ attribute highp vec2 qt_MultiTexCoord0;
+ uniform highp mat4 qt_ModelViewProjectionMatrix;
+ varying highp vec2 qt_TexCoord0;
+ varying lowp float shade;
+
+ uniform highp float topWidth;
+ uniform highp float bottomWidth;
+ uniform highp float originalWidth;
+ uniform highp float originalHeight;
+ uniform highp float amplitude;
+
+ void main() {
+ qt_TexCoord0 = qt_MultiTexCoord0;
+
+ highp vec4 shift = vec4(0, 0, 0, 0);
+ shift.x = qt_Vertex.x * ((originalWidth - topWidth) + (topWidth - bottomWidth) * (qt_Vertex.y / originalHeight)) / originalWidth;
+
+ shade = sin(21.9911486 * qt_Vertex.x / originalWidth);
+ shift.y = amplitude * (originalWidth - topWidth + (topWidth - bottomWidth) * (qt_Vertex.y / originalHeight)) * shade;
+
+ gl_Position = qt_ModelViewProjectionMatrix * (qt_Vertex - shift);
+
+ shade = 0.2 * (2.0 - shade ) * (1.0 - (bottomWidth + (topWidth - bottomWidth) * (1.0 - qt_Vertex.y / originalHeight)) / originalWidth);
+ }
+ "
+
+ fragmentShader: "
+ uniform sampler2D source;
+ varying highp vec2 qt_TexCoord0;
+ varying lowp float shade;
+ void main() {
+ highp vec4 color = texture2D(source, qt_TexCoord0);
+ color.rgb *= 1.0 - shade;
+ gl_FragColor = color;
+ }
+ "
+}
+
+
+
diff --git a/examples/declarative/shadereffects/qml/shadereffects/DropShadow.qml b/examples/declarative/shadereffects/qml/shadereffects/DropShadow.qml
new file mode 100644
index 00000000..1c3b9614
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/DropShadow.qml
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+
+Item {
+ id: main
+ anchors.fill: parent
+
+ Image {
+ id: background
+ anchors.fill: parent
+ source: "images/bg.jpg"
+ }
+
+ DropShadowEffect {
+ id: layer
+
+ property real distance: 0.0
+
+ width: photo.width
+ height: photo.height
+ sourceItem: photo
+ color: "black"
+ blur: distance / 10.0
+ opacity: 1 - distance / 50.0
+
+ Binding {
+ target: layer
+ property: "x"
+ value: -0.4 * layer.distance
+ when: !dragArea.pressed
+ }
+ Binding {
+ target: layer
+ property: "y"
+ value: 0.9 * layer.distance
+ when: !dragArea.pressed
+ }
+
+ SequentialAnimation on distance {
+ id: animation
+ running: true
+ loops: Animation.Infinite
+
+ NumberAnimation { to: 30; duration: 2000 }
+ PauseAnimation { duration: 500 }
+ NumberAnimation { to: 0; duration: 2000 }
+ PauseAnimation { duration: 500 }
+ }
+ }
+
+ Image {
+ id: photo
+ anchors.fill: parent
+ source: "images/drop_shadow.png"
+ smooth: true
+ }
+
+ MouseArea {
+ id: dragArea
+ anchors.fill: parent
+
+ property int startX
+ property int startY
+
+ onPressed: {
+ startX = mouseX
+ startY = mouseY
+ }
+
+ onPositionChanged: {
+ layer.x += mouseX - startX
+ layer.y += mouseY - startY
+ startX = mouseX
+ startY = mouseY
+ }
+ }
+}
diff --git a/examples/declarative/shadereffects/qml/shadereffects/DropShadowEffect.qml b/examples/declarative/shadereffects/qml/shadereffects/DropShadowEffect.qml
new file mode 100644
index 00000000..0fa7d2f8
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/DropShadowEffect.qml
@@ -0,0 +1,174 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import Qt.labs.shaders 1.0
+
+Item {
+ id: main
+ property real blur: 0.0
+ property alias color: shadowEffectWithHBlur.color
+ property alias sourceItem: source.sourceItem
+
+ ShaderEffectSource {
+ id: source
+ smooth: true
+ hideSource: false
+ }
+
+ ShaderEffectItem {
+ id: shadowEffectWithHBlur
+ anchors.fill: parent
+
+ property color color: "grey"
+ property variant sourceTexture: source;
+ property real xStep: main.blur / main.width
+
+ vertexShader:"
+ uniform highp mat4 qt_ModelViewProjectionMatrix;
+ attribute highp vec4 qt_Vertex;
+ attribute highp vec2 qt_MultiTexCoord0;
+ uniform highp float xStep;
+ varying highp vec2 qt_TexCoord0;
+ varying highp vec2 qt_TexCoord1;
+ varying highp vec2 qt_TexCoord2;
+ varying highp vec2 qt_TexCoord4;
+ varying highp vec2 qt_TexCoord5;
+ varying highp vec2 qt_TexCoord6;
+
+ void main(void)
+ {
+ highp vec2 shift = vec2(xStep, 0.);
+ qt_TexCoord0 = qt_MultiTexCoord0 - 2.5 * shift;
+ qt_TexCoord1 = qt_MultiTexCoord0 - 1.5 * shift;
+ qt_TexCoord2 = qt_MultiTexCoord0 - 0.5 * shift;
+ qt_TexCoord4 = qt_MultiTexCoord0 + 0.5 * shift;
+ qt_TexCoord5 = qt_MultiTexCoord0 + 1.5 * shift;
+ qt_TexCoord6 = qt_MultiTexCoord0 + 2.5 * shift;
+ gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex;
+ }
+ "
+
+ fragmentShader:"
+ uniform highp vec4 color;
+ uniform lowp sampler2D sourceTexture;
+ varying highp vec2 qt_TexCoord0;
+ varying highp vec2 qt_TexCoord1;
+ varying highp vec2 qt_TexCoord2;
+ varying highp vec2 qt_TexCoord4;
+ varying highp vec2 qt_TexCoord5;
+ varying highp vec2 qt_TexCoord6;
+
+ void main() {
+ highp vec4 sourceColor = (texture2D(sourceTexture, qt_TexCoord0) * 0.1
+ + texture2D(sourceTexture, qt_TexCoord1) * 0.15
+ + texture2D(sourceTexture, qt_TexCoord2) * 0.25
+ + texture2D(sourceTexture, qt_TexCoord4) * 0.25
+ + texture2D(sourceTexture, qt_TexCoord5) * 0.15
+ + texture2D(sourceTexture, qt_TexCoord6) * 0.1);
+ gl_FragColor = mix(vec4(0), color, sourceColor.a);
+ }
+ "
+ }
+
+ ShaderEffectSource {
+ id: hBlurredShadow
+ smooth: true
+ sourceItem: shadowEffectWithHBlur
+ hideSource: true
+ }
+
+ ShaderEffectItem {
+ id: finalEffect
+ anchors.fill: parent
+
+ property color color: "grey"
+ property variant sourceTexture: hBlurredShadow;
+ property real yStep: main.blur / main.height
+
+ vertexShader:"
+ uniform highp mat4 qt_ModelViewProjectionMatrix;
+ attribute highp vec4 qt_Vertex;
+ attribute highp vec2 qt_MultiTexCoord0;
+ uniform highp float yStep;
+ varying highp vec2 qt_TexCoord0;
+ varying highp vec2 qt_TexCoord1;
+ varying highp vec2 qt_TexCoord2;
+ varying highp vec2 qt_TexCoord4;
+ varying highp vec2 qt_TexCoord5;
+ varying highp vec2 qt_TexCoord6;
+
+ void main(void)
+ {
+ highp vec2 shift = vec2(0., yStep);
+ qt_TexCoord0 = qt_MultiTexCoord0 - 2.5 * shift;
+ qt_TexCoord1 = qt_MultiTexCoord0 - 1.5 * shift;
+ qt_TexCoord2 = qt_MultiTexCoord0 - 0.5 * shift;
+ qt_TexCoord4 = qt_MultiTexCoord0 + 0.5 * shift;
+ qt_TexCoord5 = qt_MultiTexCoord0 + 1.5 * shift;
+ qt_TexCoord6 = qt_MultiTexCoord0 + 2.5 * shift;
+ gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex;
+ }
+ "
+
+ fragmentShader:"
+ uniform highp vec4 color;
+ uniform lowp sampler2D sourceTexture;
+ uniform highp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ varying highp vec2 qt_TexCoord1;
+ varying highp vec2 qt_TexCoord2;
+ varying highp vec2 qt_TexCoord4;
+ varying highp vec2 qt_TexCoord5;
+ varying highp vec2 qt_TexCoord6;
+
+ void main() {
+ highp vec4 sourceColor = (texture2D(sourceTexture, qt_TexCoord0) * 0.1
+ + texture2D(sourceTexture, qt_TexCoord1) * 0.15
+ + texture2D(sourceTexture, qt_TexCoord2) * 0.25
+ + texture2D(sourceTexture, qt_TexCoord4) * 0.25
+ + texture2D(sourceTexture, qt_TexCoord5) * 0.15
+ + texture2D(sourceTexture, qt_TexCoord6) * 0.1);
+ gl_FragColor = sourceColor * qt_Opacity;
+ }
+ "
+ }
+}
diff --git a/examples/declarative/shadereffects/qml/shadereffects/Grayscale.qml b/examples/declarative/shadereffects/qml/shadereffects/Grayscale.qml
new file mode 100644
index 00000000..4899f80d
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/Grayscale.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import Qt.labs.shaders 1.0
+
+Item {
+ id: main
+ anchors.fill: parent
+
+ GrayscaleEffect {
+ id: layer
+ anchors.fill: parent
+
+ source: ShaderEffectSource {
+ sourceItem: Image { source: "images/desaturate.jpg" }
+ live: false
+ hideSource: true
+ }
+
+ SequentialAnimation on ratio {
+ id: ratioAnimation
+ running: true
+ loops: Animation.Infinite
+ NumberAnimation {
+ easing.type: Easing.Linear
+ to: 0.0
+ duration: 1500
+ }
+ PauseAnimation { duration: 1000 }
+ NumberAnimation {
+ easing.type: Easing.Linear
+ to: 1.0
+ duration: 1500
+ }
+ PauseAnimation { duration: 1000 }
+ }
+ }
+}
diff --git a/examples/declarative/shadereffects/qml/shadereffects/GrayscaleEffect.qml b/examples/declarative/shadereffects/qml/shadereffects/GrayscaleEffect.qml
new file mode 100644
index 00000000..fcf75776
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/GrayscaleEffect.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import Qt.labs.shaders 1.0
+
+ShaderEffectItem {
+ id: effect
+ property real ratio: 1.0
+ property variant source: 0
+
+ fragmentShader:
+ "
+ varying highp vec2 qt_TexCoord0;
+ uniform sampler2D source;
+ uniform highp float ratio;
+ void main(void)
+ {
+ lowp vec4 textureColor = texture2D(source, qt_TexCoord0.st);
+ lowp float gray = dot(textureColor, vec4(0.299, 0.587, 0.114, 0.0));
+ gl_FragColor = vec4(gray * ratio + textureColor.r * (1.0 - ratio), gray * ratio + textureColor.g * (1.0 - ratio), gray * ratio + textureColor.b * (1.0 - ratio), textureColor.a);
+ }
+ "
+}
diff --git a/examples/declarative/shadereffects/qml/shadereffects/ImageMask.qml b/examples/declarative/shadereffects/qml/shadereffects/ImageMask.qml
new file mode 100644
index 00000000..c386daac
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/ImageMask.qml
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import Qt.labs.shaders 1.0
+
+Item {
+ anchors.fill: parent
+
+ Image {
+ id: bg
+ anchors.fill: parent
+ source: "images/image2.jpg"
+ }
+
+ Item {
+ id: mask
+ anchors.fill: parent
+
+ Text {
+ text: "Mask text"
+ font.pixelSize: 50
+ font.bold: true
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ NumberAnimation on rotation {
+ running: true
+ loops: Animation.Infinite
+ from: 0
+ to: 360
+ duration: 3000
+ }
+
+ SequentialAnimation on y {
+ running: true
+ loops: Animation.Infinite
+ NumberAnimation {
+ to: main.height
+ duration: 3000
+ }
+ NumberAnimation {
+ to: 0
+ duration: 3000
+ }
+ }
+ }
+
+ Rectangle {
+ id: opaqueBox
+ width: 60
+ height: parent.height
+ SequentialAnimation on x {
+ running: true
+ loops: Animation.Infinite
+ NumberAnimation {
+ to: main.width
+ duration: 2000
+ easing.type: Easing.InOutCubic
+ }
+ NumberAnimation {
+ to: 0
+ duration: 2000
+ easing.type: Easing.InOutCubic
+ }
+ }
+ }
+
+ Rectangle {
+ width: 100
+ opacity: 0.5
+ height: parent.height
+ SequentialAnimation on x {
+ PauseAnimation { duration: 100 }
+
+ SequentialAnimation {
+ loops: Animation.Infinite
+ NumberAnimation {
+ to: main.width
+ duration: 2000
+ easing.type: Easing.InOutCubic
+ }
+ NumberAnimation {
+ to: 0
+ duration: 2000
+ easing.type: Easing.InOutCubic
+ }
+ }
+ }
+ }
+ }
+
+ ImageMaskEffect {
+ anchors.fill: parent
+ image: ShaderEffectSource {
+ sourceItem: Image { source: "images/image1.jpg" }
+ live: false
+ hideSource: true
+ }
+ mask: ShaderEffectSource {
+ sourceItem: mask
+ live: true
+ hideSource: true
+ }
+ }
+}
diff --git a/examples/declarative/shadereffects/qml/shadereffects/ImageMaskEffect.qml b/examples/declarative/shadereffects/qml/shadereffects/ImageMaskEffect.qml
new file mode 100644
index 00000000..6649b175
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/ImageMaskEffect.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import Qt.labs.shaders 1.0
+
+ShaderEffectItem {
+ id: effect
+ property variant image: 0
+ property variant mask: 0
+
+ fragmentShader:
+ "
+ varying highp vec2 qt_TexCoord0;
+ uniform sampler2D image;
+ uniform sampler2D mask;
+ void main(void)
+ {
+ gl_FragColor = texture2D(image, qt_TexCoord0.st) * (texture2D(mask, qt_TexCoord0.st).a);
+ }
+ "
+}
diff --git a/examples/declarative/shadereffects/qml/shadereffects/RadialWave.qml b/examples/declarative/shadereffects/qml/shadereffects/RadialWave.qml
new file mode 100644
index 00000000..23d3ba2d
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/RadialWave.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import Qt.labs.shaders 1.0
+
+Item {
+ id: main
+ anchors.fill: parent
+
+ ShaderEffectSource {
+ id: thesource
+ sourceItem: Image { source: "images/wave.jpg" }
+ live: false
+ hideSource: true
+ }
+
+ RadialWaveEffect {
+ id: layer
+ anchors.fill: parent;
+ source: thesource
+
+ wave: 0.0
+ waveOriginX: 0.5
+ waveOriginY: 0.5
+ waveWidth: 0.01
+
+ NumberAnimation on wave {
+ id: waveAnim
+ running: true
+ loops: Animation.Infinite
+ easing.type: "Linear"
+ from: 0.0000; to: 2.0000;
+ duration: 2500
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onPressed: {
+ waveAnim.stop()
+ layer.waveOriginX = mouseX / main.width
+ layer.waveOriginY = mouseY / main.height
+ waveAnim.start()
+ }
+ }
+}
diff --git a/examples/declarative/shadereffects/qml/shadereffects/RadialWaveEffect.qml b/examples/declarative/shadereffects/qml/shadereffects/RadialWaveEffect.qml
new file mode 100644
index 00000000..f5127d1e
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/RadialWaveEffect.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import Qt.labs.shaders 1.0
+
+ShaderEffectItem {
+ id: effect
+
+ property real wave: 0.3
+ property real waveOriginX: 0.5
+ property real waveOriginY: 0.5
+ property real waveWidth: 0.01
+ property real aspectRatio: width/height
+ property variant source: 0
+
+ fragmentShader:
+ "
+ varying mediump vec2 qt_TexCoord0;
+ uniform sampler2D source;
+ uniform highp float wave;
+ uniform highp float waveWidth;
+ uniform highp float waveOriginX;
+ uniform highp float waveOriginY;
+ uniform highp float aspectRatio;
+
+ void main(void)
+ {
+ mediump vec2 texCoord2 = qt_TexCoord0;
+ mediump vec2 origin = vec2(waveOriginX, (1.0 - waveOriginY) / aspectRatio);
+
+ highp float fragmentDistance = distance(vec2(texCoord2.s, texCoord2.t / aspectRatio), origin);
+ highp float waveLength = waveWidth + fragmentDistance * 0.25;
+
+ if ( fragmentDistance > wave && fragmentDistance < wave + waveLength) {
+ highp float distanceFromWaveEdge = min(abs(wave - fragmentDistance), abs(wave + waveLength - fragmentDistance));
+ texCoord2 += sin(1.57075 * distanceFromWaveEdge / waveLength) * distanceFromWaveEdge * 0.08 / fragmentDistance;
+ }
+
+ gl_FragColor = texture2D(source, texCoord2.st);
+ }
+ "
+}
diff --git a/examples/declarative/shadereffects/qml/shadereffects/Water.qml b/examples/declarative/shadereffects/qml/shadereffects/Water.qml
new file mode 100644
index 00000000..30cf61a7
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/Water.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import Qt.labs.shaders 1.0
+
+Item {
+ anchors.fill: parent
+
+ Image {
+ id: image
+ width: parent.width
+ height: parent.height * 0.65
+ source: "images/sky.jpg"
+ smooth: true
+ }
+ WaterEffect {
+ sourceItem: image
+ intensity: 5
+ height: parent.height - image.height
+ }
+}
diff --git a/examples/declarative/shadereffects/qml/shadereffects/WaterEffect.qml b/examples/declarative/shadereffects/qml/shadereffects/WaterEffect.qml
new file mode 100644
index 00000000..661c34e7
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/WaterEffect.qml
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import Qt.labs.shaders 1.0
+
+Item {
+ id: root
+ property alias sourceItem: effectsource.sourceItem
+ property real intensity: 1
+ property bool waving: true
+ anchors.top: sourceItem.bottom
+ width: sourceItem.width
+ height: sourceItem.height
+
+ ShaderEffectItem {
+ anchors.fill: parent
+ property variant source: effectsource
+ property real f: 0
+ property real f2: 0
+ property alias intensity: root.intensity
+ smooth: true
+
+ ShaderEffectSource {
+ id: effectsource
+ hideSource: false
+ smooth: true
+ }
+
+ fragmentShader:
+ "
+ varying highp vec2 qt_TexCoord0;
+ uniform sampler2D source;
+ uniform lowp float qt_Opacity;
+ uniform highp float f;
+ uniform highp float f2;
+ uniform highp float intensity;
+
+ void main() {
+ const highp float twopi = 3.141592653589 * 2.0;
+
+ highp float distanceFactorToPhase = pow(qt_TexCoord0.y + 0.5, 8.0) * 5.0;
+ highp float ofx = sin(f * twopi + distanceFactorToPhase) / 100.0;
+ highp float ofy = sin(f2 * twopi + distanceFactorToPhase * qt_TexCoord0.x) / 60.0;
+
+ highp float intensityDampingFactor = (qt_TexCoord0.x + 0.1) * (qt_TexCoord0.y + 0.2);
+ highp float distanceFactor = (1.0 - qt_TexCoord0.y) * 4.0 * intensity * intensityDampingFactor;
+
+ ofx *= distanceFactor;
+ ofy *= distanceFactor;
+
+ highp float x = qt_TexCoord0.x + ofx;
+ highp float y = 1.0 - qt_TexCoord0.y + ofy;
+
+ highp float fake = (sin((ofy + ofx) * twopi) + 0.5) * 0.05 * (1.2 - qt_TexCoord0.y) * intensity * intensityDampingFactor;
+
+ highp vec4 pix =
+ texture2D(source, vec2(x, y)) * 0.6 +
+ texture2D(source, vec2(x-fake, y)) * 0.15 +
+ texture2D(source, vec2(x, y-fake)) * 0.15 +
+ texture2D(source, vec2(x+fake, y)) * 0.15 +
+ texture2D(source, vec2(x, y+fake)) * 0.15;
+
+ highp float darken = 0.6 - (ofx - ofy) / 2.0;
+ pix.b *= 1.2 * darken;
+ pix.r *= 0.9 * darken;
+ pix.g *= darken;
+
+ gl_FragColor = qt_Opacity * vec4(pix.r, pix.g, pix.b, 1.0);
+ }
+ "
+
+ NumberAnimation on f {
+ running: root.waving
+ loops: Animation.Infinite
+ from: 0
+ to: 1
+ duration: 2410
+ }
+ NumberAnimation on f2 {
+ running: root.waving
+ loops: Animation.Infinite
+ from: 0
+ to: 1
+ duration: 1754
+ }
+ }
+}
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/Curtain.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/Curtain.jpg
new file mode 100644
index 00000000..40003cbb
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/Curtain.jpg
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/DropShadow.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/DropShadow.jpg
new file mode 100644
index 00000000..c1e693a5
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/DropShadow.jpg
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/Grayscale.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/Grayscale.jpg
new file mode 100644
index 00000000..c95cab47
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/Grayscale.jpg
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/ImageMask.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/ImageMask.jpg
new file mode 100644
index 00000000..0da4c0da
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/ImageMask.jpg
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/RadialWave.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/RadialWave.jpg
new file mode 100644
index 00000000..fc51efcc
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/RadialWave.jpg
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/Water.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/Water.jpg
new file mode 100644
index 00000000..38615c13
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/Water.jpg
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/back.png b/examples/declarative/shadereffects/qml/shadereffects/images/back.png
new file mode 100644
index 00000000..5dd3d226
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/back.png
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/bg.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/bg.jpg
new file mode 100644
index 00000000..4d221438
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/bg.jpg
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/desaturate.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/desaturate.jpg
new file mode 100644
index 00000000..e5e99bb9
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/desaturate.jpg
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/drop_shadow.png b/examples/declarative/shadereffects/qml/shadereffects/images/drop_shadow.png
new file mode 100644
index 00000000..144c02d5
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/drop_shadow.png
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/fabric.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/fabric.jpg
new file mode 100644
index 00000000..ab654093
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/fabric.jpg
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/flower.png b/examples/declarative/shadereffects/qml/shadereffects/images/flower.png
new file mode 100644
index 00000000..144c02d5
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/flower.png
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/image1.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/image1.jpg
new file mode 100644
index 00000000..3442e775
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/image1.jpg
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/image2.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/image2.jpg
new file mode 100644
index 00000000..23e5c5c1
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/image2.jpg
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/qt-logo.png b/examples/declarative/shadereffects/qml/shadereffects/images/qt-logo.png
new file mode 100644
index 00000000..41a304b4
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/qt-logo.png
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/shader_effects.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/shader_effects.jpg
new file mode 100644
index 00000000..19e8a399
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/shader_effects.jpg
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/sky.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/sky.jpg
new file mode 100644
index 00000000..8fc19ed1
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/sky.jpg
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/toolbar.png b/examples/declarative/shadereffects/qml/shadereffects/images/toolbar.png
new file mode 100644
index 00000000..773e3ea1
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/toolbar.png
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/images/wave.jpg b/examples/declarative/shadereffects/qml/shadereffects/images/wave.jpg
new file mode 100644
index 00000000..c8083bba
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/images/wave.jpg
Binary files differ
diff --git a/examples/declarative/shadereffects/qml/shadereffects/main.qml b/examples/declarative/shadereffects/qml/shadereffects/main.qml
new file mode 100644
index 00000000..01b9ee8d
--- /dev/null
+++ b/examples/declarative/shadereffects/qml/shadereffects/main.qml
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 1.0
+import Qt.labs.shaders 1.0
+
+Item {
+ id: main
+ width: 360
+ height: 640
+
+ Rectangle {
+ anchors.fill: parent
+ color: "black"
+ }
+
+ Image {
+ id: header
+ source: "images/shader_effects.jpg"
+ }
+
+ ListModel {
+ id: demoModel
+ ListElement { name: "ImageMask" }
+ ListElement { name: "RadialWave" }
+ ListElement { name: "Water" }
+ ListElement { name: "Grayscale" }
+ ListElement { name: "DropShadow" }
+ ListElement { name: "Curtain" }
+ }
+
+ Grid {
+ id: menuGrid
+ anchors.top: header.bottom
+ anchors.bottom: toolbar.top
+ width: parent.width
+ columns: 2
+ Repeater {
+ model: demoModel
+ Item {
+ width: main.width / 2
+ height: menuGrid.height / 3
+ clip: true
+ Image {
+ width: parent.width
+ height: width
+ source: "images/" + name + ".jpg"
+ opacity: mouseArea.pressed ? 0.6 : 1.0
+ }
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ demoLoader.source = name + ".qml"
+ main.state = "showDemo"
+ }
+ }
+ }
+ }
+ }
+
+ Loader {
+ anchors.fill: parent
+ id: demoLoader
+ visible: false
+ Behavior on opacity {
+ NumberAnimation { duration: 300 }
+ }
+ }
+
+ Image {
+ id: toolbar
+ source: "images/toolbar.png"
+ width: parent.width
+ anchors.bottom: parent.bottom
+ }
+
+ Rectangle {
+ id: translucentToolbar
+ color: "black"
+ opacity: 0.3
+ anchors.fill: toolbar
+ visible: !toolbar.visible
+ }
+
+ Item {
+ height: toolbar.height
+ width: height
+ anchors.bottom: parent.bottom
+
+ Image {
+ source: "images/back.png"
+ anchors.centerIn: parent
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (main.state == "") Qt.quit(); else {
+ main.state = ""
+ demoLoader.source = ""
+ }
+ }
+ }
+ }
+
+ states: State {
+ name: "showDemo"
+ PropertyChanges {
+ target: menuGrid
+ visible: false
+ }
+ PropertyChanges {
+ target: demoLoader
+ visible: true
+ }
+ PropertyChanges {
+ target: toolbar
+ visible: false
+ }
+ }
+}
diff --git a/examples/declarative/shadereffects/shadereffects.pro b/examples/declarative/shadereffects/shadereffects.pro
new file mode 100644
index 00000000..58e7ab7d
--- /dev/null
+++ b/examples/declarative/shadereffects/shadereffects.pro
@@ -0,0 +1,46 @@
+# Add more folders to ship with the application, here
+folder_01.source = qml/shadereffects
+folder_01.target = qml
+DEPLOYMENTFOLDERS = folder_01
+
+# Additional import path used to resolve QML modules in Creator's code model
+QML_IMPORT_PATH =
+
+symbian:TARGET.UID3 = 0xE1CB8EBB
+
+# Smart Installer package's UID
+# This UID is from the protected range and therefore the package will
+# fail to install if self-signed. By default qmake uses the unprotected
+# range value if unprotected UID is defined for the application and
+# 0x2002CCCF value if protected UID is given to the application
+#symbian:DEPLOYMENT.installer_header = 0x2002CCCF
+
+# Allow network access on Symbian
+symbian:TARGET.CAPABILITY += NetworkServices
+
+# If your application uses the Qt Mobility libraries, uncomment the following
+# lines and add the respective components to the MOBILITY variable.
+# CONFIG += mobility
+# MOBILITY +=
+
+# Speed up launching on MeeGo/Harmattan when using applauncherd daemon
+# CONFIG += qdeclarative-boostable
+
+# Add dependency to Symbian components
+# CONFIG += qt-components
+
+QT += declarative opengl
+
+# The .cpp file which was generated for your project. Feel free to hack it.
+SOURCES += main.cpp
+
+symbian {
+ DEFINES += SHADEREFFECTS_USE_OPENGL_GRAPHICSSYSTEM
+}
+
+# Please do not modify the following two lines. Required for deployment.
+desktopInstallPrefix=$$[QT_INSTALL_EXAMPLES]/declarative/shadereffects
+exists(qmlapplicationviewer/qmlapplicationviewer.pri):include(qmlapplicationviewer/qmlapplicationviewer.pri)
+else:exists(qmlapplicationviewer/qmlapplicationviewer.pri):include(qmlapplicationviewer/qmlapplicationviewer.pri)
+else:include(../../helper/qmlapplicationviewer/qmlapplicationviewer.pri)
+qtcAddDeployment()
diff --git a/examples/declarative/shadereffects/shadereffects.qmlproject b/examples/declarative/shadereffects/shadereffects.qmlproject
new file mode 100644
index 00000000..112be81a
--- /dev/null
+++ b/examples/declarative/shadereffects/shadereffects.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "qml/shadereffects"
+ }
+ JavaScriptFiles {
+ directory: "qml/shadereffects"
+ }
+ ImageFiles {
+ directory: "qml/shadereffects"
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+} \ No newline at end of file