diff options
author | aavit <qt_aavit@ovi.com> | 2012-09-07 13:29:53 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-09-27 12:08:39 +0200 |
commit | 4fc4e7ed89c3085ae98c57dd80e6cd8cc61f6ee2 (patch) | |
tree | 0426f330789a67db260e5995172f0ba7ec9e8c59 /tests/manual/scenegraph_lancelot/data/shaders | |
parent | a49154a75005403185e3813d441fb3e1931af2a2 (diff) |
Added lancelot-based scenegraph rendering regression test
Change-Id: I6718d00ba96dc9c96dac82de4ded9228f6bfb990
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'tests/manual/scenegraph_lancelot/data/shaders')
41 files changed, 2007 insertions, 0 deletions
diff --git a/tests/manual/scenegraph_lancelot/data/shaders/activity/activity.qml b/tests/manual/scenegraph_lancelot/data/shaders/activity/activity.qml new file mode 100644 index 0000000000..d4ae526b5d --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/activity/activity.qml @@ -0,0 +1,35 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + id: text + anchors.centerIn: parent + font.pixelSize: 80 + text: "Shaderz!" + } + + ShaderEffectSource { + id: source + sourceItem: text + hideSource: effect.visible + } + + ShaderEffect { + id: effect + anchors.fill: text + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/basic/basic.qml b/tests/manual/scenegraph_lancelot/data/shaders/basic/basic.qml new file mode 100644 index 0000000000..f1bb03a4a9 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/basic/basic.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + ShaderEffect { + anchors.fill: parent; + fragmentShader: " + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, 1, 1); + } + " + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/culling/culling_1.qml b/tests/manual/scenegraph_lancelot/data/shaders/culling/culling_1.qml new file mode 100644 index 0000000000..47687918e0 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/culling/culling_1.qml @@ -0,0 +1,104 @@ +import QtQuick 2.0 + +Rectangle { + id: topLevel + width: 320 + height: 480 + ShaderEffectSource { + id: front + visible: false + smooth: true + sourceItem: Rectangle { + width: 256 + height: 64 + color: "cornflowerblue" + radius: 8 + Text { + anchors.centerIn: parent + text: "Front" + font.pixelSize: 48 + color: "white" + } + } + } + ShaderEffectSource { + id: back + visible: false + smooth: true + sourceItem: Rectangle { + width: 256 + height: 64 + color: "firebrick" + radius: 8 + Text { + anchors.centerIn: parent + text: "Back" + font.pixelSize: 48 + color: "white" + } + } + } + Column { + anchors.fill: parent + Repeater { + model: ListModel { + ListElement { + foo: "No culling" + bar: ShaderEffect.NoCulling + turned: false + } + ListElement { + foo: "Back-face culling" + bar: ShaderEffect.BackFaceCulling + turned: false + } + ListElement { + foo: "Front-face culling" + bar: ShaderEffect.FrontFaceCulling + turned: false + } + } + + Item{ + id: item_0000 + width: 320 + height: 120 + ShaderEffect { + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.margins: 10 + width: 200 + height: 100 + culling: model.bar + property variant frontSource: front + property variant backSource: back + fragmentShader: " + varying highp vec2 qt_TexCoord0; + uniform sampler2D frontSource; + uniform sampler2D backSource; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = gl_FrontFacing + ? texture2D(frontSource, qt_TexCoord0) + : texture2D(backSource, qt_TexCoord0); + }" + transform: Rotation { + origin.x: 200 + origin.y: 180 - 120 * index + axis { x: 0; y: 1; z: 0 } + angle: (turned == true) ? 180 : 0 + + } + } + Text { + font.pointSize: 10 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.margins: 5 + text: foo + } + } + } + } +} + diff --git a/tests/manual/scenegraph_lancelot/data/shaders/culling/culling_2.qml b/tests/manual/scenegraph_lancelot/data/shaders/culling/culling_2.qml new file mode 100644 index 0000000000..a6fcc260cd --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/culling/culling_2.qml @@ -0,0 +1,103 @@ +import QtQuick 2.0 + +Rectangle { + id: topLevel + width: 320 + height: 480 + ShaderEffectSource { + id: front + visible: false + smooth: true + sourceItem: Rectangle { + width: 256 + height: 64 + color: "cornflowerblue" + radius: 8 + Text { + anchors.centerIn: parent + text: "Front" + font.pixelSize: 48 + color: "white" + } + } + } + ShaderEffectSource { + id: back + visible: false + smooth: true + sourceItem: Rectangle { + width: 256 + height: 64 + color: "firebrick" + radius: 8 + Text { + anchors.centerIn: parent + text: "Back" + font.pixelSize: 48 + color: "white" + } + } + } + Column { + anchors.fill: parent + Repeater { + model: ListModel { + ListElement { + foo: "No culling" + bar: ShaderEffect.NoCulling + turned: true + } + ListElement { + foo: "Back-face culling" + bar: ShaderEffect.BackFaceCulling + turned: true + } + ListElement { + foo: "Front-face culling" + bar: ShaderEffect.FrontFaceCulling + turned: true + } + } + + Item{ + id: item_0000 + width: 320 + height: 120 + ShaderEffect{ + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.margins: 10 + width: 200 + height: 100 + culling: model.bar + property variant frontSource: front + property variant backSource: back + fragmentShader: " + varying highp vec2 qt_TexCoord0; + uniform sampler2D frontSource; + uniform sampler2D backSource; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = gl_FrontFacing + ? texture2D(frontSource, qt_TexCoord0) + : texture2D(backSource, qt_TexCoord0); + }" + transform: Rotation { + origin.x: 100 + origin.y: 180 - 120 * index + axis { x: 0; y: 1; z: 0 } + angle: (turned == true) ? 180 : 0 + + } + } + Text { + font.pointSize: 10 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.margins: 5 + text: foo + } + } + } + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/attributes.qml b/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/attributes.qml new file mode 100644 index 0000000000..17d9aadf95 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/attributes.qml @@ -0,0 +1,65 @@ +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 480 + + Text { + id: text + font.pixelSize: 80 + text: "Shaderz!" + } + + ShaderEffectSource { + id: source + sourceItem: text + hideSource: true + smooth: true + } + Column { + ShaderEffect { + width: 320 + height: 160 + property variant source: source + vertexShader: " + uniform highp mat4 qt_Matrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 qt_TexCoord0; + void main() { + gl_Position = qt_Matrix * qt_Vertex; + qt_TexCoord0 = qt_MultiTexCoord0; + }" + } + ShaderEffect { + width: 320 + height: 160 + property variant source: source + vertexShader: " + attribute highp vec2 qt_MultiTexCoord0; + uniform highp mat4 qt_Matrix; + attribute highp vec4 qt_Vertex; + varying highp vec2 qt_TexCoord0; + void main() { + gl_Position = qt_Matrix * qt_Vertex; + qt_TexCoord0 = qt_MultiTexCoord0; + }" + } + ShaderEffect { + width: 320 + height: 160 + property variant source: source + vertexShader: " + attribute highp vec2 qt_MultiTexCoord0; + uniform highp mat4 qt_Matrix; + attribute highp vec4 qt_Vertex; + varying highp vec2 qt_TexCoord0; + uniform highp float width; + uniform highp float height; + void main() { + gl_Position = qt_Matrix * qt_Vertex; + qt_TexCoord0 = qt_Vertex.xy / vec2(width, height); + }" + } + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_1.qml b/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_1.qml new file mode 100644 index 0000000000..ddea979124 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_1.qml @@ -0,0 +1,60 @@ +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 480 + color: "skyblue" + ShaderEffect { + anchors.centerIn: parent + width: 16 * 16 + height: 24 * 16 + property variant source: ShaderEffectSource { + sourceItem: Rectangle { + width: 22 * 20 + height: 16 * 20 + color: "#EF2B2D" + Rectangle { + y: 6 * 20 + height: 4 * 20 + width: 22 * 20 + color: "white" + } + Rectangle { + x: 6 * 20 + width: 4 * 20 + height: 16 * 20 + color: "white" + } + Rectangle { + y: 7 * 20 + height: 2 * 20 + width: 22 * 20 + color: "#002868" + } + Rectangle { + x: 7 * 20 + width: 2 * 20 + height: 16 * 20 + color: "#002868" + } + } + smooth: true + } + vertexShader: " + uniform highp mat4 qt_Matrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 qt_TexCoord0; + void main() { + highp vec4 pos = qt_Vertex; + pos.x += sin(qt_Vertex.y * 0.02) * 20.; + pos.y += sin(qt_Vertex.x * 0.02) * 20.; + gl_Position = qt_Matrix * pos; + qt_TexCoord0 = qt_MultiTexCoord0; + }" + mesh: GridMesh { + property int r: 1 + resolution: Qt.size(r, r) + } + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_16.qml b/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_16.qml new file mode 100644 index 0000000000..971cda4f55 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_16.qml @@ -0,0 +1,60 @@ +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 480 + color: "skyblue" + ShaderEffect { + anchors.centerIn: parent + width: 16 * 16 + height: 24 * 16 + property variant source: ShaderEffectSource { + sourceItem: Rectangle { + width: 22 * 20 + height: 16 * 20 + color: "#EF2B2D" + Rectangle { + y: 6 * 20 + height: 4 * 20 + width: 22 * 20 + color: "white" + } + Rectangle { + x: 6 * 20 + width: 4 * 20 + height: 16 * 20 + color: "white" + } + Rectangle { + y: 7 * 20 + height: 2 * 20 + width: 22 * 20 + color: "#002868" + } + Rectangle { + x: 7 * 20 + width: 2 * 20 + height: 16 * 20 + color: "#002868" + } + } + smooth: true + } + vertexShader: " + uniform highp mat4 qt_Matrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 qt_TexCoord0; + void main() { + highp vec4 pos = qt_Vertex; + pos.x += sin(qt_Vertex.y * 0.02) * 20.; + pos.y += sin(qt_Vertex.x * 0.02) * 20.; + gl_Position = qt_Matrix * pos; + qt_TexCoord0 = qt_MultiTexCoord0; + }" + mesh: GridMesh { + property int r: 16 + resolution: Qt.size(r, r) + } + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_2.qml b/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_2.qml new file mode 100644 index 0000000000..d301ef089c --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_2.qml @@ -0,0 +1,60 @@ +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 480 + color: "skyblue" + ShaderEffect{ + anchors.centerIn: parent + width: 16 * 16 + height: 24 * 16 + property variant source: ShaderEffectSource { + sourceItem: Rectangle { + width: 22 * 20 + height: 16 * 20 + color: "#EF2B2D" + Rectangle { + y: 6 * 20 + height: 4 * 20 + width: 22 * 20 + color: "white" + } + Rectangle { + x: 6 * 20 + width: 4 * 20 + height: 16 * 20 + color: "white" + } + Rectangle { + y: 7 * 20 + height: 2 * 20 + width: 22 * 20 + color: "#002868" + } + Rectangle { + x: 7 * 20 + width: 2 * 20 + height: 16 * 20 + color: "#002868" + } + } + smooth: true + } + vertexShader: " + uniform highp mat4 qt_Matrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 qt_TexCoord0; + void main() { + highp vec4 pos = qt_Vertex; + pos.x += sin(qt_Vertex.y * 0.02) * 20.; + pos.y += sin(qt_Vertex.x * 0.02) * 20.; + gl_Position = qt_Matrix * pos; + qt_TexCoord0 = qt_MultiTexCoord0; + }" + mesh: GridMesh { + property int r: 2 + resolution: Qt.size(r, r) + } + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_4.qml b/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_4.qml new file mode 100644 index 0000000000..0043282efd --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_4.qml @@ -0,0 +1,60 @@ +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 480 + color: "skyblue" + ShaderEffect { + anchors.centerIn: parent + width: 16 * 16 + height: 24 * 16 + property variant source: ShaderEffectSource { + sourceItem: Rectangle { + width: 22 * 20 + height: 16 * 20 + color: "#EF2B2D" + Rectangle { + y: 6 * 20 + height: 4 * 20 + width: 22 * 20 + color: "white" + } + Rectangle { + x: 6 * 20 + width: 4 * 20 + height: 16 * 20 + color: "white" + } + Rectangle { + y: 7 * 20 + height: 2 * 20 + width: 22 * 20 + color: "#002868" + } + Rectangle { + x: 7 * 20 + width: 2 * 20 + height: 16 * 20 + color: "#002868" + } + } + smooth: true + } + vertexShader: " + uniform highp mat4 qt_Matrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 qt_TexCoord0; + void main() { + highp vec4 pos = qt_Vertex; + pos.x += sin(qt_Vertex.y * 0.02) * 20.; + pos.y += sin(qt_Vertex.x * 0.02) * 20.; + gl_Position = qt_Matrix * pos; + qt_TexCoord0 = qt_MultiTexCoord0; + }" + mesh: GridMesh { + property int r: 4 + resolution: Qt.size(r, r) + } + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_8.qml b/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_8.qml new file mode 100644 index 0000000000..f9427a1f16 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/gridmesh/resolution_8.qml @@ -0,0 +1,60 @@ +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 480 + color: "skyblue" + ShaderEffect { + anchors.centerIn: parent + width: 16 * 16 + height: 24 * 16 + property variant source: ShaderEffectSource { + sourceItem: Rectangle { + width: 22 * 20 + height: 16 * 20 + color: "#EF2B2D" + Rectangle { + y: 6 * 20 + height: 4 * 20 + width: 22 * 20 + color: "white" + } + Rectangle { + x: 6 * 20 + width: 4 * 20 + height: 16 * 20 + color: "white" + } + Rectangle { + y: 7 * 20 + height: 2 * 20 + width: 22 * 20 + color: "#002868" + } + Rectangle { + x: 7 * 20 + width: 2 * 20 + height: 16 * 20 + color: "#002868" + } + } + smooth: true + } + vertexShader: " + uniform highp mat4 qt_Matrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 qt_TexCoord0; + void main() { + highp vec4 pos = qt_Vertex; + pos.x += sin(qt_Vertex.y * 0.02) * 20.; + pos.y += sin(qt_Vertex.x * 0.02) * 20.; + gl_Position = qt_Matrix * pos; + qt_TexCoord0 = qt_MultiTexCoord0; + }" + mesh: GridMesh { + property int r: 8 + resolution: Qt.size(r, r) + } + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/hiddensource/hiddensource_1.qml b/tests/manual/scenegraph_lancelot/data/shaders/hiddensource/hiddensource_1.qml new file mode 100644 index 0000000000..83469531b1 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/hiddensource/hiddensource_1.qml @@ -0,0 +1,64 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Rectangle { + id: draggee + width: 200 + height: 80 + x: 20 + y: 15 + gradient: Gradient { + GradientStop { position: 0.0; color: "steelBlue" } + GradientStop { position: 0.49; color: "white" } + GradientStop { position: 0.5; color: "gray" } + GradientStop { position: 1.0; color: "darkGray" } + } + radius: 20 + border.width: 2 + border.color: "black" + Text { + anchors.centerIn: parent + font.pixelSize: 40 + text: "Position 1" + } + } + + ShaderEffectSource { + id: source + sourceItem: draggee + hideSource: true + property real margins: 6 + sourceRect: Qt.rect(-margins, -margins, sourceItem.width + 2 * margins, sourceItem.height + 2 * margins) + smooth: true + } + + ShaderEffect{ + id: effect + anchors.fill: source.sourceItem + anchors.margins: -source.margins + property variant source: source + property variant offset: Qt.size(4 / width, 4 / height) + property variant delta: Qt.size(0.5 / width, 0.5 / height) + + fragmentShader: " + uniform lowp sampler2D source; + uniform highp vec2 offset; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + highp vec2 delta2 = vec2(delta.x, -delta.y); + lowp float shadow = 0.25 * (texture2D(source, qt_TexCoord0 - offset + delta).a + + texture2D(source, qt_TexCoord0 - offset - delta).a + + texture2D(source, qt_TexCoord0 - offset + delta2).a + + texture2D(source, qt_TexCoord0 - offset - delta2).a); + lowp vec4 color = texture2D(source, qt_TexCoord0); + gl_FragColor = mix(vec4(vec3(0.), 0.5 * shadow), color, color.a); + } + " + } +} + diff --git a/tests/manual/scenegraph_lancelot/data/shaders/hiddensource/hiddensource_2.qml b/tests/manual/scenegraph_lancelot/data/shaders/hiddensource/hiddensource_2.qml new file mode 100644 index 0000000000..160b89168e --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/hiddensource/hiddensource_2.qml @@ -0,0 +1,65 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Rectangle { + id: draggee + width: 200 + height: 80 + x: 100 + y: 360 + gradient: Gradient { + GradientStop { position: 0.0; color: "steelBlue" } + GradientStop { position: 0.49; color: "white" } + GradientStop { position: 0.5; color: "gray" } + GradientStop { position: 1.0; color: "darkGray" } + } + radius: 20 + border.width: 2 + border.color: "black" + Text { + anchors.centerIn: parent + font.pixelSize: 40 + text: "Position 2" + } + } + + ShaderEffectSource { + id: source + sourceItem: draggee + hideSource: true + property real margins: 6 + sourceRect: Qt.rect(-margins, -margins, sourceItem.width + 2 * margins, sourceItem.height + 2 * margins) + smooth: true + } + + ShaderEffect{ + id: effect + anchors.fill: source.sourceItem + anchors.margins: -source.margins + property variant source: source + property variant offset: Qt.size(4 / width, 4 / height) + property variant delta: Qt.size(0.5 / width, 0.5 / height) + + fragmentShader: " + uniform lowp sampler2D source; + uniform highp vec2 offset; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + highp vec2 delta2 = vec2(delta.x, -delta.y); + lowp float shadow = 0.25 * (texture2D(source, qt_TexCoord0 - offset + delta).a + + texture2D(source, qt_TexCoord0 - offset - delta).a + + texture2D(source, qt_TexCoord0 - offset + delta2).a + + texture2D(source, qt_TexCoord0 - offset - delta2).a); + lowp vec4 color = texture2D(source, qt_TexCoord0); + gl_FragColor = mix(vec4(vec3(0.), 0.5 * shadow), color, color.a); + } + " + } +} + + diff --git a/tests/manual/scenegraph_lancelot/data/shaders/hiddensource/unhidden_1.qml b/tests/manual/scenegraph_lancelot/data/shaders/hiddensource/unhidden_1.qml new file mode 100644 index 0000000000..566edddedb --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/hiddensource/unhidden_1.qml @@ -0,0 +1,64 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Rectangle { + id: draggee + width: 200 + height: 80 + x: 20 + y: 15 + gradient: Gradient { + GradientStop { position: 0.0; color: "steelBlue" } + GradientStop { position: 0.49; color: "white" } + GradientStop { position: 0.5; color: "gray" } + GradientStop { position: 1.0; color: "darkGray" } + } + radius: 20 + border.width: 2 + border.color: "black" + Text { + anchors.centerIn: parent + font.pixelSize: 40 + text: "Position 1" + } + } + + ShaderEffectSource { + id: source + sourceItem: draggee + hideSource: false + property real margins: 6 + sourceRect: Qt.rect(-margins, -margins, sourceItem.width + 2 * margins, sourceItem.height + 2 * margins) + smooth: true + } + + ShaderEffect{ + id: effect + anchors.fill: source.sourceItem + anchors.margins: -source.margins + property variant source: source + property variant offset: Qt.size(4 / width, 4 / height) + property variant delta: Qt.size(0.5 / width, 0.5 / height) + + fragmentShader: " + uniform lowp sampler2D source; + uniform highp vec2 offset; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + highp vec2 delta2 = vec2(delta.x, -delta.y); + lowp float shadow = 0.25 * (texture2D(source, qt_TexCoord0 - offset + delta).a + + texture2D(source, qt_TexCoord0 - offset - delta).a + + texture2D(source, qt_TexCoord0 - offset + delta2).a + + texture2D(source, qt_TexCoord0 - offset - delta2).a); + lowp vec4 color = texture2D(source, qt_TexCoord0); + gl_FragColor = mix(vec4(vec3(0.), 0.5 * shadow), color, color.a); + } + " + } +} + diff --git a/tests/manual/scenegraph_lancelot/data/shaders/hiddensource/unhidden_2.qml b/tests/manual/scenegraph_lancelot/data/shaders/hiddensource/unhidden_2.qml new file mode 100644 index 0000000000..0b8038e9ee --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/hiddensource/unhidden_2.qml @@ -0,0 +1,66 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Rectangle { + id: draggee + width: 200 + height: 80 + x: 100 + y: 360 + gradient: Gradient { + GradientStop { position: 0.0; color: "steelBlue" } + GradientStop { position: 0.49; color: "white" } + GradientStop { position: 0.5; color: "gray" } + GradientStop { position: 1.0; color: "darkGray" } + } + radius: 20 + border.width: 2 + border.color: "black" + Text { + anchors.centerIn: parent + font.pixelSize: 40 + text: "Position 2" + } + } + + ShaderEffectSource { + id: source + sourceItem: draggee + hideSource: false + property real margins: 6 + sourceRect: Qt.rect(-margins, -margins, sourceItem.width + 2 * margins, sourceItem.height + 2 * margins) + smooth: true + } + + ShaderEffect{ + id: effect + anchors.fill: source.sourceItem + anchors.margins: -source.margins + property variant source: source + property variant offset: Qt.size(4 / width, 4 / height) + property variant delta: Qt.size(0.5 / width, 0.5 / height) + + fragmentShader: " + uniform lowp sampler2D source; + uniform highp vec2 offset; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + highp vec2 delta2 = vec2(delta.x, -delta.y); + lowp float shadow = 0.25 * (texture2D(source, qt_TexCoord0 - offset + delta).a + + texture2D(source, qt_TexCoord0 - offset - delta).a + + texture2D(source, qt_TexCoord0 - offset + delta2).a + + texture2D(source, qt_TexCoord0 - offset - delta2).a); + lowp vec4 color = texture2D(source, qt_TexCoord0); + gl_FragColor = mix(vec4(vec3(0.), 0.5 * shadow), color, color.a); + } + " + } +} + + + diff --git a/tests/manual/scenegraph_lancelot/data/shaders/image/async.qml b/tests/manual/scenegraph_lancelot/data/shaders/image/async.qml new file mode 100644 index 0000000000..132f160a26 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/image/async.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Image { + id: image; + source: "./face-smile.png" + visible: false + asynchronous: true + } + + ShaderEffect { + anchors.fill: image + property variant source: image + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, 0, 1) + texture2D(source, qt_TexCoord0); + } + " + visible: image.status == Image.Ready + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/image/face-smile.png b/tests/manual/scenegraph_lancelot/data/shaders/image/face-smile.png Binary files differnew file mode 100644 index 0000000000..3d66d72578 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/image/face-smile.png diff --git a/tests/manual/scenegraph_lancelot/data/shaders/image/source.qml b/tests/manual/scenegraph_lancelot/data/shaders/image/source.qml new file mode 100644 index 0000000000..878eddeda5 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/image/source.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Image { + id: image; + source: "face-smile.png" + visible: false + } + + ShaderEffect { + anchors.fill: image + property variant source: image + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, 0, 1) + texture2D(source, qt_TexCoord0); + } + " + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/live/liveonce_1.qml b/tests/manual/scenegraph_lancelot/data/shaders/live/liveonce_1.qml new file mode 100644 index 0000000000..0383feaf91 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/live/liveonce_1.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + id: text + anchors.centerIn: parent + font.pixelSize: 80 + text: "Shaderz!" + visible: false + + Rectangle { + width: 50 + height: 50 + color: "red" + anchors.centerIn: parent + transform: Rotation { angle: 45 } + } + } + + ShaderEffectSource { + id: source + sourceItem: text + smooth: true + } + + ShaderEffect { + width: parent.width + height: parent.height / 2 + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(0, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/live/liveonce_2.qml b/tests/manual/scenegraph_lancelot/data/shaders/live/liveonce_2.qml new file mode 100644 index 0000000000..2e7074c65d --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/live/liveonce_2.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + id: text + anchors.centerIn: parent + font.pixelSize: 80 + text: "Shaderz!" + visible: false + + Rectangle { + width: 50 + height: 50 + color: "red" + anchors.centerIn: parent + transform: Rotation { angle: 90 } + } + } + + ShaderEffectSource { + id: source + sourceItem: text + smooth: true + } + + ShaderEffect { + width: parent.width + height: parent.height / 2 + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(0, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/live/livetwice_1.qml b/tests/manual/scenegraph_lancelot/data/shaders/live/livetwice_1.qml new file mode 100644 index 0000000000..3793e655c7 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/live/livetwice_1.qml @@ -0,0 +1,68 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + id: text + anchors.centerIn: parent + font.pixelSize: 80 + text: "Shaderz!" + visible: false + + Rectangle { + width: 50 + height: 50 + color: "red" + anchors.centerIn: parent + transform: Rotation{ angle: 45} + } + } + + ShaderEffectSource { + id: source1 + sourceItem: text + smooth: true + } + + ShaderEffectSource { + id: source2 + sourceItem: text + smooth: true + } + + ShaderEffect{ + width: parent.width + height: parent.height / 2 + + property variant source: source1 + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(1, qt_TexCoord0.y, 0, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } + + ShaderEffect { + y: parent.height / 2 + width: parent.width + height: parent.height / 2 + + property variant source: source2 + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(0, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } +} + diff --git a/tests/manual/scenegraph_lancelot/data/shaders/live/livetwice_2.qml b/tests/manual/scenegraph_lancelot/data/shaders/live/livetwice_2.qml new file mode 100644 index 0000000000..2d8a4b6c09 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/live/livetwice_2.qml @@ -0,0 +1,68 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + id: text + anchors.centerIn: parent + font.pixelSize: 80 + text: "Shaderz!" + visible: false + + Rectangle { + width: 50 + height: 50 + color: "red" + anchors.centerIn: parent + transform: Rotation{ angle: 90} + } + } + + ShaderEffectSource { + id: source1 + sourceItem: text + smooth: true + } + + ShaderEffectSource { + id: source2 + sourceItem: text + smooth: true + } + + ShaderEffect{ + width: parent.width + height: parent.height / 2 + + property variant source: source1 + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(1, qt_TexCoord0.y, 0, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } + + ShaderEffect { + y: parent.height / 2 + width: parent.width + height: parent.height / 2 + + property variant source: source2 + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(0, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } +} + diff --git a/tests/manual/scenegraph_lancelot/data/shaders/live/samesource.qml b/tests/manual/scenegraph_lancelot/data/shaders/live/samesource.qml new file mode 100644 index 0000000000..67e0cc36ad --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/live/samesource.qml @@ -0,0 +1,53 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + id: text + anchors.centerIn: parent + font.pixelSize: 80 + text: "Shaderz!" + visible: false + } + + ShaderEffectSource { + id: source + sourceItem: text + smooth: true + } + + ShaderEffect { + width: parent.width + height: parent.height / 2 + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(0, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } + + ShaderEffect { + width: parent.width + y: parent.height / 2 + height: parent.height / 2 + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, 1, 0, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/mimap/mimap_1.qml b/tests/manual/scenegraph_lancelot/data/shaders/mimap/mimap_1.qml new file mode 100644 index 0000000000..82d288ef9b --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/mimap/mimap_1.qml @@ -0,0 +1,31 @@ +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 480 + color: "black" + + Text { + id: text + anchors.fill: parent + font.pixelSize: 16 + text: "In the field of computer graphics, a shader is a set of software instructions which" + + " is used primarily to calculate rendering effects on graphics hardware with a high " + + "degree of flexibility. Shaders are used to program the graphics processing unit (GP" + + "U) programmable rendering pipeline, which has mostly superseded the fixed-function " + + "pipeline that allowed only common geometry transformation and pixel-shading functio" + + "ns; with shaders, customized effects can be used." + wrapMode: Text.Wrap + color: "yellow" + visible: false + } + + ShaderEffectSource { + anchors.fill: parent + sourceItem: text + smooth: true + mipmap: false + scale: 1.0 + + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/mimap/mimap_2.qml b/tests/manual/scenegraph_lancelot/data/shaders/mimap/mimap_2.qml new file mode 100644 index 0000000000..d234eb3ef2 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/mimap/mimap_2.qml @@ -0,0 +1,31 @@ +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 480 + color: "black" + + Text { + id: text + anchors.fill: parent + font.pixelSize: 16 + text: "In the field of computer graphics, a shader is a set of software instructions which" + + " is used primarily to calculate rendering effects on graphics hardware with a high " + + "degree of flexibility. Shaders are used to program the graphics processing unit (GP" + + "U) programmable rendering pipeline, which has mostly superseded the fixed-function " + + "pipeline that allowed only common geometry transformation and pixel-shading functio" + + "ns; with shaders, customized effects can be used." + wrapMode: Text.Wrap + color: "yellow" + visible: false + } + + ShaderEffectSource { + anchors.fill: parent + sourceItem: text + smooth: true + mipmap: true + scale: 1.0 + + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/mimap/mimap_3.qml b/tests/manual/scenegraph_lancelot/data/shaders/mimap/mimap_3.qml new file mode 100644 index 0000000000..229d61088d --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/mimap/mimap_3.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 480 + color: "black" + + Text { + id: text + anchors.fill: parent + font.pixelSize: 16 + text: "In the field of computer graphics, a shader is a set of software instructions which" + + " is used primarily to calculate rendering effects on graphics hardware with a high " + + "degree of flexibility. Shaders are used to program the graphics processing unit (GP" + + "U) programmable rendering pipeline, which has mostly superseded the fixed-function " + + "pipeline that allowed only common geometry transformation and pixel-shading functio" + + "ns; with shaders, customized effects can be used." + wrapMode: Text.Wrap + color: "yellow" + visible: false + } + + ShaderEffectSource { + anchors.fill: parent + sourceItem: text + smooth: true + mipmap: false + scale: 0.6 + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/mimap/mimap_4.qml b/tests/manual/scenegraph_lancelot/data/shaders/mimap/mimap_4.qml new file mode 100644 index 0000000000..01bca9616e --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/mimap/mimap_4.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +Rectangle { + width: 320 + height: 480 + color: "black" + + Text { + id: text + anchors.fill: parent + font.pixelSize: 16 + text: "In the field of computer graphics, a shader is a set of software instructions which" + + " is used primarily to calculate rendering effects on graphics hardware with a high " + + "degree of flexibility. Shaders are used to program the graphics processing unit (GP" + + "U) programmable rendering pipeline, which has mostly superseded the fixed-function " + + "pipeline that allowed only common geometry transformation and pixel-shading functio" + + "ns; with shaders, customized effects can be used." + wrapMode: Text.Wrap + color: "yellow" + visible: false + } + + ShaderEffectSource { + anchors.fill: parent + sourceItem: text + smooth: true + mipmap: true + scale: 0.6 + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/nesting/nesting.qml b/tests/manual/scenegraph_lancelot/data/shaders/nesting/nesting.qml new file mode 100644 index 0000000000..a1461aa0df --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/nesting/nesting.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width: 320 + height: 480 + + Text { + id: textItem + text: "Text Item" + visible: false + } + + ShaderEffect { + width: root.width / 2 + height: root.height / 2 + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + property variant source: ShaderEffectSource { + sourceItem: ShaderEffect { + width: root.width / 2 + height: root.height /2 + property variant source: ShaderEffectSource { sourceItem: textItem } + } + } + } +} + diff --git a/tests/manual/scenegraph_lancelot/data/shaders/recursive/recursive_1.qml b/tests/manual/scenegraph_lancelot/data/shaders/recursive/recursive_1.qml new file mode 100644 index 0000000000..43843c677b --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/recursive/recursive_1.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Rectangle { + id: foo + width: 200 + height: 200 + radius: 100 + anchors.centerIn: parent + gradient: Gradient { + GradientStop { position: 0; color: "red" } + GradientStop { position: 0.5; color: "white" } + GradientStop { position: 1; color: "blue" } + } + ShaderEffectSource { + id: buffer + anchors.fill: parent + sourceItem: foo + live: false + smooth: true + rotation: 45 + recursive: true + } + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/recursive/recursive_2.qml b/tests/manual/scenegraph_lancelot/data/shaders/recursive/recursive_2.qml new file mode 100644 index 0000000000..957131b4b7 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/recursive/recursive_2.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Rectangle { + id: foo + width: 200 + height: 200 + radius: 100 + anchors.centerIn: parent + gradient: Gradient { + GradientStop { position: 0; color: "red" } + GradientStop { position: 0.5; color: "white" } + GradientStop { position: 1; color: "blue" } + } + ShaderEffectSource { + id: buffer + anchors.fill: parent + sourceItem: foo + live: false + smooth: true + rotation: 90 + recursive: true + } + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/source/one-source.qml b/tests/manual/scenegraph_lancelot/data/shaders/source/one-source.qml new file mode 100644 index 0000000000..d57f7c5dfb --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/source/one-source.qml @@ -0,0 +1,35 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + id: text + anchors.centerIn: parent + font.pixelSize: 80 + text: "Shaderz!" + visible: false + } + + ShaderEffectSource { + id: source + sourceItem: text + smooth: true + } + + ShaderEffect { + anchors.fill: text; + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/source/rect.qml b/tests/manual/scenegraph_lancelot/data/shaders/source/rect.qml new file mode 100644 index 0000000000..46fa6f5583 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/source/rect.qml @@ -0,0 +1,54 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + id: text + anchors.centerIn: parent + font.pixelSize: 80 + text: "Shaderz!" + } + + ShaderEffectSource { + id: source + sourceItem: text + sourceRect: Qt.rect(rect.x - text.x, rect.y - text.y, rect.width, rect.height) + } + + ShaderEffect { + anchors.fill: rect + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } + + Rectangle { + id: rect + x: 100 + y: 100 + width: 100 + height: 100 + color: "transparent" + border.width: 2 + border.color: "red" + MouseArea { + anchors.fill: parent + drag.target: parent + drag.axis: Drag.XandYAxis + drag.minimumX: 0 + drag.maximumX: parent.parent.width - width + drag.minimumY: 0 + drag.maximumY: parent.parent.height - height + } + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/source/switch_1.qml b/tests/manual/scenegraph_lancelot/data/shaders/source/switch_1.qml new file mode 100644 index 0000000000..9df6b13c1e --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/source/switch_1.qml @@ -0,0 +1,61 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Rectangle { + id: rect1 + x: 10 + y: 10 + width: 80 + height: 80 + radius: 20 + color: "black" + } + + Rectangle { + id: rect2 + x: 100 + y: 10 + width: 80 + height: 80 + radius: 20 + color: "black" + } + + Rectangle { + id: rect3 + x: 190 + y: 10 + width: 80 + height: 80 + radius: 20 + color: "black" + } + + ShaderEffectSource { + id: source + property int counter + sourceItem: rect1 + hideSource: true + } + + ShaderEffect { + id: effect + anchors.fill: source.sourceItem + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } + + +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/source/switch_2.qml b/tests/manual/scenegraph_lancelot/data/shaders/source/switch_2.qml new file mode 100644 index 0000000000..f997630d30 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/source/switch_2.qml @@ -0,0 +1,61 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Rectangle { + id: rect1 + x: 10 + y: 10 + width: 80 + height: 80 + radius: 20 + color: "black" + } + + Rectangle { + id: rect2 + x: 100 + y: 10 + width: 80 + height: 80 + radius: 20 + color: "black" + } + + Rectangle { + id: rect3 + x: 190 + y: 10 + width: 80 + height: 80 + radius: 20 + color: "black" + } + + ShaderEffectSource { + id: source + property int counter + sourceItem: rect2 + hideSource: true + } + + ShaderEffect { + id: effect + anchors.fill: source.sourceItem + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } + + +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/source/switch_3.qml b/tests/manual/scenegraph_lancelot/data/shaders/source/switch_3.qml new file mode 100644 index 0000000000..0d3c1fc4ee --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/source/switch_3.qml @@ -0,0 +1,61 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Rectangle { + id: rect1 + x: 10 + y: 10 + width: 80 + height: 80 + radius: 20 + color: "black" + } + + Rectangle { + id: rect2 + x: 100 + y: 10 + width: 80 + height: 80 + radius: 20 + color: "black" + } + + Rectangle { + id: rect3 + x: 190 + y: 10 + width: 80 + height: 80 + radius: 20 + color: "black" + } + + ShaderEffectSource { + id: source + property int counter + sourceItem: rect3 + hideSource: true + } + + ShaderEffect { + id: effect + anchors.fill: source.sourceItem + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } + + +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/source/two-sources.qml b/tests/manual/scenegraph_lancelot/data/shaders/source/two-sources.qml new file mode 100644 index 0000000000..1fadabe5b6 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/source/two-sources.qml @@ -0,0 +1,57 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Rectangle { + id: rect; + anchors.centerIn: parent + width: 1 + height: 10 + visible: false + + gradient: Gradient { + GradientStop { position: 0; color: "#ff0000" } + GradientStop { position: 0.5; color: "#00ff00" } + GradientStop { position: 1; color: "#0000ff" } + } + } + + Text { + id: text + anchors.centerIn: parent + font.pixelSize: 80 + text: "Shaderz!" + visible: false + } + + ShaderEffectSource { + id: maskSource + sourceItem: text + smooth: true + } + + ShaderEffectSource { + id: colorSource + sourceItem: rect; + smooth: true + } + + ShaderEffect { + anchors.fill: text; + + property variant colorSource: colorSource + property variant maskSource: maskSource; + + fragmentShader: " + uniform lowp sampler2D maskSource; + uniform lowp sampler2D colorSource; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = texture2D(maskSource, qt_TexCoord0).a * texture2D(colorSource, qt_TexCoord0.yx); + } + " + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/source/visible_1.qml b/tests/manual/scenegraph_lancelot/data/shaders/source/visible_1.qml new file mode 100644 index 0000000000..7a3bf9fd36 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/source/visible_1.qml @@ -0,0 +1,40 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + id: text + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + font.pixelSize: 80 + text: "Shaderz!" + } + + ShaderEffectSource { + id: source + sourceItem: text + hideSource: true + } + + ShaderEffect { + id: effect + anchors.top: text.bottom + anchors.left: text.left + width: text.width + height: text.height + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/source/visible_2.qml b/tests/manual/scenegraph_lancelot/data/shaders/source/visible_2.qml new file mode 100644 index 0000000000..d60dbaee3d --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/source/visible_2.qml @@ -0,0 +1,40 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + id: text + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + font.pixelSize: 80 + text: "Shaderz!" + } + + ShaderEffectSource { + id: source + sourceItem: text + hideSource: false + } + + ShaderEffect { + id: effect + anchors.top: text.bottom + anchors.left: text.left + width: text.width + height: text.height + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/texture/size.qml b/tests/manual/scenegraph_lancelot/data/shaders/texture/size.qml new file mode 100644 index 0000000000..ab8db47009 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/texture/size.qml @@ -0,0 +1,46 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + ShaderEffectSource { + id: source + sourceItem: text + textureSize: Qt.size(text.width / 2, text.height / 2) + smooth: true + } + + ShaderEffect { + anchors.fill: text + + property variant source: source + property variant textureSize: source.textureSize + property color color: "black" + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + uniform highp vec2 textureSize; + uniform lowp vec4 color; + uniform lowp float qt_Opacity; + void main() { + highp vec2 dx = vec2(0.5 / textureSize.x, 0.); + highp vec2 dy = vec2(0., 0.5 / textureSize.y); + gl_FragColor = color * 0.25 + * (texture2D(source, qt_TexCoord0 + dx + dy).a + + texture2D(source, qt_TexCoord0 + dx - dy).a + + texture2D(source, qt_TexCoord0 - dx + dy).a + + texture2D(source, qt_TexCoord0 - dx - dy).a); + } + " + } + + Text { + id: text + anchors.centerIn: parent + font.pixelSize: 80 + text: "Shaderz!" + color: "white" + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/tree/hiddentree_1.qml b/tests/manual/scenegraph_lancelot/data/shaders/tree/hiddentree_1.qml new file mode 100644 index 0000000000..ad4cce9546 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/tree/hiddentree_1.qml @@ -0,0 +1,32 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Rectangle { + visible: false + Item { + Text { + id: text + font.pixelSize: 80 + text: "Shaderz!" + color: "black" + Rectangle { + width: 50 + height: 50 + color: "red" + anchors.centerIn: parent + transform: Rotation { angle: 45 } + } + } + } + } + + ShaderEffectSource { + width: text.width + height: text.height + anchors.centerIn: parent + sourceItem: text + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/tree/hiddentree_2.qml b/tests/manual/scenegraph_lancelot/data/shaders/tree/hiddentree_2.qml new file mode 100644 index 0000000000..834c69f93a --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/tree/hiddentree_2.qml @@ -0,0 +1,32 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Rectangle { + visible: false + Item { + Text { + id: text + font.pixelSize: 80 + text: "Shaderz!" + color: "black" + Rectangle { + width: 50 + height: 50 + color: "red" + anchors.centerIn: parent + transform: Rotation { angle: 90 } + } + } + } + } + + ShaderEffectSource { + width: text.width + height: text.height + anchors.centerIn: parent + sourceItem: text + } +} diff --git a/tests/manual/scenegraph_lancelot/data/shaders/wrap/modes.qml b/tests/manual/scenegraph_lancelot/data/shaders/wrap/modes.qml new file mode 100644 index 0000000000..c008114810 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/shaders/wrap/modes.qml @@ -0,0 +1,68 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Text { + id: text + anchors.centerIn: parent + font.pixelSize: 80 + text: "Shaderz!" + visible: false + } + + ShaderEffectSource { + id: clamp + sourceItem: text + smooth: true + wrapMode: ShaderEffectSource.ClampToEdge + } + + ShaderEffectSource { + id: hRepeat + sourceItem: text + smooth: true + wrapMode: ShaderEffectSource.RepeatHorizontally + } + + ShaderEffectSource { + id: vRepeat + sourceItem: text + smooth: true + wrapMode: ShaderEffectSource.RepeatVertically + } + + ShaderEffectSource { + id: repeat + sourceItem: text + smooth: true + wrapMode: ShaderEffectSource.Repeat + } + + ShaderEffect { + anchors.fill: parent + + property variant cyan: hRepeat + property variant magenta: vRepeat + property variant yellow: repeat + property variant black: clamp + + fragmentShader: " + uniform lowp sampler2D cyan; + uniform lowp sampler2D magenta; + uniform lowp sampler2D yellow; + uniform lowp sampler2D black; + varying highp vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + void main() { + highp vec2 t = qt_TexCoord0 * 3. - 1.; + lowp float c = texture2D(cyan, t + vec2(.05, .09)).a; + lowp float m = texture2D(magenta, t + vec2(.04, -.10)).a; + lowp float y = texture2D(yellow, t + vec2(-.10, .01)).a; + lowp float k = texture2D(black, t).a; + gl_FragColor = 1. - vec4(c + k, m + k, y + k, 0.); + } + " + } +} |