diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/render/gltexture/tst_gltexture.cpp | 38 | ||||
-rw-r--r-- | tests/auto/render/qray3d/tst_qray3d.cpp | 36 | ||||
-rw-r--r-- | tests/auto/render/qrenderstate/tst_qrenderstate.cpp | 8 | ||||
-rw-r--r-- | tests/manual/manual.pro | 1 | ||||
-rw-r--r-- | tests/manual/qtbug-76766/FrameGraph.qml | 140 | ||||
-rw-r--r-- | tests/manual/qtbug-76766/Material1.qml | 93 | ||||
-rw-r--r-- | tests/manual/qtbug-76766/Material2.qml | 105 | ||||
-rw-r--r-- | tests/manual/qtbug-76766/PostProcess.qml | 117 | ||||
-rw-r--r-- | tests/manual/qtbug-76766/SceneRoot.qml | 176 | ||||
-rw-r--r-- | tests/manual/qtbug-76766/expected_output.png | bin | 0 -> 22639 bytes | |||
-rw-r--r-- | tests/manual/qtbug-76766/main.cpp | 74 | ||||
-rw-r--r-- | tests/manual/qtbug-76766/main.qml | 76 | ||||
-rw-r--r-- | tests/manual/qtbug-76766/qml.qrc | 11 | ||||
-rw-r--r-- | tests/manual/qtbug-76766/qtbug-76766.pro | 10 | ||||
-rw-r--r-- | tests/manual/qtbug-76766/shaders.qrc | 6 | ||||
-rw-r--r-- | tests/manual/qtbug-76766/shaders/shader.frag | 11 | ||||
-rw-r--r-- | tests/manual/qtbug-76766/shaders/shader.vert | 36 |
17 files changed, 916 insertions, 22 deletions
diff --git a/tests/auto/render/gltexture/tst_gltexture.cpp b/tests/auto/render/gltexture/tst_gltexture.cpp index 8a8701f8e..e971078d0 100644 --- a/tests/auto/render/gltexture/tst_gltexture.cpp +++ b/tests/auto/render/gltexture/tst_gltexture.cpp @@ -864,6 +864,44 @@ private Q_SLOTS: // Cleanup texture.destroy(); } + + void checkPropertiesAfterLoadTextureDataFromImages() + { + // GIVEN + GLTexture texture; + TextureProperties props; + props.target = QAbstractTexture::TargetCubeMap; + props.format = QAbstractTexture::Automatic; + props.width = 1; + props.height = 1; + texture.setProperties(props); + QVector<GLTexture::Image> images; + // test a image texture data generator whose url is invalid + QImageTextureDataFunctorPtr gen = QImageTextureDataFunctorPtr::create(QUrl(), true); + images.push_back({gen, 0, 0, QAbstractTexture::CubeMapPositiveX}); + texture.setImages(images); + + // WHEN + texture.createOrUpdateGLTexture(); + + // THEN + QCOMPARE(texture.properties().format, QAbstractTexture::Automatic); + + // WHEN + // test a image texture data generator whose url is valid + gen = QImageTextureDataFunctorPtr::create(QUrl("qrc:/image.jpg"), true); + images.clear(); + images.push_back({gen, 0, 0, QAbstractTexture::CubeMapPositiveX}); + texture.setImages(images); + texture.createOrUpdateGLTexture(); + + // THEN + QVERIFY(texture.properties().format != QAbstractTexture::Automatic); + QVERIFY(texture.properties().format != QAbstractTexture::NoFormat); + + // Cleanup + texture.destroy(); + } }; QTEST_MAIN(tst_GLTexture); diff --git a/tests/auto/render/qray3d/tst_qray3d.cpp b/tests/auto/render/qray3d/tst_qray3d.cpp index dfc2a7396..ef0702a0a 100644 --- a/tests/auto/render/qray3d/tst_qray3d.cpp +++ b/tests/auto/render/qray3d/tst_qray3d.cpp @@ -108,23 +108,23 @@ void tst_QRay3D::create_data() // non-normalized direction vectors QTest::newRow("line on x-axis from origin - B") << Vector3D() - << Vector3D(2.0f, 0.0f, 0.0f); + << Vector3D(2.0f, 0.0f, 0.0f).normalized(); QTest::newRow("line parallel -z-axis from 3,3,3 - B") << Vector3D(3.0f, 3.0f, 3.0f) - << Vector3D(0.0f, 0.0f, -0.7f); + << Vector3D(0.0f, 0.0f, -0.7f).normalized(); QTest::newRow("vertical line (parallel to y-axis) - B") << Vector3D(0.5f, 0.0f, 0.5f) - << Vector3D(0.0f, 5.3f, 0.0f); + << Vector3D(0.0f, 5.3f, 0.0f).normalized(); QTest::newRow("equidistant from all 3 axes - B") << Vector3D(0.5f, 0.0f, 0.5f) - << Vector3D(1.0f, 1.0f, 1.0f); + << Vector3D(1.0f, 1.0f, 1.0f).normalized(); QTest::newRow("negative direction") << Vector3D(-3.0f, -3.0f, -3.0f) - << Vector3D(-1.2f, -1.8f, -2.4f); + << Vector3D(-1.2f, -1.8f, -2.4f).normalized(); } void tst_QRay3D::create() @@ -203,32 +203,32 @@ void tst_QRay3D::point_data() QTest::newRow("line on x-axis from origin") << Vector3D() << Vector3D(2.0f, 0.0f, 0.0f) - << Vector3D(1.2f, 0.0f, 0.0f) - << Vector3D(-14.4f, 0.0f, 0.0f); + << Vector3D(0.6f, 0.0f, 0.0f) + << Vector3D(-7.2f, 0.0f, 0.0f); QTest::newRow("line parallel -z-axis from 3,3,3") << Vector3D(3.0f, 3.0f, 3.0f) << Vector3D(0.0f, 0.0f, -0.7f) - << Vector3D(3.0f, 3.0f, 2.58f) - << Vector3D(3.0f, 3.0f, 8.04f); + << Vector3D(3.0f, 3.0f, 2.4f) + << Vector3D(3.0f, 3.0f, 10.2f); QTest::newRow("vertical line (parallel to y-axis)") << Vector3D(0.5f, 0.0f, 0.5f) << Vector3D(0.0f, 5.3f, 0.0f) - << Vector3D(0.5f, 3.18f, 0.5f) - << Vector3D(0.5f, -38.16f, 0.5f); + << Vector3D(0.5f, 0.6f, 0.5f) + << Vector3D(0.5f, -7.2f, 0.5f); QTest::newRow("equidistant from all 3 axes") << Vector3D(0.5f, 0.0f, 0.5f) << Vector3D(1.0f, 1.0f, 1.0f) - << Vector3D(1.1f, 0.6f, 1.1f) - << Vector3D(-6.7f, -7.2f, -6.7f); + << Vector3D(0.84641f, 0.34641f, 0.84641f) + << Vector3D(-3.65692f, -4.15692f, -3.65692f); QTest::newRow("negative direction") << Vector3D(-3.0f, -3.0f, -3.0f) << Vector3D(-1.2f, -1.8f, -2.4f) - << Vector3D(-3.72f, -4.08f, -4.44f) - << Vector3D(5.64f, 9.96f, 14.28f); + << Vector3D(-3.22283f, -3.33425f, -3.44567f) + << Vector3D(-0.325987f, 1.01102f, 2.34803f); } void tst_QRay3D::point() @@ -475,7 +475,7 @@ void tst_QRay3D::transform() QVERIFY(fuzzyCompare(ray1.direction(), ray3.direction())); QVERIFY(fuzzyCompare(ray1.origin(), m * point)); - QVERIFY(fuzzyCompare(ray1.direction(), m.mapVector(direction))); + QVERIFY(fuzzyCompare(ray1.direction(), m.mapVector(direction).normalized())); } class tst_QRay3DProperties : public QObject @@ -503,7 +503,7 @@ void tst_QRay3D::properties() Qt3DRender::RayCasting::QRay3D r = qvariant_cast<Qt3DRender::RayCasting::QRay3D>(obj.property("ray")); QCOMPARE(r.origin(), Vector3D(1, 2, 3)); - QCOMPARE(r.direction(), Vector3D(4, 5, 6)); + QCOMPARE(r.direction(), Vector3D(4, 5, 6).normalized()); obj.setProperty("ray", QVariant::fromValue @@ -511,7 +511,7 @@ void tst_QRay3D::properties() r = qvariant_cast<Qt3DRender::RayCasting::QRay3D>(obj.property("ray")); QCOMPARE(r.origin(), Vector3D(-1, -2, -3)); - QCOMPARE(r.direction(), Vector3D(-4, -5, -6)); + QCOMPARE(r.direction(), Vector3D(-4, -5, -6).normalized()); } void tst_QRay3D::metaTypes() diff --git a/tests/auto/render/qrenderstate/tst_qrenderstate.cpp b/tests/auto/render/qrenderstate/tst_qrenderstate.cpp index 4dc850b25..596aa9553 100644 --- a/tests/auto/render/qrenderstate/tst_qrenderstate.cpp +++ b/tests/auto/render/qrenderstate/tst_qrenderstate.cpp @@ -187,8 +187,8 @@ private Q_SLOTS: // THEN RenderStateNode *backend1 = createBackendNode(frontend1); RenderStateNode *backend2 = createBackendNode(frontend2); - QVERIFY(backend1->mask() == mask); - QVERIFY(backend2->mask() == mask); + QVERIFY(backend1->type() == mask); + QVERIFY(backend2->type() == mask); QVERIFY(backend1->impl() != backend2->impl()); // WHEN @@ -272,8 +272,8 @@ private Q_SLOTS: // THEN RenderStateNode *backend1 = createBackendNode(frontend1); RenderStateNode *backend2 = createBackendNode(frontend2); - QVERIFY(backend1->mask() == mask); - QVERIFY(backend2->mask() == mask); + QVERIFY(backend1->type() == mask); + QVERIFY(backend2->type() == mask); QVERIFY(backend1->impl() != backend2->impl()); // WHEN diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index 88e339561..07f7f9132 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -64,6 +64,7 @@ SUBDIRS += \ raster-cpp \ raster-qml \ qtbug-72236 \ + qtbug-76766 \ shader-image-qml qtHaveModule(multimedia): { diff --git a/tests/manual/qtbug-76766/FrameGraph.qml b/tests/manual/qtbug-76766/FrameGraph.qml new file mode 100644 index 000000000..0b096bc19 --- /dev/null +++ b/tests/manual/qtbug-76766/FrameGraph.qml @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt3D.Core 2.9 +import Qt3D.Render 2.9 + +RenderSurfaceSelector { + id: surfaceSelector + + readonly property Layer layer: Layer { + recursive: true + } + + property alias camera: cameraSelector.camera + property alias clearColor: clearBuffers.clearColor + property alias fbo : renderToFboSelector.target + + Viewport { + normalizedRect: Qt.rect(0.0, 0.0, 1.0, 1.0) + + // 1st: render scene to texture + RenderTargetSelector { + id : renderToFboSelector + + RenderStateSet { + renderStates: [ + MultiSampleAntiAliasing {}, + DepthTest { + depthFunction: DepthTest.Less + }, + CullFace{ + mode: CullFace.Back + } + ] + + ClearBuffers { + id: clearBuffers + buffers: ClearBuffers.ColorDepthBuffer + NoDraw {} + } + + CameraSelector { + id: cameraSelector + + LayerFilter { + layers: [layer] + filterMode: LayerFilter.DiscardAllMatchingLayers + TechniqueFilter { + RenderPassFilter { + matchAny: FilterKey { name: "pass"; value: 0 } + } + SortPolicy { + sortTypes: [SortPolicy.BackToFront] + RenderPassFilter { + matchAny: FilterKey { name: "pass"; value: 1 } + } + } + } + } + + RenderStateSet { + renderStates: [ + DepthTest { + depthFunction: DepthTest.Always + } + ] + LayerFilter { + layers: [layer] + filterMode: LayerFilter.AcceptAnyMatchingLayers + TechniqueFilter { + RenderPassFilter { + matchAny: FilterKey { name: "pass"; value: 0 } + } + SortPolicy { + sortTypes: [SortPolicy.BackToFront] + RenderPassFilter { + matchAny: FilterKey { name: "pass"; value: 1 } + } + } + } + } + } + } + } + } + + RenderStateSet { + renderStates: [ + DepthTest {depthFunction: DepthTest.Always}, + BlendEquation {}, + BlendEquationArguments { + sourceRgb: BlendEquationArguments.One + sourceAlpha: BlendEquationArguments.One + destinationRgb: BlendEquationArguments.Zero + destinationAlpha: BlendEquationArguments.Zero + } + ] + + RenderPassFilter { + matchAny : FilterKey { name : "pass"; value : "final" } + } + } + } +} diff --git a/tests/manual/qtbug-76766/Material1.qml b/tests/manual/qtbug-76766/Material1.qml new file mode 100644 index 000000000..069d99c74 --- /dev/null +++ b/tests/manual/qtbug-76766/Material1.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt3D.Core 2.0 +import Qt3D.Render 2.0 + +Material { + id: root + + property color color: Qt.rgba(0.15, 0.35, 0.50, 1.0) + + parameters: [ + Parameter { name: "color"; value: Qt.vector3d(root.color.r, root.color.g, root.color.b) } + ] + + + effect: Effect { + property string vertex: "qrc:/shaders/shader.vert" + property string fragment: "qrc:/shaders/shader.frag" + + FilterKey { + id: forward + name: "renderingStyle" + value: "forward" + } + + ShaderProgram { + id: gl3Shader + vertexShaderCode: loadSource(parent.vertex) + fragmentShaderCode: loadSource(parent.fragment) + } + + techniques: [ + // OpenGL 3.1 + Technique { + filterKeys: [ forward ] + graphicsApiFilter { + api: GraphicsApiFilter.OpenGL + profile: GraphicsApiFilter.CoreProfile + majorVersion: 3 + minorVersion: 3 + } + renderPasses: RenderPass { + filterKeys: [ + FilterKey { + name: "pass" + value: 0 + } + ] + shaderProgram: gl3Shader + } + } + ] + } +} + + diff --git a/tests/manual/qtbug-76766/Material2.qml b/tests/manual/qtbug-76766/Material2.qml new file mode 100644 index 000000000..0af0ecb6c --- /dev/null +++ b/tests/manual/qtbug-76766/Material2.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt3D.Core 2.0 +import Qt3D.Render 2.0 + +Material { + id: root + + property color color: Qt.rgba(0.15, 0.35, 0.50, 1.0) + + parameters: [ + Parameter { name: "color"; value: Qt.vector3d(root.color.r, root.color.g, root.color.b) } + ] + + + effect: Effect { + property string vertex: "qrc:/shaders/shader.vert" + property string fragment: "qrc:/shaders/shader.frag" + + FilterKey { + id: forward + name: "renderingStyle" + value: "forward" + } + + ShaderProgram { + id: gl3Shader + vertexShaderCode: loadSource(parent.vertex) + fragmentShaderCode: loadSource(parent.fragment) + } + + techniques: [ + // OpenGL 3.1 + Technique { + filterKeys: [ forward ] + graphicsApiFilter { + api: GraphicsApiFilter.OpenGL + profile: GraphicsApiFilter.CoreProfile + majorVersion: 3 + minorVersion: 3 + } + renderPasses: [ + RenderPass { + filterKeys: [ + FilterKey { + name: "pass" + value: 1 + } + ] + shaderProgram: gl3Shader + renderStates: [ + NoDepthMask {}, + BlendEquation {}, + BlendEquationArguments { + sourceRgb: BlendEquationArguments.One + destinationRgb: BlendEquationArguments.One + sourceAlpha: BlendEquationArguments.Zero + destinationAlpha: BlendEquationArguments.One + } + ] + } + ] + } + ] + } +} + + diff --git a/tests/manual/qtbug-76766/PostProcess.qml b/tests/manual/qtbug-76766/PostProcess.qml new file mode 100644 index 000000000..cd4c9c0c6 --- /dev/null +++ b/tests/manual/qtbug-76766/PostProcess.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt3D.Core 2.9 +import Qt3D.Render 2.9 +import Qt3D.Extras 2.0 + +Entity { + id: root + + property Texture colorTexture + readonly property int samples : colorTexture ? colorTexture.samples : 1 + + Effect { + id: materialEffect + techniques : [ + // OpenGL 3.2 + Technique { + graphicsApiFilter { + api : GraphicsApiFilter.OpenGL + profile : GraphicsApiFilter.CoreProfile + minorVersion : 3 + majorVersion : 2 + } + + renderPasses : RenderPass { + filterKeys : FilterKey { name : "pass"; value : "final" } + + shaderProgram : ShaderProgram { + vertexShaderCode: + "#version 150 core + + in vec3 vertexPosition; + out vec2 texCoords; + + void main() { + texCoords = vec2(0.5) + vec2(0.5) * vertexPosition.xz; + gl_Position = vec4(vertexPosition.x, vertexPosition.z, 0.0, 1.0); + }" + fragmentShaderCode: + "#version 150 core + + uniform sampler2DMS source; + + in vec2 texCoords; + out vec4 fragColor; + + void main() { + vec4 c = vec4(0.0); + c += texelFetch(source, ivec2(gl_FragCoord), 0); + fragColor = vec4(c.rgb / max(c.a, 0.01), c.a); + }" + } + } + } + ] + } + + Material { + id: materialWithoutTexture + + parameters: [ + Parameter { name: "source"; value: colorTexture }, + Parameter { name: "samples"; value: root.samples } + ] + + effect: materialEffect + } + + PlaneMesh { + id: planeMesh + width: 2.0 + height: 2.0 + meshResolution: Qt.size(2, 2) + } + + components : [ + planeMesh, + materialWithoutTexture + ] +} diff --git a/tests/manual/qtbug-76766/SceneRoot.qml b/tests/manual/qtbug-76766/SceneRoot.qml new file mode 100644 index 000000000..6e34633b1 --- /dev/null +++ b/tests/manual/qtbug-76766/SceneRoot.qml @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt3D.Core 2.0 +import Qt3D.Render 2.0 +import Qt3D.Extras 2.0 +import Qt3D.Input 2.0 +import QtQuick 2.0 as QQ2 +import QtQuick 2.12 + + +Entity { + id: sceneRoot + + Camera { + id: camera + projectionType: CameraLens.OrthographicProjection + left: -2 + right: 2 + top: 2 + bottom: -2 + nearPlane: 0.1 + farPlane: 1000.0 + position: Qt.vector3d(0.0, 0.0, 1.0) + upVector: Qt.vector3d(0.0, 1.0, 0.0) + viewCenter: Qt.vector3d(0.0, 0.0, 0.0) + } + + RenderTarget { + id: renderTargetFBO + attachments : [ + RenderTargetOutput { + attachmentPoint : RenderTargetOutput.Color0 + texture : Texture2DMultisample { + id : colorAttachment + width : scene3d.width + height : scene3d.height + format : Texture.RGBA8_UNorm + generateMipMaps : false + samples: 1 + } + }, + RenderTargetOutput { + attachmentPoint : RenderTargetOutput.Depth + texture : Texture2DMultisample { + width : scene3d.width + height : scene3d.height + format : Texture.D32F + generateMipMaps : false + samples: 1 + } + } + ] + } + + components: [ + RenderSettings { + activeFrameGraph: FrameGraph { + id: framegraph + camera: camera + fbo: renderTargetFBO + } + renderPolicy: RenderSettings.Always + } + ] + + Entity { + id: firstPassEntities + + Entity { + components: [ + Transform { + translation: Qt.vector3d(0,0,-2) + }, + Material1 { + color: "red" + }, + SphereMesh { + } + ] + } + + + Entity { + components: [ + Transform { + translation: Qt.vector3d(1,0,-1) + }, + Material2 { + color: "green" + }, + SphereMesh { + } + ] + } + } + + Entity { + id: secondPassEntities + components: [framegraph.layer] + + Entity { + components: [ + Transform { + translation: Qt.vector3d(0,0,-4) + scale: 0.5 + }, + Material1 { + ColorAnimation on color { + from: "black" + to: "purple" + duration: 2000 + loops: Animation.Infinite + } + }, + SphereMesh { + } + ] + } + + + Entity { + components: [ + Transform { + translation: Qt.vector3d(1,0,-3) + scale: 0.5 + }, + Material2 { + color: "orange" + }, + SphereMesh { + } + ] + } + } + + PostProcess { + colorTexture: colorAttachment + } +} diff --git a/tests/manual/qtbug-76766/expected_output.png b/tests/manual/qtbug-76766/expected_output.png Binary files differnew file mode 100644 index 000000000..8f642e843 --- /dev/null +++ b/tests/manual/qtbug-76766/expected_output.png diff --git a/tests/manual/qtbug-76766/main.cpp b/tests/manual/qtbug-76766/main.cpp new file mode 100644 index 000000000..f9d49846a --- /dev/null +++ b/tests/manual/qtbug-76766/main.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQuickView> +#include <QOpenGLContext> + +void setSurfaceFormat() +{ + QSurfaceFormat format; +#ifdef QT_OPENGL_ES_2 + format.setRenderableType(QSurfaceFormat::OpenGLES); +#else + if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { + format.setVersion(4, 3); + format.setProfile(QSurfaceFormat::CoreProfile); + } +#endif + format.setDepthBufferSize(24); + format.setSamples(4); + format.setStencilBufferSize(8); + QSurfaceFormat::setDefaultFormat(format); +} + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + setSurfaceFormat(); + + QQuickView view; + + view.resize(1920, 1080); + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl("qrc:/main.qml")); + view.show(); + + return app.exec(); +} diff --git a/tests/manual/qtbug-76766/main.qml b/tests/manual/qtbug-76766/main.qml new file mode 100644 index 000000000..9b8f4b691 --- /dev/null +++ b/tests/manual/qtbug-76766/main.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Scene3D 2.12 +import Qt3D.Render 2.12 + +Item { + anchors.fill: parent + + Scene3D { + id: scene3d + anchors.fill: parent + focus: true + cameraAspectRatioMode: Scene3D.AutomaticAspectRatio + + SceneRoot { + id: root + } + } + + Image { + width: 400 + fillMode: Image.PreserveAspectFit + source: "qrc:/expected_output.png" + Text { + anchors.centerIn: parent + color: "white" + text: "This is the expected output" + } + Rectangle { + anchors.fill: parent + color: "transparent" + border { + color: "white" + width: 2 + } + } + } +} diff --git a/tests/manual/qtbug-76766/qml.qrc b/tests/manual/qtbug-76766/qml.qrc new file mode 100644 index 000000000..b1f8c2c21 --- /dev/null +++ b/tests/manual/qtbug-76766/qml.qrc @@ -0,0 +1,11 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>SceneRoot.qml</file> + <file>FrameGraph.qml</file> + <file>PostProcess.qml</file> + <file>Material1.qml</file> + <file>Material2.qml</file> + <file>expected_output.png</file> + </qresource> +</RCC> diff --git a/tests/manual/qtbug-76766/qtbug-76766.pro b/tests/manual/qtbug-76766/qtbug-76766.pro new file mode 100644 index 000000000..f332d7d57 --- /dev/null +++ b/tests/manual/qtbug-76766/qtbug-76766.pro @@ -0,0 +1,10 @@ +TEMPLATE = app + +QT += qml quick +CONFIG += c++11 + +SOURCES += main.cpp + +RESOURCES += qml.qrc \ + shaders.qrc + diff --git a/tests/manual/qtbug-76766/shaders.qrc b/tests/manual/qtbug-76766/shaders.qrc new file mode 100644 index 000000000..665814e55 --- /dev/null +++ b/tests/manual/qtbug-76766/shaders.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>shaders/shader.frag</file> + <file>shaders/shader.vert</file> + </qresource> +</RCC> diff --git a/tests/manual/qtbug-76766/shaders/shader.frag b/tests/manual/qtbug-76766/shaders/shader.frag new file mode 100644 index 000000000..92d304640 --- /dev/null +++ b/tests/manual/qtbug-76766/shaders/shader.frag @@ -0,0 +1,11 @@ +#version 150 core + +uniform vec3 color; + +out vec4 fragColor; + +void main() +{ + fragColor = vec4(color,1.0); +} + diff --git a/tests/manual/qtbug-76766/shaders/shader.vert b/tests/manual/qtbug-76766/shaders/shader.vert new file mode 100644 index 000000000..fa836855d --- /dev/null +++ b/tests/manual/qtbug-76766/shaders/shader.vert @@ -0,0 +1,36 @@ +#version 150 core + +in vec3 vertexPosition; +in vec3 vertexNormal; +in vec2 vertexTexCoord; +in vec4 vertexTangent; + +out vec3 worldPosition; +out vec3 worldNormal; +out vec4 worldTangent; +out vec2 texCoord; + +uniform mat4 modelMatrix; +uniform mat3 modelNormalMatrix; +uniform mat4 mvp; + +void main() +{ + // Scale texture coordinates for for fragment shader + texCoord = vertexTexCoord; + + // Transform position, normal, and tangent to world coords + worldPosition = vec3(modelMatrix * vec4(vertexPosition, 1.0)); + worldNormal = normalize(modelNormalMatrix * vertexNormal); + worldTangent.xyz = normalize(vec3(modelMatrix * vec4(vertexTangent.xyz, 0.0))); + worldTangent.w = vertexTangent.w; + + // Calculate animated vertex positions + + float sinPos = (vertexPosition.z)+(vertexPosition.x); + float sinPos2 = (vertexPosition.y/2)+(vertexPosition.z); + vec3 vertMod = vec3(vertexPosition.x,vertexPosition.y,vertexPosition.z); + + // Calculate vertex position in clip coordinates + gl_Position = mvp * vec4(vertexPosition, 1.0); +} |