From 2a260617b96281375e2ee018af8c7547d99e4a6d Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Tue, 3 Apr 2018 17:19:43 +0100 Subject: Add replacement materials example All texture assets were made by KDAB under the CLA. The material "sphere" mesh is from Allegorithmic and published under the Creative Commons 4 license. See paragraph 1.2 of https://www.allegorithmic.com/legal/substance-share Task-number: QTBUG-61415 Change-Id: I23d61723bbac561e22e11fa57105b29148c01699 Reviewed-by: Sean Harmer Reviewed-by: Andy Nichols (cherry picked from commit 74c06c02f896c6aba408cfd0857d317378572736) --- examples/qt3d/pbr-materials/BasicCamera.qml | 66 +++++ examples/qt3d/pbr-materials/Lights.qml | 142 ++++++++++ examples/qt3d/pbr-materials/TrefoilKnot.qml | 86 ++++++ .../pbr-materials/doc/images/pbr-materials.png | Bin 0 -> 314172 bytes examples/qt3d/pbr-materials/doc/src/materials.qdoc | 39 +++ examples/qt3d/pbr-materials/main.cpp | 68 +++++ examples/qt3d/pbr-materials/main.qml | 309 +++++++++++++++++++++ examples/qt3d/pbr-materials/materials.qrc | 8 + examples/qt3d/pbr-materials/pbr-materials.pro | 19 ++ 9 files changed, 737 insertions(+) create mode 100644 examples/qt3d/pbr-materials/BasicCamera.qml create mode 100644 examples/qt3d/pbr-materials/Lights.qml create mode 100644 examples/qt3d/pbr-materials/TrefoilKnot.qml create mode 100644 examples/qt3d/pbr-materials/doc/images/pbr-materials.png create mode 100644 examples/qt3d/pbr-materials/doc/src/materials.qdoc create mode 100644 examples/qt3d/pbr-materials/main.cpp create mode 100644 examples/qt3d/pbr-materials/main.qml create mode 100644 examples/qt3d/pbr-materials/materials.qrc create mode 100644 examples/qt3d/pbr-materials/pbr-materials.pro (limited to 'examples/qt3d/pbr-materials') diff --git a/examples/qt3d/pbr-materials/BasicCamera.qml b/examples/qt3d/pbr-materials/BasicCamera.qml new file mode 100644 index 000000000..9f2ce729b --- /dev/null +++ b/examples/qt3d/pbr-materials/BasicCamera.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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: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 + +Camera { + id: mainCamera + objectName: "mainCamera" + + projectionType: CameraLens.PerspectiveProjection + fieldOfView: 22.5 + aspectRatio: _window.width / _window.height + onAspectRatioChanged: console.log( "aspectRatio = " + aspectRatio ) + nearPlane: 0.01 + farPlane: 1000.0 + viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) + upVector: Qt.vector3d( 0.0, 1.0, 0.0 ) +} diff --git a/examples/qt3d/pbr-materials/Lights.qml b/examples/qt3d/pbr-materials/Lights.qml new file mode 100644 index 000000000..158583da2 --- /dev/null +++ b/examples/qt3d/pbr-materials/Lights.qml @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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: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 QtQuick 2.1 +import Qt3D.Core 2.0 +import Qt3D.Render 2.0 +import Qt3D.Input 2.0 +import Qt3D.Extras 2.0 + +Entity { + id: lights + + // Point Light (pulsing) + Entity { + components: [ + PointLight { + color: "red" + intensity: 0.3 + constantAttenuation: 1.0 + linearAttenuation: 0.0 + quadraticAttenuation: 0.0025 + + NumberAnimation on intensity { + from: 0.3; to: 0.8; + running: true + loops: Animation.Infinite + duration: 1000 + easing.type: Easing.CosineCurve + } + }, + Transform { + translation: Qt.vector3d(0.0, 5.0, 0.0) + } + ] + } + + // 2 x Directional Lights (steady) + Entity { + components: [ + DirectionalLight { + worldDirection: Qt.vector3d(0.3, -3.0, 0.0).normalized(); + color: "#fbf9ce" + intensity: 0.3 + } + ] + } + + Entity { + components: [ + DirectionalLight { + worldDirection: Qt.vector3d(-0.3, -0.3, 0.0).normalized(); + color: "#9cdaef" + intensity: 0.15 + } + ] + } + + // Spot Light (sweeping) + Entity { + components: [ + SpotLight { + localDirection: Qt.vector3d(0.0, -1.0, 0.0) + color: "white" + intensity: 5.0 + }, + Transform { + id: spotLightTransform + translation: Qt.vector3d(0.0, 5.0, 0.0) + rotationZ: -60.0 + + + SequentialAnimation { + loops: Animation.Infinite + running: true + + NumberAnimation { + target: spotLightTransform + property: "rotationZ" + from: -60; to: 60 + duration: 4000 + easing.type: Easing.InOutQuad + } + + NumberAnimation { + target: spotLightTransform + property: "rotationZ" + from: 60; to: -60 + duration: 4000 + easing.type: Easing.InOutQuad + } + } + } + ] + } +} diff --git a/examples/qt3d/pbr-materials/TrefoilKnot.qml b/examples/qt3d/pbr-materials/TrefoilKnot.qml new file mode 100644 index 000000000..1a7b4031b --- /dev/null +++ b/examples/qt3d/pbr-materials/TrefoilKnot.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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: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.Extras 2.9 + +Entity { + id: root + + property real x: 0.0 + property real y: 0.0 + property real z: 0.0 + property real scale: 1.0 + property real theta: 0.0 + property real phi: 0.0 + + components: [ transform, mesh, material ] + + MetalRoughMaterial { + id: material + baseColor: Qt.rgba( 0.8, 0.0, 0.0, 1.0 ) + metalness: 0.2 + roughness: 0.5 + } + + Transform { + id: transform + translation: Qt.vector3d(root.x, root.y, root.z) + rotationX: theta + rotationY: phi + scale: root.scale + } + + Mesh { + id: mesh + source: "assets/obj/trefoil.obj" + } +} diff --git a/examples/qt3d/pbr-materials/doc/images/pbr-materials.png b/examples/qt3d/pbr-materials/doc/images/pbr-materials.png new file mode 100644 index 000000000..2934895db Binary files /dev/null and b/examples/qt3d/pbr-materials/doc/images/pbr-materials.png differ diff --git a/examples/qt3d/pbr-materials/doc/src/materials.qdoc b/examples/qt3d/pbr-materials/doc/src/materials.qdoc new file mode 100644 index 000000000..c96bb0843 --- /dev/null +++ b/examples/qt3d/pbr-materials/doc/src/materials.qdoc @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example materials + \title Qt 3D: PBR Materials QML Example + \ingroup qt3d-examples-qml + \brief A QML application that demonstrates using PBR materials. + + \image pbr-materials.png + + \e {Pbr-Materials} demonstrates using the Qt 3D material system. + + \include examples-run.qdocinc +*/ diff --git a/examples/qt3d/pbr-materials/main.cpp b/examples/qt3d/pbr-materials/main.cpp new file mode 100644 index 000000000..faed40390 --- /dev/null +++ b/examples/qt3d/pbr-materials/main.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** 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: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$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + Qt3DExtras::Quick::Qt3DQuickWindow view; + + // Expose the window as a context property so we can set the aspect ratio + view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view); + view.setSource(QUrl("qrc:/main.qml")); + view.show(); + + return app.exec(); +} diff --git a/examples/qt3d/pbr-materials/main.qml b/examples/qt3d/pbr-materials/main.qml new file mode 100644 index 000000000..301a113b5 --- /dev/null +++ b/examples/qt3d/pbr-materials/main.qml @@ -0,0 +1,309 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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: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 QtQuick 2.1 +import Qt3D.Core 2.0 +import Qt3D.Render 2.9 +import Qt3D.Input 2.0 +import Qt3D.Extras 2.9 + +Entity { + id: root + objectName: "root" + + // Use the renderer configuration specified in ForwardRenderer.qml + // and render from the mainCamera + components: [ + RenderSettings { + activeFrameGraph: ForwardRenderer { + camera: mainCamera + } + }, + // Event Source will be set by the Qt3DQuickWindow + InputSettings { } + ] + + BasicCamera { + id: mainCamera + position: Qt.vector3d( -5.17253, 2.95727, 6.65948 ) + viewCenter: Qt.vector3d( 6.73978, -2.50545, -10.6525 ) + } + + FirstPersonCameraController { camera: mainCamera } + + Lights { } + + Entity { + components: [ + PointLight { + enabled: parent.enabled + color: "black" + intensity: 0 + }, + EnvironmentLight { + enabled: parent.enabled + + irradiance: TextureLoader { + source: "assets/cubemaps/default/default_irradiance.dds" + wrapMode { + x: WrapMode.ClampToEdge + y: WrapMode.ClampToEdge + } + generateMipMaps: false + } + specular: TextureLoader { + source: "assets/cubemaps/default/default_specular.dds" + wrapMode { + x: WrapMode.ClampToEdge + y: WrapMode.ClampToEdge + } + generateMipMaps: false + } + } + ] + } + + Entity { + id: floor + + components: [ + Mesh { + source: "assets/obj/plane-10x10.obj" + }, + TexturedMetalRoughMaterial { + baseColor: TextureLoader { + source: "assets/textures/ceramic_small_diamond/ceramic_small_diamond_basecolor.png" + format: Texture.SRGB8_Alpha8 + generateMipMaps: true + } + metalness: TextureLoader { source: "assets/textures/ceramic_small_diamond/ceramic_small_diamond_metallic.png"; generateMipMaps: true } + roughness: TextureLoader { source: "assets/textures/ceramic_small_diamond/ceramic_small_diamond_roughness.png"; generateMipMaps: true } + normal: TextureLoader { source: "assets/textures/ceramic_small_diamond/ceramic_small_diamond_normal.png"; generateMipMaps: true } + ambientOcclusion: TextureLoader { source: "assets/textures/ceramic_small_diamond/ceramic_small_diamond_ambient_occlusion.png" } + } + ] + } + + TrefoilKnot { + id: trefoilKnot + y: 1.5 + z: -2 + scale: 0.2 + + ParallelAnimation { + loops: Animation.Infinite + running: true + + NumberAnimation { + target: trefoilKnot + property: "theta" + from: 0; to: 360 + duration: 5000 + } + + NumberAnimation { + target: trefoilKnot + property: "phi" + from: 0; to: 360 + duration: 5000 + } + } + } + + Mesh { + id: matSphere + source: "assets/obj/material-sphere.obj" + } + + Entity { + id: sphere1 + + components: [ + matSphere1Transform, + matSphere, + matSphere1Material + ] + + Transform { + id: matSphere1Transform + translation: Qt.vector3d(-3, 0, 0) + rotationY: -90 + } + + TexturedMetalRoughMaterial { + id: matSphere1Material + baseColor: TextureLoader { + source: "assets/textures/aluminium_random_brushed/aluminium_random_brushed_basecolor.png" + format: Texture.SRGB8_Alpha8 + generateMipMaps: true + } + metalness: TextureLoader { source: "assets/textures/aluminium_random_brushed/aluminium_random_brushed_metallic.png"; generateMipMaps: true } + roughness: TextureLoader { source: "assets/textures/aluminium_random_brushed/aluminium_random_brushed_roughness.png"; generateMipMaps: true} + normal: TextureLoader { source: "assets/textures/aluminium_random_brushed/aluminium_random_brushed_normal.png"; generateMipMaps: true } + ambientOcclusion: TextureLoader { source: "assets/textures/no-ao.png" } + } + } + + Entity { + id: sphere2 + + components: [ + matSphere2Transform, + matSphere, + matSphere2Material + ] + + Transform { + id: matSphere2Transform + translation: Qt.vector3d(-1.5, 0, 0) + rotationY: -90 + } + + TexturedMetalRoughMaterial { + id: matSphere2Material + baseColor: TextureLoader { + source: "assets/textures/american_walnut_crown_cut/american_walnut_crown_cut_basecolor.png" + format: Texture.SRGB8_Alpha8 + generateMipMaps: true + } + metalness: TextureLoader { source: "assets/textures/american_walnut_crown_cut/american_walnut_crown_cut_metallic.png"; generateMipMaps: true } + roughness: TextureLoader { source: "assets/textures/american_walnut_crown_cut/american_walnut_crown_cut_roughness.png"; generateMipMaps: true } + normal: TextureLoader { source: "assets/textures/american_walnut_crown_cut/american_walnut_crown_cut_normal.png"; generateMipMaps: true } + ambientOcclusion: TextureLoader { source: "assets/textures/no-ao.png" } + } + } + + Entity { + id: sphere3 + + components: [ + matSphere3Transform, + matSphere, + matSphere3Material + ] + + Transform { + id: matSphere3Transform + translation: Qt.vector3d(0, 0, 0) + rotationY: -90 + } + + TexturedMetalRoughMaterial { + id: matSphere3Material + baseColor: TextureLoader { + source: "assets/textures/ceramic_tiles_brown_tomato/ceramic_tiles_brown_tomato_basecolor.png" + format: Texture.SRGB8_Alpha8 + generateMipMaps: true + } + metalness: TextureLoader { source: "assets/textures/ceramic_tiles_brown_tomato/ceramic_tiles_brown_tomato_metallic.png"; generateMipMaps: true } + roughness: TextureLoader { source: "assets/textures/ceramic_tiles_brown_tomato/ceramic_tiles_brown_tomato_roughness.png"; generateMipMaps: true } + normal: TextureLoader { source: "assets/textures/ceramic_tiles_brown_tomato/ceramic_tiles_brown_tomato_normal.png"; generateMipMaps: true } + ambientOcclusion: TextureLoader { source: "assets/textures/no-ao.png" } + } + } + + Entity { + id: sphere4 + + components: [ + matSphere4Transform, + matSphere, + matSphere4Material + ] + + Transform { + id: matSphere4Transform + translation: Qt.vector3d(1.5, 0, 0) + rotationY: -90 + } + + TexturedMetalRoughMaterial { + id: matSphere4Material + baseColor: TextureLoader { + source: "assets/textures/copper_brushed/copper_brushed_basecolor.png" + format: Texture.SRGB8_Alpha8 + generateMipMaps: true + } + metalness: TextureLoader { source: "assets/textures/copper_brushed/copper_brushed_metallic.png"; generateMipMaps: true } + roughness: TextureLoader { source: "assets/textures/copper_brushed/copper_brushed_roughness.png"; generateMipMaps: true } + normal: TextureLoader { source: "assets/textures/copper_brushed/copper_brushed_normal.png"; generateMipMaps: true } + ambientOcclusion: TextureLoader { source: "assets/textures/no-ao.png" } + } + } + + Entity { + id: sphere5 + + components: [ + matSphere5Transform, + matSphere, + matSphere5Material + ] + + Transform { + id: matSphere5Transform + translation: Qt.vector3d(3, 0, 0) + rotationY: -90 + } + + TexturedMetalRoughMaterial { + id: matSphere5Material + baseColor: TextureLoader { + source: "assets/textures/gold_leaf_waste/gold_leaf_waste_basecolor.png" + format: Texture.SRGB8_Alpha8 + generateMipMaps: true + } + metalness: TextureLoader { source: "assets/textures/gold_leaf_waste/gold_leaf_waste_metallic.png"; generateMipMaps: true } + roughness: TextureLoader { source: "assets/textures/gold_leaf_waste/gold_leaf_waste_roughness.png"; generateMipMaps: true } + normal: TextureLoader { source: "assets/textures/gold_leaf_waste/gold_leaf_waste_normal.png"; generateMipMaps: true } + ambientOcclusion: TextureLoader { source: "assets/textures/no-ao.png" } + } + } +} diff --git a/examples/qt3d/pbr-materials/materials.qrc b/examples/qt3d/pbr-materials/materials.qrc new file mode 100644 index 000000000..f7bf8d322 --- /dev/null +++ b/examples/qt3d/pbr-materials/materials.qrc @@ -0,0 +1,8 @@ + + + main.qml + BasicCamera.qml + TrefoilKnot.qml + Lights.qml + + diff --git a/examples/qt3d/pbr-materials/pbr-materials.pro b/examples/qt3d/pbr-materials/pbr-materials.pro new file mode 100644 index 000000000..873170f76 --- /dev/null +++ b/examples/qt3d/pbr-materials/pbr-materials.pro @@ -0,0 +1,19 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +QT += 3dcore 3drender 3dinput 3dquick qml quick 3dquickextras + +HEADERS += \ + +SOURCES += \ + main.cpp + +OTHER_FILES += \ + *.qml \ + +RESOURCES += \ + materials.qrc \ + ../exampleresources/cubemaps.qrc \ + ../exampleresources/obj.qrc \ + ../exampleresources/textures.qrc -- cgit v1.2.3