summaryrefslogtreecommitdiffstats
path: root/examples/qt3d/deferred-renderer-qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/qt3d/deferred-renderer-qml')
-rw-r--r--examples/qt3d/deferred-renderer-qml/DeferredRenderer.qml83
-rw-r--r--examples/qt3d/deferred-renderer-qml/FinalEffect.qml177
-rw-r--r--examples/qt3d/deferred-renderer-qml/GBuffer.qml122
-rw-r--r--examples/qt3d/deferred-renderer-qml/SceneEffect.qml142
-rw-r--r--examples/qt3d/deferred-renderer-qml/deferred-renderer-qml.pro21
-rw-r--r--examples/qt3d/deferred-renderer-qml/deferred-renderer-qml.qrc9
-rw-r--r--examples/qt3d/deferred-renderer-qml/main.cpp68
-rw-r--r--examples/qt3d/deferred-renderer-qml/main.qml239
8 files changed, 861 insertions, 0 deletions
diff --git a/examples/qt3d/deferred-renderer-qml/DeferredRenderer.qml b/examples/qt3d/deferred-renderer-qml/DeferredRenderer.qml
new file mode 100644
index 000000000..d95402cb9
--- /dev/null
+++ b/examples/qt3d/deferred-renderer-qml/DeferredRenderer.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D 2.0
+import Qt3D.Render 2.0
+
+Viewport {
+ rect : Qt.rect(0.0, 0.0, 1.0, 1.0)
+
+ property alias gBuffer : gBufferTargetSelector.target
+ property alias camera : sceneCameraSelector.camera
+
+ LayerFilter {
+ layers : "scene"
+
+ RenderTargetSelector {
+ id : gBufferTargetSelector
+
+ ClearBuffer {
+ buffers: ClearBuffer.ColorDepthBuffer
+
+ RenderPassFilter {
+ id : geometryPass
+ includes : Annotation { name : "pass"; value : "geometry" }
+
+ CameraSelector {
+ id : sceneCameraSelector
+ }
+ }
+ }
+ }
+ }
+
+ LayerFilter {
+ layers : "screenQuad"
+
+ ClearBuffer {
+ buffers: ClearBuffer.ColorDepthBuffer
+
+ RenderPassFilter {
+ id : finalPass
+ includes : Annotation { name : "pass"; value : "final" }
+ CameraSelector {
+ camera: sceneCameraSelector.camera
+ }
+ }
+
+ }
+ }
+}
diff --git a/examples/qt3d/deferred-renderer-qml/FinalEffect.qml b/examples/qt3d/deferred-renderer-qml/FinalEffect.qml
new file mode 100644
index 000000000..f46e65c12
--- /dev/null
+++ b/examples/qt3d/deferred-renderer-qml/FinalEffect.qml
@@ -0,0 +1,177 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D 2.0
+import Qt3D.Render 2.0
+
+Effect {
+ techniques : [
+ // OpenGL 3.1
+ Technique {
+ openGLFilter {api : OpenGLFilter.Desktop; profile : OpenGLFilter.Core; minorVersion : 1; majorVersion : 3 }
+ parameters: Parameter { name: "PointLightBlock"; value: ShaderData {
+ property ShaderDataArray lights: ShaderDataArray {
+ // hard coded lights until we have a way to filter
+ // ShaderData in a scene
+ values: [sceneEntity.light, sphere1.light, sphere2.light, light3.light, light4.light]
+ }
+ }
+ }
+ renderPasses : RenderPass {
+ annotations : Annotation { name : "pass"; value : "final" }
+ shaderProgram : ShaderProgram {
+ id : finalShaderGL3
+ vertexShaderCode:
+ "#version 140
+
+ in vec4 vertexPosition;
+ uniform mat4 modelMatrix;
+
+ void main()
+ {
+ gl_Position = modelMatrix * vertexPosition;
+ }
+ "
+ fragmentShaderCode:
+ "#version 140
+
+ uniform sampler2D color;
+ uniform sampler2D position;
+ uniform sampler2D normal;
+ uniform vec2 winSize;
+
+ out vec4 fragColor;
+
+ struct PointLight
+ {
+ vec3 position;
+ vec3 direction;
+ vec4 color;
+ float intensity;
+ };
+
+ const int lightCount = 5;
+ uniform PointLightBlock {
+ PointLight lights[lightCount];
+ };
+
+ void main()
+ {
+ vec2 texCoord = gl_FragCoord.xy / winSize;
+ vec4 col = texture(color, texCoord);
+ vec3 pos = texture(position, texCoord).xyz;
+ vec3 norm = texture(normal, texCoord).xyz;
+
+ vec4 lightColor;
+ for (int i = 0; i < lightCount; i++) {
+ vec3 s = normalize(lights[i].position - pos);
+ lightColor += lights[i].color * (lights[i].intensity * max(dot(s, norm), 0.0));
+ }
+ lightColor /= float(lightCount);
+ fragColor = col * lightColor;
+ }
+ "
+ }
+ }
+ },
+ // OpenGL 2.0 with FBO extension
+ Technique {
+ openGLFilter {api : OpenGLFilter.Desktop; profile : OpenGLFilter.None; minorVersion : 0; majorVersion : 2 }
+ parameters: Parameter { name: "pointLights"; value: ShaderData {
+ property ShaderDataArray lights: ShaderDataArray {
+ // hard coded lights until we have a way to filter
+ // ShaderData in a scene
+ values: [sceneEntity.light, sphere1.light, sphere2.light, light3.light, light4.light]
+ }
+ }
+ }
+ renderPasses : RenderPass {
+ annotations : Annotation { name : "pass"; value : "final" }
+ shaderProgram : ShaderProgram {
+ id : finalShaderGL2
+ vertexShaderCode:
+ "#version 110
+
+ attribute vec4 vertexPosition;
+ uniform mat4 modelMatrix;
+
+ void main()
+ {
+ gl_Position = modelMatrix * vertexPosition;
+ }
+ "
+ fragmentShaderCode:
+ "#version 110
+
+ uniform sampler2D color;
+ uniform sampler2D position;
+ uniform sampler2D normal;
+ uniform vec2 winSize;
+
+ struct PointLight
+ {
+ vec3 position;
+ vec3 direction;
+ vec4 color;
+ float intensity;
+ };
+
+ const int lightCount = 5;
+ uniform struct
+ {
+ PointLight lights[lightCount];
+ };
+
+ void main()
+ {
+ vec2 texCoord = gl_FragCoord.xy / winSize;
+ vec4 col = texture2D(color, texCoord);
+ vec3 pos = texture2D(position, texCoord).xyz;
+ vec3 norm = texture2D(normal, texCoord).xyz;
+
+ vec4 lightColor;
+ for (int i = 0; i < lightCount; i++) {
+ vec3 s = lights[i].position - pos);
+ lightColor += lights[i].color * (lights[i].intensity * max(dot(s, norm), 0.0));
+ }
+ lightColor /= float(lightCount);
+ gl_FragColor = col * lightColor;
+ }
+ "
+ }
+ }
+ }]
+}
diff --git a/examples/qt3d/deferred-renderer-qml/GBuffer.qml b/examples/qt3d/deferred-renderer-qml/GBuffer.qml
new file mode 100644
index 000000000..309cec160
--- /dev/null
+++ b/examples/qt3d/deferred-renderer-qml/GBuffer.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D 2.0
+import Qt3D.Render 2.0
+
+RenderTarget {
+
+ property alias color : colorAttachment
+ property alias position : positionAttachment
+ property alias normal : normalAttachment
+ property alias depth : depthAttachment
+
+ attachments : [
+
+ RenderAttachment {
+ name : "color"
+ type : RenderAttachment.ColorAttachment0
+ texture : Texture2D {
+ id : colorAttachment
+ width : 1024
+ height : 1024
+ format : Texture.RGBA32F
+ generateMipMaps : false
+ magnificationFilter : Texture.Linear
+ minificationFilter : Texture.Linear
+ wrapMode {
+ x: WrapMode.ClampToEdge
+ y: WrapMode.ClampToEdge
+ }
+ }
+ },
+ RenderAttachment {
+ name : "position"
+ type : RenderAttachment.ColorAttachment1
+ texture : Texture2D {
+ id : positionAttachment
+ width : 1024
+ height : 1024
+ // This texture format may not be supported by
+ // some OpenGL vendors when used as a color attachment
+ format : Texture.RGB32F
+ generateMipMaps : false
+ magnificationFilter : Texture.Linear
+ minificationFilter : Texture.Linear
+ wrapMode {
+ x: WrapMode.ClampToEdge
+ y: WrapMode.ClampToEdge
+ }
+ }
+ },
+ RenderAttachment {
+ name : "normal"
+ type : RenderAttachment.ColorAttachment2
+ texture : Texture2D {
+ id : normalAttachment
+ width : 1024
+ height : 1024
+ // This texture format may not be supported by
+ // some OpenGL vendors when used as a color attachment
+ format : Texture.RGB16F
+ generateMipMaps : false
+ magnificationFilter : Texture.Linear
+ minificationFilter : Texture.Linear
+ wrapMode {
+ x: WrapMode.ClampToEdge
+ y: WrapMode.ClampToEdge
+ }
+ }
+ },
+ RenderAttachment {
+ name : "depth"
+ type : RenderAttachment.DepthAttachment
+ texture : Texture2D {
+ id : depthAttachment
+ width : 1024
+ height : 1024
+ format : Texture.D32F
+ generateMipMaps : false
+ magnificationFilter : Texture.Linear
+ minificationFilter : Texture.Linear
+ wrapMode {
+ x: WrapMode.ClampToEdge
+ y: WrapMode.ClampToEdge
+ }
+ }
+ }
+ ] // attachments
+}
diff --git a/examples/qt3d/deferred-renderer-qml/SceneEffect.qml b/examples/qt3d/deferred-renderer-qml/SceneEffect.qml
new file mode 100644
index 000000000..e4cfdf8c5
--- /dev/null
+++ b/examples/qt3d/deferred-renderer-qml/SceneEffect.qml
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D 2.0
+import Qt3D.Render 2.0
+
+Effect {
+ id : sceneMaterialEffect
+ techniques : [
+ // OpenGL 3.1
+ Technique {
+ openGLFilter {api : OpenGLFilter.Desktop; profile : OpenGLFilter.Core; minorVersion : 1; majorVersion : 3 }
+ renderPasses : RenderPass {
+ annotations : Annotation { name : "pass"; value : "geometry" }
+ shaderProgram : ShaderProgram {
+ id : sceneShaderGL3
+ vertexShaderCode:
+ "#version 140
+
+ in vec4 vertexPosition;
+ in vec3 vertexNormal;
+
+ out vec4 color0;
+ out vec3 position0;
+ out vec3 normal0;
+
+ uniform mat4 mvp;
+ uniform mat4 modelView;
+ uniform mat3 modelViewNormal;
+ uniform vec4 meshColor;
+
+ void main()
+ {
+ color0 = meshColor;
+ position0 = vec3(modelView * vertexPosition);
+ normal0 = normalize(modelViewNormal * vertexNormal);
+ gl_Position = mvp * vertexPosition;
+ }
+ "
+ fragmentShaderCode:
+ "#version 140
+
+ in vec4 color0;
+ in vec3 position0;
+ in vec3 normal0;
+
+ out vec4 color;
+ out vec3 position;
+ out vec3 normal;
+
+ void main()
+ {
+ color = color0;
+ position = position0;
+ normal = normal0;
+ }
+ "
+ }
+ }
+ },
+ // OpenGL 2.0
+ Technique {
+ openGLFilter {api : OpenGLFilter.Desktop; profile : OpenGLFilter.Core; minorVersion : 0; majorVersion : 2 }
+ renderPasses : RenderPass {
+ annotations : Annotation { name : "pass"; value : "geometry" }
+ shaderProgram : ShaderProgram {
+ id : sceneShaderGL2
+ vertexShaderCode:
+ "#version 110
+
+ attribute vec4 vertexPosition;
+ attribute vec3 vertexNormal;
+
+ varying vec4 color0;
+ varying vec3 position0;
+ varying vec3 normal0;
+
+ uniform mat4 mvp;
+ uniform mat4 modelView;
+ uniform mat3 modelViewNormal;
+ uniform vec4 meshColor;
+
+ void main()
+ {
+ color0 = meshColor;
+ position0 = vec3(modelView * vertexPosition);
+ normal0 = normalize(modelViewNormal * vertexNormal);
+ gl_Position = mvp * vertexPosition;
+ }
+ "
+ fragmentShaderCode:
+ "#version 110
+
+ varying vec4 color0;
+ varying vec3 position0;
+ varying vec3 normal0;
+
+ void main()
+ {
+ gl_FragData[0] = color0;
+ gl_FragData[1] = vec4(position0, 0);
+ gl_FragData[2] = vec4(normal0, 0);
+ }
+ "
+ }
+ }
+ }
+ ]
+}
diff --git a/examples/qt3d/deferred-renderer-qml/deferred-renderer-qml.pro b/examples/qt3d/deferred-renderer-qml/deferred-renderer-qml.pro
new file mode 100644
index 000000000..2b1329c2e
--- /dev/null
+++ b/examples/qt3d/deferred-renderer-qml/deferred-renderer-qml.pro
@@ -0,0 +1,21 @@
+TEMPLATE = app
+
+QT += 3dcore 3drenderer 3dinput 3dquick qml quick
+
+include("../exampleresources/exampleresources.pri")
+
+HEADERS += \
+
+
+OTHER_FILES += \
+ main.qml \
+ DeferredRenderer.qml \
+ FinalEffect.qml \
+ SceneEffect.qml \
+ GBuffer.qml
+
+RESOURCES += \
+ deferred-renderer-qml.qrc
+
+SOURCES += \
+ main.cpp
diff --git a/examples/qt3d/deferred-renderer-qml/deferred-renderer-qml.qrc b/examples/qt3d/deferred-renderer-qml/deferred-renderer-qml.qrc
new file mode 100644
index 000000000..573b2337e
--- /dev/null
+++ b/examples/qt3d/deferred-renderer-qml/deferred-renderer-qml.qrc
@@ -0,0 +1,9 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>DeferredRenderer.qml</file>
+ <file>FinalEffect.qml</file>
+ <file>SceneEffect.qml</file>
+ <file>GBuffer.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/qt3d/deferred-renderer-qml/main.cpp b/examples/qt3d/deferred-renderer-qml/main.cpp
new file mode 100644
index 000000000..0ad35ff6c
--- /dev/null
+++ b/examples/qt3d/deferred-renderer-qml/main.cpp
@@ -0,0 +1,68 @@
+
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <Qt3DCore/window.h>
+#include <Qt3DRenderer/qrenderaspect.h>
+#include <Qt3DInput/QInputAspect>
+#include <Qt3DQuick/QQmlAspectEngine>
+
+#include <exampleresources.h>
+
+#include <QGuiApplication>
+#include <QtQml>
+
+int main(int argc, char* argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ initializeAssetResources("../exampleresources/example-assets.qrb");
+
+ Qt3D::Window view;
+ Qt3D::Quick::QQmlAspectEngine engine;
+
+ engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
+ engine.aspectEngine()->initialize();
+ QVariantMap data;
+ data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
+ data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view));
+ engine.aspectEngine()->setData(data);
+ engine.setSource(QUrl("qrc:/main.qml"));
+ view.show();
+
+ return app.exec();
+}
diff --git a/examples/qt3d/deferred-renderer-qml/main.qml b/examples/qt3d/deferred-renderer-qml/main.qml
new file mode 100644
index 000000000..c30c57fd4
--- /dev/null
+++ b/examples/qt3d/deferred-renderer-qml/main.qml
@@ -0,0 +1,239 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D 2.0
+import Qt3D.Render 2.0
+import QtQuick 2.0 as QQ2
+
+Entity {
+ id : root
+
+ GBuffer {
+ id : gBuffer
+ }
+
+ components : FrameGraph {
+ id : deferredFrameGraphComponent
+ activeFrameGraph: DeferredRenderer {
+ camera : camera
+ gBuffer: gBuffer
+ }
+ }
+
+ Configuration {
+ controlledCamera: camera
+ }
+
+ Entity {
+ id : screenQuadEntity
+ components : [
+ Layer {
+ names : "screenQuad"
+ },
+ PlaneMesh {
+ width: 2.0
+ height: 2.0
+ meshResolution: Qt.size(2, 2)
+ },
+ Transform { // We rotate the plane so that it faces us
+ Rotate {
+ axis : Qt.vector3d(1.0, 0.0, 0.0)
+ angle : 90
+ }
+ },
+ Material {
+ parameters : [
+ Parameter { name: "color"; value : gBuffer.color },
+ Parameter { name: "position"; value : gBuffer.position },
+ Parameter { name: "normal"; value : gBuffer.normal },
+ Parameter { name: "winSize"; value : Qt.size(1024, 1024) }
+ ]
+ effect : FinalEffect {}
+ }
+ ]
+
+ }
+
+ Entity {
+ id : sceneEntity
+
+ property PointLight light: PointLight {
+ color : "white"
+ intensity : 4.0
+ QQ2.ColorAnimation on color { from: "white"; to: "blue"; duration: 4000; loops: 2 }
+ QQ2.NumberAnimation on intensity { from: 0; to: 5.0; duration: 1000; loops: QQ2.Animation.Infinite }
+ }
+
+ components: sceneEntity.light
+
+ Camera {
+ id: camera
+ projectionType: CameraLens.PerspectiveProjection
+ fieldOfView: 45
+ aspectRatio: 16/9
+ nearPlane : 0.01
+ farPlane : 1000.0
+ position: Qt.vector3d( 0.0, 0.0, -25.0 )
+ upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
+ viewCenter: Qt.vector3d( 0.0, 0.0, 10.0 )
+ }
+
+ Layer {
+ id : sceneLayer
+ names : "scene"
+ }
+
+ SphereMesh {
+ id : sphereMesh
+ rings: 50
+ slices: 100
+ shareable: false
+ }
+
+ SceneEffect {
+ id : sceneMaterialEffect
+ }
+
+ Entity {
+ id : sphere1
+
+ property Material material : Material {
+ effect : sceneMaterialEffect
+ parameters : Parameter { name : "meshColor"; value : "dodgerblue" }
+ }
+
+ property Transform transform : Transform {
+ Translate{ dx: -10; dy: 0; dz : 5
+ id: sphere1Translate
+ QQ2.SequentialAnimation {
+ loops: QQ2.Animation.Infinite
+ running: false
+ QQ2.NumberAnimation {target: sphere1Translate; property: "dx"; to: 6; duration: 2000 }
+ QQ2.NumberAnimation {target: sphere1Translate; property: "dx"; to: -10; duration: 2000 }
+ }
+ }
+ }
+
+ property PointLight light : PointLight {
+ color : "green"
+ intensity : 5.0
+ }
+
+ components : [
+ sphereMesh,
+ material,
+ sphere1.transform,
+ sphere1.light,
+ sceneLayer
+ ]
+ }
+
+ Entity {
+ id : sphere2
+
+ property Material material : Material {
+ effect : sceneMaterialEffect
+ parameters : Parameter { name : "meshColor"; value : "green" }
+ }
+
+ property PointLight light : PointLight {
+ color : "orange"
+ intensity : 2.0
+ }
+
+ property Transform transform : Transform {
+ Translate{ dx: 5; dy: 0; dz : 5}
+ }
+
+ components : [
+ sphereMesh,
+ sphere2.transform,
+ material,
+ sphere2.light,
+ sceneLayer
+ ]
+ }
+
+ Entity {
+ id: light3
+ property PointLight light : PointLight {
+ color : "white"
+ intensity : 2.0
+ }
+
+ property Material material : Material {
+ effect : sceneMaterialEffect
+ parameters : Parameter { name : "meshColor"; value : "red" }
+ }
+
+ property Transform transform : Transform {
+ Translate{ id: light3Translate; dx: 2; dy: 2; dz : 7
+ QQ2.SequentialAnimation {
+ loops: QQ2.Animation.Infinite
+ running: true
+ QQ2.NumberAnimation {target: light3Translate; property: "dy"; to: 6; duration: 1000; easing.type: QQ2.Easing.InOutQuad }
+ QQ2.NumberAnimation {target: light3Translate; property: "dy"; to: -6; duration: 1000; easing.type: QQ2.Easing.InOutQuint }
+ }
+ }
+ }
+
+ components: [
+ sphereMesh,
+ material,
+ light,
+ transform,
+ sceneLayer
+ ]
+ }
+
+ Entity {
+ id: light4
+ property PointLight light : PointLight {
+ color : "white"
+ intensity : 3.0
+ }
+ property Transform transform : Transform {
+ Translate{ dx: 5; dy: 2; dz : 7}
+ }
+
+ components: [
+ light4.light,
+ light4.transform,
+ sceneLayer
+ ]
+ }
+ }
+}