aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/scenegraph/graph
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-04-06 14:18:18 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-04-07 17:08:39 +0200
commitfd4f121fcaccc671f942b8542e3c8f9eaedc7942 (patch)
treef15d4230c2e84eeb56268198cf5f4080166eb1b6 /examples/quick/scenegraph/graph
parentaafd78d0340a971bfc72ac1ce5adaf8a175265af (diff)
Remove QSGSimpleMaterial
And port the graph example to QSGMaterial and the RHI. We will not anymore add a direct OpenGL path (that would mean using QSGMaterialShader) for the example because the upcoming purge renders that useless anyway. Task-number: QTBUG-82988 Change-Id: I137575ed5df45b6bfc34a11d73dc5100945081c5 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'examples/quick/scenegraph/graph')
-rw-r--r--examples/quick/scenegraph/graph/graph.qrc8
-rw-r--r--examples/quick/scenegraph/graph/linenode.cpp103
-rw-r--r--examples/quick/scenegraph/graph/main.cpp2
-rw-r--r--examples/quick/scenegraph/graph/noisynode.cpp123
-rw-r--r--examples/quick/scenegraph/graph/shaders/compile.bat54
-rw-r--r--examples/quick/scenegraph/graph/shaders/line.frag21
-rw-r--r--examples/quick/scenegraph/graph/shaders/line.frag.qsbbin0 -> 1361 bytes
-rw-r--r--examples/quick/scenegraph/graph/shaders/line.fsh64
-rw-r--r--examples/quick/scenegraph/graph/shaders/line.vert25
-rw-r--r--examples/quick/scenegraph/graph/shaders/line.vert.qsbbin0 -> 1742 bytes
-rw-r--r--examples/quick/scenegraph/graph/shaders/line.vsh66
-rw-r--r--examples/quick/scenegraph/graph/shaders/noisy.frag24
-rw-r--r--examples/quick/scenegraph/graph/shaders/noisy.frag.qsbbin0 -> 1866 bytes
-rw-r--r--examples/quick/scenegraph/graph/shaders/noisy.fsh65
-rw-r--r--examples/quick/scenegraph/graph/shaders/noisy.vert22
-rw-r--r--examples/quick/scenegraph/graph/shaders/noisy.vert.qsbbin0 -> 1736 bytes
-rw-r--r--examples/quick/scenegraph/graph/shaders/noisy.vsh64
17 files changed, 312 insertions, 329 deletions
diff --git a/examples/quick/scenegraph/graph/graph.qrc b/examples/quick/scenegraph/graph/graph.qrc
index 2adaeac751..b7fc7539f8 100644
--- a/examples/quick/scenegraph/graph/graph.qrc
+++ b/examples/quick/scenegraph/graph/graph.qrc
@@ -1,9 +1,9 @@
<RCC>
<qresource prefix="/scenegraph/graph">
<file>main.qml</file>
- <file>shaders/noisy.vsh</file>
- <file>shaders/noisy.fsh</file>
- <file>shaders/line.vsh</file>
- <file>shaders/line.fsh</file>
+ <file>shaders/noisy.vert.qsb</file>
+ <file>shaders/noisy.frag.qsb</file>
+ <file>shaders/line.vert.qsb</file>
+ <file>shaders/line.frag.qsb</file>
</qresource>
</RCC>
diff --git a/examples/quick/scenegraph/graph/linenode.cpp b/examples/quick/scenegraph/graph/linenode.cpp
index cb7f1c8e7f..5d4d8acd20 100644
--- a/examples/quick/scenegraph/graph/linenode.cpp
+++ b/examples/quick/scenegraph/graph/linenode.cpp
@@ -52,45 +52,90 @@
#include <QtGui/QColor>
-#include <QtQuick/QSGSimpleMaterial>
+#include <QtQuick/QSGMaterial>
-struct LineMaterial
+class LineShader : public QSGMaterialRhiShader
{
- QColor color;
- float spread;
- float size;
+public:
+ LineShader() {
+ setShaderFileName(VertexStage, QLatin1String(":/scenegraph/graph/shaders/line.vert.qsb"));
+ setShaderFileName(FragmentStage, QLatin1String(":/scenegraph/graph/shaders/line.frag.qsb"));
+ }
+
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
-class LineShader : public QSGSimpleMaterialShader<LineMaterial>
+class LineMaterial : public QSGMaterial
{
- QSG_DECLARE_SIMPLE_SHADER(LineShader, LineMaterial)
-
public:
- LineShader() {
- setShaderSourceFile(QOpenGLShader::Vertex, ":/scenegraph/graph/shaders/line.vsh");
- setShaderSourceFile(QOpenGLShader::Fragment, ":/scenegraph/graph/shaders/line.fsh");
+ LineMaterial()
+ {
+ setFlag(SupportsRhiShader);
+ setFlag(Blending);
}
- QList<QByteArray> attributes() const override { return QList<QByteArray>() << "pos" << "t"; }
+ QSGMaterialType *type() const override
+ {
+ static QSGMaterialType type;
+ return &type;
+ }
- void updateState(const LineMaterial *m, const LineMaterial *) override {
- program()->setUniformValue(id_color, m->color);
- program()->setUniformValue(id_spread, m->spread);
- program()->setUniformValue(id_size, m->size);
+ QSGMaterialShader *createShader() const override
+ {
+ Q_ASSERT(flags().testFlag(RhiShaderWanted));
+ return new LineShader;
}
- void resolveUniforms() override {
- id_spread = program()->uniformLocation("spread");
- id_size = program()->uniformLocation("size");
- id_color = program()->uniformLocation("color");
+ int compare(const QSGMaterial *m) const override
+ {
+ const LineMaterial *other = static_cast<const LineMaterial *>(m);
+
+ if (int diff = int(state.color.rgb()) - int(other->state.color.rgb()))
+ return diff;
+
+ if (int diff = state.size - other->state.size)
+ return diff;
+
+ if (int diff = state.spread - other->state.spread)
+ return diff;
+
+ return 0;
}
-private:
- int id_color = -1;
- int id_spread = -1;
- int id_size = -1;
+ struct {
+ QColor color;
+ float size;
+ float spread;
+ } state;
};
+bool LineShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *)
+{
+ QByteArray *buf = state.uniformData();
+ Q_ASSERT(buf->size() >= 92);
+
+ if (state.isMatrixDirty()) {
+ const QMatrix4x4 m = state.combinedMatrix();
+ memcpy(buf->data(), m.constData(), 64);
+ }
+
+ if (state.isOpacityDirty()) {
+ const float opacity = state.opacity();
+ memcpy(buf->data() + 80, &opacity, 4);
+ }
+
+ LineMaterial *mat = static_cast<LineMaterial *>(newMaterial);
+ float c[4] = { float(mat->state.color.redF()),
+ float(mat->state.color.greenF()),
+ float(mat->state.color.blueF()),
+ float(mat->state.color.alphaF()) };
+ memcpy(buf->data() + 64, c, 16);
+ memcpy(buf->data() + 84, &mat->state.size, 4);
+ memcpy(buf->data() + 88, &mat->state.spread, 4);
+
+ return true;
+}
+
struct LineVertex {
float x;
float y;
@@ -114,11 +159,11 @@ LineNode::LineNode(float size, float spread, const QColor &color)
setGeometry(&m_geometry);
m_geometry.setDrawingMode(GL_TRIANGLE_STRIP);
- QSGSimpleMaterial<LineMaterial> *m = LineShader::createMaterial();
- m->state()->color = color;
- m->state()->size = size;
- m->state()->spread = spread;
- m->setFlag(QSGMaterial::Blending);
+ LineMaterial *m = new LineMaterial;
+ m->state.color = color;
+ m->state.size = size;
+ m->state.spread = spread;
+
setMaterial(m);
setFlag(OwnsMaterial);
}
diff --git a/examples/quick/scenegraph/graph/main.cpp b/examples/quick/scenegraph/graph/main.cpp
index 854fad84e3..95c310131b 100644
--- a/examples/quick/scenegraph/graph/main.cpp
+++ b/examples/quick/scenegraph/graph/main.cpp
@@ -56,6 +56,8 @@
int main(int argc, char *argv[])
{
+ qputenv("QSG_RHI", "1"); // ### Qt 6 remove, this will be the default anyway
+
QGuiApplication a(argc, argv);
QQuickView view;
diff --git a/examples/quick/scenegraph/graph/noisynode.cpp b/examples/quick/scenegraph/graph/noisynode.cpp
index de5a616da2..d67110f48a 100644
--- a/examples/quick/scenegraph/graph/noisynode.cpp
+++ b/examples/quick/scenegraph/graph/noisynode.cpp
@@ -51,63 +51,113 @@
#include "noisynode.h"
#include <QtCore/QRandomGenerator>
-#include <QtQuick/QSGSimpleMaterialShader>
+
#include <QtQuick/QSGTexture>
#include <QtQuick/QQuickWindow>
+#include <QtQuick/QSGMaterial>
#define NOISE_SIZE 64
-struct NoisyMaterial
+class NoisyShader : public QSGMaterialRhiShader
{
- ~NoisyMaterial() {
- delete texture;
+public:
+ NoisyShader() {
+ setShaderFileName(VertexStage, QLatin1String(":/scenegraph/graph/shaders/noisy.vert.qsb"));
+ setShaderFileName(FragmentStage, QLatin1String(":/scenegraph/graph/shaders/noisy.frag.qsb"));
}
- QColor color;
- QSGTexture *texture;
+ bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ void updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
+ QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
};
-class NoisyShader : public QSGSimpleMaterialShader<NoisyMaterial>
+class NoisyMaterial : public QSGMaterial
{
- QSG_DECLARE_SIMPLE_SHADER(NoisyShader, NoisyMaterial)
-
public:
- NoisyShader() {
- setShaderSourceFile(QOpenGLShader::Vertex, ":/scenegraph/graph/shaders/noisy.vsh");
- setShaderSourceFile(QOpenGLShader::Fragment, ":/scenegraph/graph/shaders/noisy.fsh");
+ NoisyMaterial()
+ {
+ setFlag(SupportsRhiShader);
+ setFlag(Blending);
+ }
+
+ ~NoisyMaterial()
+ {
+ delete state.texture;
}
- QList<QByteArray> attributes() const override { return QList<QByteArray>() << "aVertex" << "aTexCoord"; }
+ QSGMaterialType *type() const override
+ {
+ static QSGMaterialType type;
+ return &type;
+ }
- void updateState(const NoisyMaterial *m, const NoisyMaterial *) override {
+ QSGMaterialShader *createShader() const override
+ {
+ Q_ASSERT(flags().testFlag(RhiShaderWanted));
+ return new NoisyShader;
+ }
- // Set the color
- program()->setUniformValue(id_color, m->color);
+ int compare(const QSGMaterial *m) const override
+ {
+ const NoisyMaterial *other = static_cast<const NoisyMaterial *>(m);
- // Bind the texture and set program to use texture unit 0 (the default)
- m->texture->bind();
+ if (int diff = int(state.color.rgb()) - int(other->state.color.rgb()))
+ return diff;
- // Then set the texture size so we can adjust the texture coordinates accordingly in the
- // vertex shader..
- QSize s = m->texture->textureSize();
- program()->setUniformValue(id_textureSize, QSizeF(1.0 / s.width(), 1.0 / s.height()));
- }
+ if (!state.texture || !other->state.texture)
+ return state.texture ? 1 : -1;
- void resolveUniforms() override {
- id_texture = program()->uniformLocation("texture");
- id_textureSize = program()->uniformLocation("textureSize");
- id_color = program()->uniformLocation("color");
+ if (int diff = state.texture->comparisonKey() - other->state.texture->comparisonKey())
+ return diff;
- // We will only use texture unit 0, so set it only once.
- program()->setUniformValue(id_texture, 0);
+ return 0;
}
-private:
- int id_color = -1;
- int id_texture = -1;
- int id_textureSize = -1;
+ struct {
+ QColor color;
+ QSGTexture *texture;
+ } state;
};
+bool NoisyShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *)
+{
+ QByteArray *buf = state.uniformData();
+ Q_ASSERT(buf->size() >= 92);
+
+ if (state.isMatrixDirty()) {
+ const QMatrix4x4 m = state.combinedMatrix();
+ memcpy(buf->data(), m.constData(), 64);
+ }
+
+ if (state.isOpacityDirty()) {
+ const float opacity = state.opacity();
+ memcpy(buf->data() + 88, &opacity, 4);
+ }
+
+ NoisyMaterial *mat = static_cast<NoisyMaterial *>(newMaterial);
+ float c[4] = { float(mat->state.color.redF()),
+ float(mat->state.color.greenF()),
+ float(mat->state.color.blueF()),
+ float(mat->state.color.alphaF()) };
+ memcpy(buf->data() + 64, c, 16);
+
+ const QSize s = mat->state.texture->textureSize();
+ float textureSize[2] = { 1.0f / s.width(), 1.0f / s.height() };
+ memcpy(buf->data() + 80, textureSize, 8);
+
+ return true;
+}
+
+void NoisyShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture,
+ QSGMaterial *newMaterial, QSGMaterial *)
+{
+ Q_UNUSED(state);
+ Q_UNUSED(binding);
+
+ NoisyMaterial *mat = static_cast<NoisyMaterial *>(newMaterial);
+ *texture = mat->state.texture;
+}
+
NoisyNode::NoisyNode(QQuickWindow *window)
{
// Make some noise...
@@ -123,10 +173,9 @@ NoisyNode::NoisyNode(QQuickWindow *window)
t->setHorizontalWrapMode(QSGTexture::Repeat);
t->setVerticalWrapMode(QSGTexture::Repeat);
- QSGSimpleMaterial<NoisyMaterial> *m = NoisyShader::createMaterial();
- m->state()->texture = t;
- m->state()->color = QColor::fromRgbF(0.95, 0.95, 0.97);
- m->setFlag(QSGMaterial::Blending);
+ NoisyMaterial *m = new NoisyMaterial;
+ m->state.texture = t;
+ m->state.color = QColor::fromRgbF(0.95, 0.95, 0.97);
setMaterial(m);
setFlag(OwnsMaterial, true);
diff --git a/examples/quick/scenegraph/graph/shaders/compile.bat b/examples/quick/scenegraph/graph/shaders/compile.bat
new file mode 100644
index 0000000000..4ec3f2ec8e
--- /dev/null
+++ b/examples/quick/scenegraph/graph/shaders/compile.bat
@@ -0,0 +1,54 @@
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::
+:: Copyright (C) 2019 The Qt Company Ltd.
+:: Contact: https://www.qt.io/licensing/
+::
+:: This file is part of the examples of the Qt Toolkit.
+::
+:: $QT_BEGIN_LICENSE:BSD$
+:: Commercial License Usage
+:: Licensees holding valid commercial Qt licenses may use this file in
+:: accordance with the commercial license agreement provided with the
+:: Software or, alternatively, in accordance with the terms contained in
+:: a written agreement between you and The Qt Company. For licensing terms
+:: and conditions see https://www.qt.io/terms-conditions. For further
+:: information use the contact form at https://www.qt.io/contact-us.
+::
+:: BSD License Usage
+:: Alternatively, you may use this file under the terms of the BSD license
+:: as follows:
+::
+:: "Redistribution and use in source and binary forms, with or without
+:: modification, are permitted provided that the following conditions are
+:: met:
+:: * Redistributions of source code must retain the above copyright
+:: notice, this list of conditions and the following disclaimer.
+:: * Redistributions in binary form must reproduce the above copyright
+:: notice, this list of conditions and the following disclaimer in
+:: the documentation and/or other materials provided with the
+:: distribution.
+:: * Neither the name of The Qt Company Ltd nor the names of its
+:: contributors may be used to endorse or promote products derived
+:: from this software without specific prior written permission.
+::
+::
+:: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+:: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+:: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+:: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+:: OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+:: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+:: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+:: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+:: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+:: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+:: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+::
+:: $QT_END_LICENSE$
+::
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+
+qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -o noisy.vert.qsb noisy.vert
+qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -o noisy.frag.qsb noisy.frag
+qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -o line.vert.qsb line.vert
+qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -o line.frag.qsb line.frag
diff --git a/examples/quick/scenegraph/graph/shaders/line.frag b/examples/quick/scenegraph/graph/shaders/line.frag
new file mode 100644
index 0000000000..44b5b24c94
--- /dev/null
+++ b/examples/quick/scenegraph/graph/shaders/line.frag
@@ -0,0 +1,21 @@
+#version 440
+
+layout(location = 0) in float vT;
+
+layout(location = 0) out vec4 fragColor;
+
+layout(std140, binding = 0) uniform buf {
+ mat4 qt_Matrix;
+ vec4 color;
+ float qt_Opacity;
+ float size;
+ float spread;
+};
+
+#define PI 3.14159265358979323846
+
+void main(void)
+{
+ float tt = smoothstep(spread, 1.0, sin(vT * PI));
+ fragColor = color * qt_Opacity * tt;
+}
diff --git a/examples/quick/scenegraph/graph/shaders/line.frag.qsb b/examples/quick/scenegraph/graph/shaders/line.frag.qsb
new file mode 100644
index 0000000000..7efcd94c37
--- /dev/null
+++ b/examples/quick/scenegraph/graph/shaders/line.frag.qsb
Binary files differ
diff --git a/examples/quick/scenegraph/graph/shaders/line.fsh b/examples/quick/scenegraph/graph/shaders/line.fsh
deleted file mode 100644
index 77e05a2d15..0000000000
--- a/examples/quick/scenegraph/graph/shaders/line.fsh
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-uniform lowp vec4 color;
-uniform lowp float qt_Opacity;
-uniform lowp float spread;
-
-varying lowp float vT;
-
-#define PI 3.14159265358979323846
-
-void main(void)
-{
- lowp float tt = smoothstep(spread, 1.0, sin(vT * PI));
-
- gl_FragColor = color * qt_Opacity * tt;
-}
diff --git a/examples/quick/scenegraph/graph/shaders/line.vert b/examples/quick/scenegraph/graph/shaders/line.vert
new file mode 100644
index 0000000000..eac4273f0a
--- /dev/null
+++ b/examples/quick/scenegraph/graph/shaders/line.vert
@@ -0,0 +1,25 @@
+#version 440
+
+layout(location = 0) in vec4 pos;
+layout(location = 1) in float t;
+
+layout(location = 0) out float vT;
+
+layout(std140, binding = 0) uniform buf {
+ mat4 qt_Matrix;
+ vec4 color;
+ float qt_Opacity;
+ float size;
+ float spread;
+};
+
+out gl_PerVertex { vec4 gl_Position; };
+
+void main(void)
+{
+ vec4 adjustedPos = pos;
+ adjustedPos.y += (t * size);
+ gl_Position = qt_Matrix * adjustedPos;
+
+ vT = t;
+}
diff --git a/examples/quick/scenegraph/graph/shaders/line.vert.qsb b/examples/quick/scenegraph/graph/shaders/line.vert.qsb
new file mode 100644
index 0000000000..c17b16960f
--- /dev/null
+++ b/examples/quick/scenegraph/graph/shaders/line.vert.qsb
Binary files differ
diff --git a/examples/quick/scenegraph/graph/shaders/line.vsh b/examples/quick/scenegraph/graph/shaders/line.vsh
deleted file mode 100644
index 4f00ab9e5d..0000000000
--- a/examples/quick/scenegraph/graph/shaders/line.vsh
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-attribute highp vec4 pos;
-attribute highp float t;
-
-uniform lowp float size;
-uniform highp mat4 qt_Matrix;
-
-varying lowp float vT;
-
-void main(void)
-{
- vec4 adjustedPos = pos;
- adjustedPos.y += (t * size);
- gl_Position = qt_Matrix * adjustedPos;
-
- vT = t;
-}
diff --git a/examples/quick/scenegraph/graph/shaders/noisy.frag b/examples/quick/scenegraph/graph/shaders/noisy.frag
new file mode 100644
index 0000000000..8cea9de02b
--- /dev/null
+++ b/examples/quick/scenegraph/graph/shaders/noisy.frag
@@ -0,0 +1,24 @@
+#version 440
+
+layout(location = 0) in vec2 vTexCoord;
+layout(location = 1) in vec2 vShadeCoord;
+
+layout(location = 0) out vec4 fragColor;
+
+layout(std140, binding = 0) uniform buf {
+ mat4 qt_Matrix;
+ vec4 color;
+ vec2 textureSize;
+ float qt_Opacity;
+};
+
+layout(binding = 1) uniform sampler2D qt_Texture;
+
+#define PI 3.14159265358979323846
+
+void main()
+{
+ float shade = texture(qt_Texture, vTexCoord).r * 0.05 - length(vec2(0.5, 0.4) - vShadeCoord) * 0.3;
+ vec4 c = vec4(color.xyz + shade, color.w);
+ fragColor = c * qt_Opacity;
+}
diff --git a/examples/quick/scenegraph/graph/shaders/noisy.frag.qsb b/examples/quick/scenegraph/graph/shaders/noisy.frag.qsb
new file mode 100644
index 0000000000..77f29bd253
--- /dev/null
+++ b/examples/quick/scenegraph/graph/shaders/noisy.frag.qsb
Binary files differ
diff --git a/examples/quick/scenegraph/graph/shaders/noisy.fsh b/examples/quick/scenegraph/graph/shaders/noisy.fsh
deleted file mode 100644
index 14ea675360..0000000000
--- a/examples/quick/scenegraph/graph/shaders/noisy.fsh
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-uniform sampler2D texture;
-uniform lowp float qt_Opacity;
-uniform lowp vec4 color;
-
-varying highp vec2 vTexCoord;
-varying lowp vec2 vShadeCoord;
-
-#define PI 3.14159265358979323846
-
-void main()
-{
- lowp float shade = texture2D(texture, vTexCoord).r * 0.05 - length(vec2(0.5, 0.4) - vShadeCoord) * 0.3;
- lowp vec4 c = vec4(color.xyz + shade, color.w);
- gl_FragColor = c * qt_Opacity;
-}
diff --git a/examples/quick/scenegraph/graph/shaders/noisy.vert b/examples/quick/scenegraph/graph/shaders/noisy.vert
new file mode 100644
index 0000000000..5728f2a02f
--- /dev/null
+++ b/examples/quick/scenegraph/graph/shaders/noisy.vert
@@ -0,0 +1,22 @@
+#version 440
+
+layout(location = 0) in vec4 aVertex;
+layout(location = 1) in vec2 aTexCoord;
+
+layout(location = 0) out vec2 vTexCoord;
+layout(location = 1) out vec2 vShadeCoord;
+
+layout(std140, binding = 0) uniform buf {
+ mat4 qt_Matrix;
+ vec4 color;
+ vec2 textureSize;
+ float qt_Opacity;
+};
+
+out gl_PerVertex { vec4 gl_Position; };
+
+void main() {
+ gl_Position = qt_Matrix * aVertex;
+ vTexCoord = aVertex.xy * textureSize;
+ vShadeCoord = aTexCoord;
+}
diff --git a/examples/quick/scenegraph/graph/shaders/noisy.vert.qsb b/examples/quick/scenegraph/graph/shaders/noisy.vert.qsb
new file mode 100644
index 0000000000..d405024983
--- /dev/null
+++ b/examples/quick/scenegraph/graph/shaders/noisy.vert.qsb
Binary files differ
diff --git a/examples/quick/scenegraph/graph/shaders/noisy.vsh b/examples/quick/scenegraph/graph/shaders/noisy.vsh
deleted file mode 100644
index 1f89dbcc29..0000000000
--- a/examples/quick/scenegraph/graph/shaders/noisy.vsh
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-attribute highp vec4 aVertex;
-attribute highp vec2 aTexCoord;
-
-uniform highp mat4 qt_Matrix;
-uniform highp vec2 textureSize;
-
-varying highp vec2 vTexCoord;
-varying lowp vec2 vShadeCoord;
-
-void main() {
- gl_Position = qt_Matrix * aVertex;
- vTexCoord = aVertex.xy * textureSize;
- vShadeCoord = aTexCoord;
-}