summaryrefslogtreecommitdiffstats
path: root/src/quick3d/imports/extras/defaults
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2016-04-11 14:58:17 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2016-04-23 11:14:30 +0000
commit0542f1614aa6d50c4c9809fb0ce5f1adb5666d67 (patch)
tree77a1ed41c16262f5cc7aa9ddb2d66d3f9b61a719 /src/quick3d/imports/extras/defaults
parent8677f62fa690efa29fbb6f870af1ea2b4e7111cf (diff)
Move defaults and geometries out of Qt3DRender and into Qt3DExtras
QBoundingVolumeDebug has been disabled for now. Will be re-enabled later on. Change-Id: Id6b0abab2ec2aa697330bd20d782f9d104d25d50 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/quick3d/imports/extras/defaults')
-rw-r--r--src/quick3d/imports/extras/defaults/defaults.pri20
-rw-r--r--src/quick3d/imports/extras/defaults/qml/DiffuseMapMaterial.qml132
-rw-r--r--src/quick3d/imports/extras/defaults/qml/DiffuseSpecularMapMaterial.qml145
-rw-r--r--src/quick3d/imports/extras/defaults/qml/FirstPersonCameraController.qml176
-rw-r--r--src/quick3d/imports/extras/defaults/qml/ForwardRenderer.qml74
-rw-r--r--src/quick3d/imports/extras/defaults/qml/GoochMaterial.qml128
-rw-r--r--src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapAlphaMaterial.qml150
-rw-r--r--src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapMaterial.qml148
-rw-r--r--src/quick3d/imports/extras/defaults/qml/NormalDiffuseSpecularMapMaterial.qml161
-rw-r--r--src/quick3d/imports/extras/defaults/qml/PerVertexColorMaterial.qml111
-rw-r--r--src/quick3d/imports/extras/defaults/qml/PhongAlphaMaterial.qml149
-rw-r--r--src/quick3d/imports/extras/defaults/qml/PhongMaterial.qml123
-rw-r--r--src/quick3d/imports/extras/defaults/qml/SkyboxEntity.qml157
-rw-r--r--src/quick3d/imports/extras/defaults/qml/TextureMaterial.qml125
14 files changed, 1799 insertions, 0 deletions
diff --git a/src/quick3d/imports/extras/defaults/defaults.pri b/src/quick3d/imports/extras/defaults/defaults.pri
new file mode 100644
index 000000000..eee644925
--- /dev/null
+++ b/src/quick3d/imports/extras/defaults/defaults.pri
@@ -0,0 +1,20 @@
+
+# When adding new QML files that should be built into the plugin,
+# add them to this variable and they will be listed into a generated
+# resource file.
+#
+# To have the plugin register them as types, add an entries to the
+# qmldir array in qt3dquick3drenderplugin.cpp
+QML_FILES = \
+ $$PWD/qml/PhongMaterial.qml \
+ $$PWD/qml/DiffuseMapMaterial.qml \
+ $$PWD/qml/DiffuseSpecularMapMaterial.qml \
+ $$PWD/qml/NormalDiffuseMapMaterial.qml \
+ $$PWD/qml/NormalDiffuseMapAlphaMaterial.qml \
+ $$PWD/qml/NormalDiffuseSpecularMapMaterial.qml \
+ $$PWD/qml/ForwardRenderer.qml \
+ $$PWD/qml/PerVertexColorMaterial.qml \
+ $$PWD/qml/SkyboxEntity.qml \
+ $$PWD/qml/GoochMaterial.qml \
+ $$PWD/qml/PhongAlphaMaterial.qml \
+ $$PWD/qml/TextureMaterial.qml
diff --git a/src/quick3d/imports/extras/defaults/qml/DiffuseMapMaterial.qml b/src/quick3d/imports/extras/defaults/qml/DiffuseMapMaterial.qml
new file mode 100644
index 000000000..6e5a843b0
--- /dev/null
+++ b/src/quick3d/imports/extras/defaults/qml/DiffuseMapMaterial.qml
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 )
+ property alias diffuse: diffuseTextureImage.source
+ property color specular: Qt.rgba( 0.01, 0.01, 0.01, 1.0 )
+ property real shininess: 150.0
+ property real textureScale: 1.0
+
+ parameters: [
+ Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) },
+ Parameter {
+ name: "diffuseTexture"
+ value: Texture2D {
+ id: diffuseTexture
+ minificationFilter: Texture.LinearMipMapLinear
+ magnificationFilter: Texture.Linear
+ wrapMode {
+ x: WrapMode.Repeat
+ y: WrapMode.Repeat
+ }
+ generateMipMaps: true
+ maximumAnisotropy: 16.0
+ TextureImage { id: diffuseTextureImage; }
+ }
+ },
+ Parameter { name: "ks"; value: Qt.vector3d(root.specular.r, root.specular.g, root.specular.b) },
+ Parameter { name: "shininess"; value: root.shininess },
+ Parameter { name: "texCoordScale"; value: textureScale }
+ ]
+
+ effect: Effect {
+ FilterKey {
+ id: forward
+ name: "renderingStyle"
+ value: "forward"
+ }
+
+ ShaderProgram {
+ id: gl2Es2Shader
+ vertexShaderCode: loadSource("qrc:/shaders/es2/diffusemap.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/diffusemap.frag")
+ }
+
+ ShaderProgram {
+ id: gl3Shader
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/diffusemap.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/diffusemap.frag")
+ }
+
+ techniques: [
+ // OpenGL 3.1
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.CoreProfile
+ majorVersion: 3
+ minorVersion: 1
+ }
+ renderPasses: RenderPass { shaderProgram: gl3Shader }
+ },
+
+ // OpenGL 2.1
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass { shaderProgram: gl2Es2Shader }
+ },
+
+ // OpenGL ES 2
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGLES
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass { shaderProgram: gl2Es2Shader }
+ }
+ ]
+ }
+}
+
diff --git a/src/quick3d/imports/extras/defaults/qml/DiffuseSpecularMapMaterial.qml b/src/quick3d/imports/extras/defaults/qml/DiffuseSpecularMapMaterial.qml
new file mode 100644
index 000000000..e5ec0562a
--- /dev/null
+++ b/src/quick3d/imports/extras/defaults/qml/DiffuseSpecularMapMaterial.qml
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 )
+ property alias diffuse: diffuseTextureImage.source
+ property alias specular: specularTextureImage.source
+ property real shininess: 150.0
+ property real textureScale: 1.0
+
+ parameters: [
+ Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) },
+ Parameter {
+ name: "diffuseTexture"
+ value: Texture2D {
+ id: diffuseTexture
+ minificationFilter: Texture.LinearMipMapLinear
+ magnificationFilter: Texture.Linear
+ wrapMode {
+ x: WrapMode.Repeat
+ y: WrapMode.Repeat
+ }
+ generateMipMaps: true
+ maximumAnisotropy: 16.0
+ TextureImage { id: diffuseTextureImage; }
+ }
+ },
+ Parameter { name: "specularTexture";
+ value: Texture2D {
+ id: specularTexture
+ minificationFilter: Texture.LinearMipMapLinear
+ magnificationFilter: Texture.Linear
+ wrapMode {
+ x: WrapMode.Repeat
+ y: WrapMode.Repeat
+ }
+ generateMipMaps: true
+ maximumAnisotropy: 16.0
+ TextureImage { id: specularTextureImage; }
+ }
+ },
+ Parameter { name: "shininess"; value: root.shininess },
+ Parameter { name: "texCoordScale"; value: textureScale }
+ ]
+
+ effect: Effect {
+
+ FilterKey {
+ id: forward
+ name: "renderingStyle"
+ value: "forward"
+ }
+
+ ShaderProgram {
+ id: gl2Es2Shader
+ vertexShaderCode: loadSource("qrc:/shaders/es2/diffusemap.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/diffusespecularmap.frag")
+ }
+
+ ShaderProgram {
+ id: gl3Shader
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/diffusemap.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/diffusespecularmap.frag")
+ }
+
+ techniques: [
+ // OpenGL 3.1
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.CoreProfile
+ majorVersion: 3
+ minorVersion: 1
+ }
+ renderPasses: RenderPass { shaderProgram: gl3Shader }
+ },
+
+ // OpenGL 2.1
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass { shaderProgram: gl2Es2Shader }
+ },
+
+ // OpenGL ES 2
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGLES
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass { shaderProgram: gl2Es2Shader }
+ }
+ ]
+ }
+}
diff --git a/src/quick3d/imports/extras/defaults/qml/FirstPersonCameraController.qml b/src/quick3d/imports/extras/defaults/qml/FirstPersonCameraController.qml
new file mode 100644
index 000000000..e6950140d
--- /dev/null
+++ b/src/quick3d/imports/extras/defaults/qml/FirstPersonCameraController.qml
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Paul Lemire <paul.lemire350@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D.Core 2.0
+import Qt3D.Render 2.0
+import Qt3D.Input 2.0
+import Qt3D.Logic 2.0
+import QtQml 2.2
+
+Entity {
+ id: root
+ property Camera camera
+ property real linearSpeed: 10.0
+ property real lookSpeed: 180.0
+
+ QtObject {
+ id: d
+ readonly property vector3d firstPersonUp: Qt.vector3d(0, 1, 0)
+ readonly property bool leftMouseButtonPressed: leftMouseButtonAction.active
+ readonly property real vx: txAxis.value * linearSpeed;
+ readonly property real vy: tyAxis.value * linearSpeed;
+ readonly property real vz: tzAxis.value * linearSpeed;
+ readonly property real dx: rxAxis.value * lookSpeed
+ readonly property real dy: ryAxis.value * lookSpeed
+ readonly property bool fineMotion: fineMotionAction.active
+ }
+
+ KeyboardDevice {
+ id: keyboardSourceDevice
+ }
+
+ MouseDevice {
+ id: mouseSourceDevice
+ sensitivity: d.fineMotion ? 0.01 : 0.1
+ }
+
+ components: [
+
+ LogicalDevice {
+ actions: [
+ Action {
+ id: leftMouseButtonAction
+ ActionInput {
+ sourceDevice: mouseSourceDevice
+ buttons: [MouseEvent.LeftButton]
+ }
+ },
+ Action {
+ id: fineMotionAction
+ ActionInput {
+ sourceDevice: keyboardSourceDevice
+ buttons: [Qt.Key_Shift]
+ }
+ }
+ ] // actions
+
+ axes: [
+ // Rotation
+ Axis {
+ id: rxAxis
+ AxisInput {
+ sourceDevice: mouseSourceDevice
+ axis: MouseDevice.X
+ }
+ },
+ Axis {
+ id: ryAxis
+ AxisInput {
+ sourceDevice: mouseSourceDevice
+ axis: MouseDevice.Y
+ }
+ },
+ // Translation
+ Axis {
+ id: txAxis
+ AxisInput {
+ sourceDevice: keyboardSourceDevice
+ buttons: [Qt.Key_Left]
+ scale: -1.0
+ }
+ AxisInput {
+ sourceDevice: keyboardSourceDevice
+ buttons: [Qt.Key_Right]
+ scale: 1.0
+ }
+ },
+ Axis {
+ id: tzAxis
+ AxisInput {
+ sourceDevice: keyboardSourceDevice
+ buttons: [Qt.Key_Up]
+ scale: 1.0
+ }
+ AxisInput {
+ sourceDevice: keyboardSourceDevice
+ buttons: [Qt.Key_Down]
+ scale: -1.0
+ }
+ },
+ Axis {
+ id: tyAxis
+ AxisInput {
+ sourceDevice: keyboardSourceDevice
+ buttons: [Qt.Key_PageUp]
+ scale: 1.0
+ }
+ AxisInput {
+ sourceDevice: keyboardSourceDevice
+ buttons: [Qt.Key_PageDown]
+ scale: -1.0
+ }
+ }
+ ] // axes
+ },
+
+ FrameAction {
+ onTriggered: {
+ // The time difference since the last frame is passed in as the
+ // argument dt. It is a floating point value in units of seconds.
+ root.camera.translate(Qt.vector3d(d.vx, d.vy, d.vz).times(dt))
+
+ if (d.leftMouseButtonPressed) {
+ root.camera.pan(d.dx * dt, d.firstPersonUp)
+ root.camera.tilt(d.dy * dt)
+ }
+ }
+ }
+ ] // components
+}
diff --git a/src/quick3d/imports/extras/defaults/qml/ForwardRenderer.qml b/src/quick3d/imports/extras/defaults/qml/ForwardRenderer.qml
new file mode 100644
index 000000000..0cd5bcaa6
--- /dev/null
+++ b/src/quick3d/imports/extras/defaults/qml/ForwardRenderer.qml
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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
+
+TechniqueFilter {
+ // Expose camera to allow user to choose which camera to use for rendering
+ property alias camera: cameraSelector.camera
+ property alias clearColor: clearBuffer.clearColor
+ property alias viewportRect: viewport.normalizedRect
+ property alias window: surfaceSelector.surface
+
+ // Select the forward rendering Technique of any used Effect
+ matchAll: [ FilterKey { name: "renderingStyle"; value: "forward" } ]
+
+ RenderSurfaceSelector {
+ id: surfaceSelector
+
+ // Use the whole viewport
+ Viewport {
+ id: viewport
+ normalizedRect: Qt.rect(0.0, 0.0, 1.0, 1.0)
+
+ // Use the specified camera
+ CameraSelector {
+ id : cameraSelector
+ FrustumCulling {
+ ClearBuffers {
+ id: clearBuffer
+ clearColor: "white"
+ buffers : ClearBuffers.ColorDepthBuffer
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/quick3d/imports/extras/defaults/qml/GoochMaterial.qml b/src/quick3d/imports/extras/defaults/qml/GoochMaterial.qml
new file mode 100644
index 000000000..51c656ae0
--- /dev/null
+++ b/src/quick3d/imports/extras/defaults/qml/GoochMaterial.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 diffuse: Qt.rgba( 0.0, 0.0, 0.0, 1.0 )
+ property color specular: Qt.rgba( 0.0, 0.0, 0.0, 1.0 )
+ property color coolColor: Qt.rgba( 0.0, 0.0, 0.4, 1.0 )
+ property color warmColor: Qt.rgba( 0.4, 0.4, 0.0, 1.0 )
+ property real alpha: 0.25
+ property real beta: 0.5
+ property real shininess: 100.0
+
+ ShaderProgram {
+ id: gl3GoochShader
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/gooch.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/gooch.frag")
+ }
+
+ ShaderProgram {
+ id: gl2es2GoochShader
+ vertexShaderCode: loadSource("qrc:/shaders/es2/gooch.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/gooch.frag")
+ }
+
+ effect: Effect {
+
+ FilterKey {
+ id: forward
+ name: "renderingStyle"
+ value: "forward"
+ }
+
+ parameters: [
+ Parameter { name: "kd"; value: root.diffuse },
+ Parameter { name: "ks"; value: root.specular },
+ Parameter { name: "kblue"; value: root.coolColor },
+ Parameter { name: "kyellow"; value: root.warmColor },
+ Parameter { name: "alpha"; value: root.alpha },
+ Parameter { name: "beta"; value: root.beta },
+ Parameter { name: "shininess"; value: root.shininess }
+ ]
+
+ techniques: [
+ // GL 3 Technique
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.CoreProfile
+ majorVersion: 3
+ minorVersion: 2
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl3GoochShader
+ }
+ },
+
+ // GL 2 Technique
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl2es2GoochShader
+ }
+ },
+
+ // ES 2 Technique
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGLES
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl2es2GoochShader
+ }
+ }
+ ]
+ }
+}
+
diff --git a/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapAlphaMaterial.qml b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapAlphaMaterial.qml
new file mode 100644
index 000000000..6dfbf98c1
--- /dev/null
+++ b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapAlphaMaterial.qml
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 )
+ property alias diffuse: diffuseTextureImage.source
+ property color specular: Qt.rgba( 0.01, 0.01, 0.01, 1.0 )
+ property alias normal: normalTextureImage.source
+ property real shininess: 150.0
+ property real textureScale: 1.0
+
+ parameters: [
+ Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) },
+ Parameter {
+ name: "diffuseTexture"
+ value: Texture2D {
+ id: diffuseTexture
+ minificationFilter: Texture.LinearMipMapLinear
+ magnificationFilter: Texture.Linear
+ wrapMode {
+ x: WrapMode.Repeat
+ y: WrapMode.Repeat
+ }
+ generateMipMaps: true
+ maximumAnisotropy: 16.0
+ TextureImage { id: diffuseTextureImage; }
+ }
+ },
+ Parameter {
+ name: "normalTexture"
+ value: Texture2D {
+ id: normalTexture
+ minificationFilter: Texture.Linear
+ magnificationFilter: Texture.Linear
+ wrapMode {
+ x: WrapMode.Repeat
+ y: WrapMode.Repeat
+ }
+ maximumAnisotropy: 16.0
+ TextureImage { id: normalTextureImage; }
+ }
+ },
+ Parameter { name: "ks"; value: Qt.vector3d(root.specular.r, root.specular.g, root.specular.b) },
+ Parameter { name: "shininess"; value: root.shininess },
+ Parameter { name: "texCoordScale"; value: textureScale }
+ ]
+
+ effect: Effect {
+ FilterKey {
+ id: forward
+ name: "renderingStyle"
+ value: "forward"
+ }
+
+ ShaderProgram {
+ id: gl2Es2Shader
+ vertexShaderCode: loadSource("qrc:/shaders/es2/normaldiffusemap.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/normaldiffusemapalpha.frag")
+ }
+
+ ShaderProgram {
+ id: gl3Shader
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/normaldiffusemap.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/normaldiffusemapalpha.frag")
+ }
+
+ AlphaCoverage { id: alphaCoverageState }
+ DepthTest { id: depthTestState; depthFunction: DepthTest.Less }
+
+ techniques: [
+ // OpenGL 3.1
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.CoreProfile
+ majorVersion: 3
+ minorVersion: 1
+ }
+ renderPasses: RenderPass { shaderProgram: gl3Shader; renderStates: [alphaCoverageState, depthTestState] }
+ },
+
+ // OpenGL 2.1
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass { shaderProgram: gl2Es2Shader; renderStates: [alphaCoverageState, depthTestState] }
+ },
+
+ // OpenGL ES 2
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGLES
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass { shaderProgram: gl2Es2Shader; renderStates: [alphaCoverageState, depthTestState] }
+ }
+ ]
+ }
+}
+
diff --git a/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapMaterial.qml b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapMaterial.qml
new file mode 100644
index 000000000..eeb1d33d4
--- /dev/null
+++ b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseMapMaterial.qml
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 )
+ property alias diffuse: diffuseTextureImage.source
+ property color specular: Qt.rgba( 0.01, 0.01, 0.01, 1.0 )
+ property alias normal: normalTextureImage.source
+ property real shininess: 150.0
+ property real textureScale: 1.0
+
+ parameters: [
+ Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) },
+ Parameter {
+ name: "diffuseTexture"
+ value: Texture2D {
+ id: diffuseTexture
+ minificationFilter: Texture.LinearMipMapLinear
+ magnificationFilter: Texture.Linear
+ wrapMode {
+ x: WrapMode.Repeat
+ y: WrapMode.Repeat
+ }
+ generateMipMaps: true
+ maximumAnisotropy: 16.0
+ TextureImage { id: diffuseTextureImage; }
+ }
+ },
+ Parameter {
+ name: "normalTexture"
+ value: Texture2D {
+ id: normalTexture
+ minificationFilter: Texture.Linear
+ magnificationFilter: Texture.Linear
+ wrapMode {
+ x: WrapMode.Repeat
+ y: WrapMode.Repeat
+ }
+ maximumAnisotropy: 16.0
+ TextureImage { id: normalTextureImage; }
+ }
+ },
+ Parameter { name: "ks"; value: Qt.vector3d(root.specular.r, root.specular.g, root.specular.b) },
+ Parameter { name: "shininess"; value: root.shininess },
+ Parameter { name: "texCoordScale"; value: textureScale }
+ ]
+
+ effect: Effect {
+
+ FilterKey {
+ id: forward
+ name: "renderingStyle"
+ value: "forward"
+ }
+
+ ShaderProgram {
+ id: gl2Es2Shader
+ vertexShaderCode: loadSource("qrc:/shaders/es2/normaldiffusemap.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/normaldiffusemap.frag")
+ }
+
+ ShaderProgram {
+ id: gl3Shader
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/normaldiffusemap.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/normaldiffusemap.frag")
+ }
+
+ techniques: [
+ // OpenGL 3.1
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.CoreProfile
+ majorVersion: 3
+ minorVersion: 1
+ }
+ renderPasses: RenderPass { shaderProgram: gl3Shader }
+ },
+
+ // OpenGL 2.1
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass { shaderProgram: gl2Es2Shader }
+ },
+
+ // OpenGL ES 2
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGLES
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass { shaderProgram: gl2Es2Shader }
+ }
+ ]
+ }
+}
+
diff --git a/src/quick3d/imports/extras/defaults/qml/NormalDiffuseSpecularMapMaterial.qml b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseSpecularMapMaterial.qml
new file mode 100644
index 000000000..d2c0efda0
--- /dev/null
+++ b/src/quick3d/imports/extras/defaults/qml/NormalDiffuseSpecularMapMaterial.qml
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 )
+ property alias diffuse: diffuseTextureImage.source
+ property alias specular: specularTextureImage.source
+ property alias normal: normalTextureImage.source
+ property real shininess: 150.0
+ property real textureScale: 1.0
+
+ parameters: [
+ Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) },
+ Parameter {
+ name: "diffuseTexture"
+ value: Texture2D {
+ id: diffuseTexture
+ minificationFilter: Texture.LinearMipMapLinear
+ magnificationFilter: Texture.Linear
+ wrapMode {
+ x: WrapMode.Repeat
+ y: WrapMode.Repeat
+ }
+ generateMipMaps: true
+ maximumAnisotropy: 16.0
+ TextureImage { id: diffuseTextureImage; }
+ }
+ },
+ Parameter { name: "specularTexture";
+ value: Texture2D {
+ id: specularTexture
+ minificationFilter: Texture.LinearMipMapLinear
+ magnificationFilter: Texture.Linear
+ wrapMode {
+ x: WrapMode.Repeat
+ y: WrapMode.Repeat
+ }
+ generateMipMaps: true
+ maximumAnisotropy: 16.0
+ TextureImage { id: specularTextureImage; }
+ }
+ },
+ Parameter {
+ name: "normalTexture"
+ value: Texture2D {
+ id: normalTexture
+ minificationFilter: Texture.Linear
+ magnificationFilter: Texture.Linear
+ wrapMode {
+ x: WrapMode.Repeat
+ y: WrapMode.Repeat
+ }
+ maximumAnisotropy: 16.0
+ TextureImage { id: normalTextureImage; }
+ }
+ },
+ Parameter { name: "shininess"; value: root.shininess },
+ Parameter { name: "texCoordScale"; value: textureScale }
+ ]
+
+ effect: Effect {
+
+ FilterKey {
+ id: forward
+ name: "renderingStyle"
+ value: "forward"
+ }
+
+ ShaderProgram {
+ id: gl2Es2Shader
+ vertexShaderCode: loadSource("qrc:/shaders/es2/normaldiffusemap.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/normaldiffusespecularmap.frag")
+ }
+
+ ShaderProgram {
+ id: gl3Shader
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/normaldiffusemap.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/normaldiffusespecularmap.frag")
+ }
+
+ techniques: [
+ // OpenGL 3.1
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.CoreProfile
+ majorVersion: 3
+ minorVersion: 1
+ }
+ renderPasses: RenderPass { shaderProgram: gl3Shader }
+ },
+
+ // OpenGL 2.1
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass { shaderProgram: gl2Es2Shader }
+ },
+
+ // OpenGL ES 2
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGLES
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass { shaderProgram: gl2Es2Shader }
+ }
+ ]
+ }
+}
+
diff --git a/src/quick3d/imports/extras/defaults/qml/PerVertexColorMaterial.qml b/src/quick3d/imports/extras/defaults/qml/PerVertexColorMaterial.qml
new file mode 100644
index 000000000..9e286f459
--- /dev/null
+++ b/src/quick3d/imports/extras/defaults/qml/PerVertexColorMaterial.qml
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Lorenz Esch (TU Ilmenau).
+** 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
+
+ ShaderProgram {
+ id: gl3PerVertexColorShader
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/pervertexcolor.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/pervertexcolor.frag")
+ }
+
+ ShaderProgram {
+ id: gl2es2PerVertexColorShader
+ vertexShaderCode: loadSource("qrc:/shaders/es2/pervertexcolor.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/pervertexcolor.frag")
+ }
+
+ effect: Effect {
+
+ FilterKey {
+ id: forward
+ name: "renderingStyle"
+ value: "forward"
+ }
+
+ techniques: [
+ // GL 3 Technique
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.CoreProfile
+ majorVersion: 3
+ minorVersion: 1
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl3PerVertexColorShader
+ }
+ },
+
+ // GL 2 Technique
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl2es2PerVertexColorShader
+ }
+ },
+
+ // ES 2 Technique
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGLES
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl2es2PerVertexColorShader
+ }
+ }
+ ]
+ }
+}
+
diff --git a/src/quick3d/imports/extras/defaults/qml/PhongAlphaMaterial.qml b/src/quick3d/imports/extras/defaults/qml/PhongAlphaMaterial.qml
new file mode 100644
index 000000000..295d8abd1
--- /dev/null
+++ b/src/quick3d/imports/extras/defaults/qml/PhongAlphaMaterial.qml
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Paul Lemire
+** 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 ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 )
+ property color diffuse: Qt.rgba( 0.7, 0.7, 0.7, 1.0 )
+ property color specular: Qt.rgba( 0.01, 0.01, 0.01, 1.0 )
+ property real shininess: 150.0
+ property real alpha: 0.5
+
+
+ ShaderProgram {
+ id: gl3PhongAlphaShader
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/phong.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/phongalpha.frag")
+ }
+
+ ShaderProgram {
+ id: gl2es2PhongAlphaShader
+ vertexShaderCode: loadSource("qrc:/shaders/es2/phong.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/phongalpha.frag")
+ }
+
+ effect: Effect {
+
+ FilterKey {
+ id: forward
+ name: "renderingStyle"
+ value: "forward"
+ }
+
+ parameters: [
+ Parameter { name: "alpha"; value: root.alpha },
+ Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) },
+ Parameter { name: "kd"; value: Qt.vector3d(root.diffuse.r, root.diffuse.g, root.diffuse.b) },
+ Parameter { name: "ks"; value: Qt.vector3d(root.specular.r, root.specular.g, root.specular.b) },
+ Parameter { name: "shininess"; value: root.shininess }
+ ]
+
+ techniques: [
+ // GL 3 Technique
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.CoreProfile
+ majorVersion: 3
+ minorVersion: 1
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl3PhongAlphaShader
+ renderStates: [
+ NoDepthMask { },
+ BlendEquationArguments {
+ sourceRgb: BlendEquationArguments.SourceAlpha
+ destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
+ },
+ BlendEquation {blendFunction: BlendEquation.Add}
+ ]
+ }
+ },
+
+ // GL 2 Technique
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl2es2PhongAlphaShader
+ renderStates: [
+ NoDepthMask { },
+ BlendEquationArguments {
+ sourceRgb: BlendEquationArguments.SourceAlpha
+ destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
+ },
+ BlendEquation {blendFunction: BlendEquation.Add}
+ ]
+ }
+ },
+
+ // ES 2 Technique
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGLES
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl2es2PhongAlphaShader
+ renderStates: [
+ NoDepthMask { },
+ BlendEquationArguments {
+ sourceRgb: BlendEquationArguments.SourceAlpha
+ destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
+ },
+ BlendEquation {blendFunction: BlendEquation.Add}
+ ]
+ }
+ }
+ ]
+ }
+}
+
diff --git a/src/quick3d/imports/extras/defaults/qml/PhongMaterial.qml b/src/quick3d/imports/extras/defaults/qml/PhongMaterial.qml
new file mode 100644
index 000000000..e60bcefc8
--- /dev/null
+++ b/src/quick3d/imports/extras/defaults/qml/PhongMaterial.qml
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 ambient: Qt.rgba( 0.05, 0.05, 0.05, 1.0 )
+ property color diffuse: Qt.rgba( 0.7, 0.7, 0.7, 1.0 )
+ property color specular: Qt.rgba( 0.01, 0.01, 0.01, 1.0 )
+ property real shininess: 150.0
+
+
+ ShaderProgram {
+ id: gl3PhongShader
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/phong.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/phong.frag")
+ }
+
+ ShaderProgram {
+ id: gl2es2PhongShader
+ vertexShaderCode: loadSource("qrc:/shaders/es2/phong.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/phong.frag")
+ }
+
+ effect: Effect {
+
+ FilterKey {
+ id: forward
+ name: "renderingStyle"
+ value: "forward"
+ }
+
+ parameters: [
+ Parameter { name: "ka"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) },
+ Parameter { name: "kd"; value: Qt.vector3d(root.diffuse.r, root.diffuse.g, root.diffuse.b) },
+ Parameter { name: "ks"; value: Qt.vector3d(root.specular.r, root.specular.g, root.specular.b) },
+ Parameter { name: "shininess"; value: root.shininess }
+ ]
+
+ techniques: [
+ // GL 3 Technique
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.CoreProfile
+ majorVersion: 3
+ minorVersion: 1
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl3PhongShader
+ }
+ },
+
+ // GL 2 Technique
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl2es2PhongShader
+ }
+ },
+
+ // ES 2 Technique
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGLES
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl2es2PhongShader
+ }
+ }
+ ]
+ }
+}
+
diff --git a/src/quick3d/imports/extras/defaults/qml/SkyboxEntity.qml b/src/quick3d/imports/extras/defaults/qml/SkyboxEntity.qml
new file mode 100644
index 000000000..9fcf8559f
--- /dev/null
+++ b/src/quick3d/imports/extras/defaults/qml/SkyboxEntity.qml
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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
+
+Entity {
+
+ property alias cameraPosition: transform.translation;
+ property string baseName: "";
+ property string extension: ".png"
+
+ property TextureCubeMap skyboxTexture: TextureCubeMap {
+ generateMipMaps: false
+ magnificationFilter: Texture.Linear
+ minificationFilter: Texture.Linear
+ wrapMode {
+ x: WrapMode.ClampToEdge
+ y: WrapMode.ClampToEdge
+ }
+ TextureImage { face: Texture.CubeMapPositiveX; source: baseName + "_posx" + extension }
+ TextureImage { face: Texture.CubeMapPositiveY; source: baseName + "_posy" + extension }
+ TextureImage { face: Texture.CubeMapPositiveZ; source: baseName + "_posz" + extension }
+ TextureImage { face: Texture.CubeMapNegativeX; source: baseName + "_negx" + extension }
+ TextureImage { face: Texture.CubeMapNegativeY; source: baseName + "_negy" + extension }
+ TextureImage { face: Texture.CubeMapNegativeZ; source: baseName + "_negz" + extension }
+ }
+
+ ShaderProgram {
+ id: gl3SkyboxShader
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/skybox.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/skybox.frag")
+ }
+
+ ShaderProgram {
+ id: gl2es2SkyboxShader
+ vertexShaderCode: loadSource("qrc:/shaders/es2/skybox.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/skybox.frag")
+ }
+
+ CuboidMesh {
+ id: cuboidMesh
+ yzMeshResolution: Qt.size(2, 2)
+ xzMeshResolution: Qt.size(2, 2)
+ xyMeshResolution: Qt.size(2, 2)
+ }
+
+ Transform {
+ id: transform
+ }
+
+ Material {
+ id: skyboxMaterial
+ parameters: Parameter { name: "skyboxTexture"; value: skyboxTexture}
+
+ effect: Effect {
+ FilterKey {
+ id: forward
+ name: "renderingStyle"
+ value: "forward"
+ }
+
+ techniques: [
+ // GL3 Technique
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.CoreProfile
+ majorVersion: 3
+ minorVersion: 1
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl3SkyboxShader
+ renderStates: [
+ // cull front faces
+ CullFace { mode: CullFace.Front },
+ DepthTest { depthFunction: DepthTest.LessOrEqual }
+ ]
+ }
+ },
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl2es2SkyboxShader
+ renderStates: [
+ CullFace { mode: CullFace.Front },
+ DepthTest { depthFunction: DepthTest.LessOrEqual }
+ ]
+ }
+ },
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGLES
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl2es2SkyboxShader
+ renderStates: [
+ CullFace { mode: CullFace.Front },
+ DepthTest { depthFunction: DepthTest.LessOrEqual }
+ ]
+ }
+ }
+ ]
+ }
+ }
+
+ components: [cuboidMesh, skyboxMaterial, transform]
+}
+
diff --git a/src/quick3d/imports/extras/defaults/qml/TextureMaterial.qml b/src/quick3d/imports/extras/defaults/qml/TextureMaterial.qml
new file mode 100644
index 000000000..d5f99445b
--- /dev/null
+++ b/src/quick3d/imports/extras/defaults/qml/TextureMaterial.qml
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 Texture2D texture: Texture2D {}
+ property alias textureOffset: texCoordOffset.offset
+
+ ShaderProgram {
+ id: gl3Shader
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/unlittexture.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/unlittexture.frag")
+ }
+
+ ShaderProgram {
+ id: gl2es2Shader
+ vertexShaderCode: loadSource("qrc:/shaders/es2/unlittexture.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/unlittexture.frag")
+ }
+
+ effect: Effect {
+
+ FilterKey {
+ id: forward
+ name: "renderingStyle"
+ value: "forward"
+ }
+
+ parameters: [
+ Parameter {
+ name: "diffuseTexture"
+ value: root.texture
+ },
+ Parameter {
+ id: texCoordOffset
+ property vector2d offset: Qt.vector2d(0, 0)
+ name: "texCoordOffset"
+ value: offset
+ }
+
+ ]
+
+ techniques: [
+ // OpenGL 3.1
+ Technique {
+ annotations: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.CoreProfile
+ majorVersion: 3
+ minorVersion: 1
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl3Shader
+ }
+ },
+
+ // GL 2 Technique
+ Technique {
+ annotations: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl2es2Shader
+ }
+ },
+
+ // ES 2 Technique
+ Technique {
+ annotations: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGLES
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass {
+ shaderProgram: gl2es2Shader
+ }
+ }
+ ]
+ }
+}