diff --git a/examples/quick3d/principledmaterial/main.qml b/examples/quick3d/principledmaterial/main.qml index af8fcc12a235846147443273f4c2b35a3adf0dba..4b2044e52948b6f8c56405ed08a03c1fdac7b5f1 100644 --- a/examples/quick3d/principledmaterial/main.qml +++ b/examples/quick3d/principledmaterial/main.qml @@ -132,20 +132,14 @@ Window { specularAmount: materialCtrl.specular indexOfRefraction: materialCtrl.ior opacity: materialCtrl.opacityValue - Texture { - id: basemetal - source: "maps/metallic/basemetal.astc" - } - Texture { - id: normalrough - source: "maps/metallic/normalrough.astc" - } - baseColorMap: basemetal - metalnessMap: basemetal - roughnessMap: normalrough - normalMap: normalrough - metalnessChannel: Material.A - roughnessChannel: Material.A + + baseColorMap: Texture { source: "maps/metallic/basecolor.jpg" } + metalnessMap: Texture { source: "maps/metallic/metallic.jpg" } + roughnessMap: Texture { source: "maps/metallic/roughness.jpg" } + normalMap: Texture { source: "maps/metallic/normal.jpg" } + + metalnessChannel: Material.R + roughnessChannel: Material.R } ] //! [textured principled] diff --git a/examples/quick3d/principledmaterial/maps/metallic/basecolor.jpg b/examples/quick3d/principledmaterial/maps/metallic/basecolor.jpg new file mode 100644 index 0000000000000000000000000000000000000000..440182747fc639345d3c5a4aae447203db487691 Binary files /dev/null and b/examples/quick3d/principledmaterial/maps/metallic/basecolor.jpg differ diff --git a/examples/quick3d/principledmaterial/maps/metallic/metallic.jpg b/examples/quick3d/principledmaterial/maps/metallic/metallic.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6fe7b17129d28a8312d87de43bdd351c6395736b Binary files /dev/null and b/examples/quick3d/principledmaterial/maps/metallic/metallic.jpg differ diff --git a/examples/quick3d/principledmaterial/maps/metallic/normal.jpg b/examples/quick3d/principledmaterial/maps/metallic/normal.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c8d1a5928c4b739fe54ecf8508033c116824a31f Binary files /dev/null and b/examples/quick3d/principledmaterial/maps/metallic/normal.jpg differ diff --git a/examples/quick3d/principledmaterial/maps/metallic/roughness.jpg b/examples/quick3d/principledmaterial/maps/metallic/roughness.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f200e3329cb7ed22efeca927e1eeade5ccd35b3a Binary files /dev/null and b/examples/quick3d/principledmaterial/maps/metallic/roughness.jpg differ diff --git a/examples/quick3d/principledmaterial/materials.qrc b/examples/quick3d/principledmaterial/materials.qrc index 6c28bfc42e810c5051827b84d3a068ed9bc61d05..3abe9467de4a3020c85224b72f1f46c047709a6a 100644 --- a/examples/quick3d/principledmaterial/materials.qrc +++ b/examples/quick3d/principledmaterial/materials.qrc @@ -1,7 +1,9 @@ <RCC> <qresource prefix="/"> <file>maps/OpenfootageNET_garage-1024.hdr</file> - <file>maps/metallic/normalrough.astc</file> - <file>maps/metallic/basemetal.astc</file> + <file>maps/metallic/roughness.jpg</file> + <file>maps/metallic/normal.jpg</file> + <file>maps/metallic/metallic.jpg</file> + <file>maps/metallic/basecolor.jpg</file> </qresource> </RCC> diff --git a/tests/manual/principledmaterial/MaterialControl.qml b/tests/manual/principledmaterial/MaterialControl.qml new file mode 100644 index 0000000000000000000000000000000000000000..3712342c1d710393156b46d79457023f2ca20eb0 --- /dev/null +++ b/tests/manual/principledmaterial/MaterialControl.qml @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples 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.14 +import QtQuick.Controls 2.14 +import QtQuick.Layouts 1.14 + +Rectangle { + property real metalness: metalness.sliderValue + property real roughness: roughness.sliderValue + property real specular: specular.sliderValue + property real specularTint: specularTint.sliderValue + property real ior: ior.sliderValue + property real opacityValue: opacityValue.sliderValue + + color: "#6b7080" + width: parent.width + height: 75 + + Component { + id: propertySlider + RowLayout { + Label { + id: propText + text: name + color: "#222840" + font.pointSize: 12 + Layout.minimumWidth: 150 + Layout.maximumWidth: 150 + } + Slider { + id: slider + from: fromValue + to: toValue + value: sliderValue + stepSize: 0.01 + onValueChanged: sliderValue = value + Layout.minimumWidth: 200 + Layout.maximumWidth: 200 + background: Rectangle { + x: slider.leftPadding + y: slider.topPadding + slider.availableHeight / 2 - height / 2 + implicitWidth: 200 + implicitHeight: 4 + width: slider.availableWidth + height: implicitHeight + radius: 1 + color: "#222840" + + Rectangle { + width: slider.visualPosition * parent.width + height: parent.height + color: "#848895" + radius: 1 + } + } + handle: Rectangle { + x: slider.leftPadding + slider.visualPosition * (slider.availableWidth - width) + y: slider.topPadding + slider.availableHeight / 2 - height / 2 + implicitWidth: 20 + implicitHeight: 20 + radius: 5 + color: slider.pressed ? "#222840" : "#6b7080" + border.color: "#848895" + } + } + Label { + id: valueText + text: slider.value.toFixed(2) + color: "#222840" + font.pointSize: 12 + font.bold: true + Layout.minimumWidth: 40 + Layout.maximumWidth: 40 + } + } + } + + ColumnLayout { + anchors.horizontalCenter: parent.horizontalCenter + RowLayout { + spacing: 20 + Loader { + id: metalness + property real sliderValue: 1.0 + property string name: "Metalness" + property real fromValue: 0.0 + property real toValue: 1.0 + sourceComponent: propertySlider + } + Loader { + id: roughness + property real sliderValue: 0.2 + property string name: "Roughness" + property real fromValue: 0.0 + property real toValue: 1.0 + sourceComponent: propertySlider + } + Loader { + id: ior + property real sliderValue: 1.8 + property string name: "Index of Refraction" + property real fromValue: 1.0 + property real toValue: 3.0 + sourceComponent: propertySlider + } + } + RowLayout { + spacing: 20 + Loader { + id: specular + property real sliderValue: 0.0 + property string name: "Specular Power" + property real fromValue: 0.0 + property real toValue: 1.0 + sourceComponent: propertySlider + } + Loader { + id: specularTint + property real sliderValue: 0.0 + property string name: "Specular Tint" + property real fromValue: 0.0 + property real toValue: 1.0 + sourceComponent: propertySlider + } + Loader { + id: opacityValue + property real sliderValue: 1.0 + property string name: "Opacity" + property real fromValue: 0.0 + property real toValue: 1.0 + sourceComponent: propertySlider + } + } + } +} diff --git a/tests/manual/principledmaterial/README b/tests/manual/principledmaterial/README new file mode 100644 index 0000000000000000000000000000000000000000..01f880627beded6d069eae7079253ebf53c6182a --- /dev/null +++ b/tests/manual/principledmaterial/README @@ -0,0 +1,3 @@ +This is a version of the principledmaterial example that uses compressed +textures. The example was rolled back to an earlier version, since not all +machines/devices/graphics APIs support ASTC compressed textures. diff --git a/tests/manual/principledmaterial/main.cpp b/tests/manual/principledmaterial/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8e886b611af5ae654e8f080108d42cb360f73df7 --- /dev/null +++ b/tests/manual/principledmaterial/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples 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 <QGuiApplication> +#include <QQmlApplicationEngine> + +#include <QtGui> +#include <QtQuick3D/private/qquick3dviewport_p.h> + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + + QGuiApplication app(argc, argv); + + QSurfaceFormat::setDefaultFormat(QQuick3DViewport::idealSurfaceFormat()); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + if (engine.rootObjects().isEmpty()) + return -1; + + return app.exec(); +} diff --git a/tests/manual/principledmaterial/main.qml b/tests/manual/principledmaterial/main.qml new file mode 100644 index 0000000000000000000000000000000000000000..308c29dad666a96400e4a6ef98cce89087b9ad7e --- /dev/null +++ b/tests/manual/principledmaterial/main.qml @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples 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.14 +import QtQuick.Window 2.14 +import QtQuick3D 1.15 + +Window { + id: window + width: 1280 + height: 720 + visible: true + title: "Principled Materials Example" + + MaterialControl { + id: materialCtrl + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + } + + View3D { + anchors.fill: parent + camera: camera + renderMode: View3D.Underlay + + //! [rotating light] + // Rotate the light direction + DirectionalLight { + rotation: Qt.vector3d(0, 100, 0) + brightness: 100 + SequentialAnimation on rotation { + loops: Animation.Infinite + PropertyAnimation { + duration: 5000 + to: Qt.vector3d(0, 360, 0) + from: Qt.vector3d(0, 0, 0) + } + } + } + //! [rotating light] + + //! [environment] + environment: SceneEnvironment { + probeBrightness: 250 + clearColor: "#848895" + + backgroundMode: SceneEnvironment.Color + lightProbe: Texture { + source: "maps/OpenfootageNET_garage-1024.hdr" + } + } + //! [environment] + + PerspectiveCamera { + id: camera + position: Qt.vector3d(0, 0, -600) + } + + //! [basic principled] + Model { + position: Qt.vector3d(-250, -30, 0) + scale: Qt.vector3d(4, 4, 4) + source: "#Sphere" + materials: [ PrincipledMaterial { + baseColor: "#41cd52" + metalness: materialCtrl.metalness + roughness: materialCtrl.roughness + specularAmount: materialCtrl.specular + indexOfRefraction: materialCtrl.ior + specularTint: materialCtrl.specularTint + opacity: materialCtrl.opacityValue + } + ] + } + //! [basic principled] + + //! [textured principled] + Model { + position: Qt.vector3d(250, -30, 0) + scale: Qt.vector3d(4, 4, 4) + source: "#Sphere" + materials: [ PrincipledMaterial { + metalness: materialCtrl.metalness + roughness: materialCtrl.roughness + specularAmount: materialCtrl.specular + indexOfRefraction: materialCtrl.ior + opacity: materialCtrl.opacityValue + Texture { + id: basemetal + source: "maps/metallic/basemetal.astc" + } + Texture { + id: normalrough + source: "maps/metallic/normalrough.astc" + } + baseColorMap: basemetal + metalnessMap: basemetal + roughnessMap: normalrough + normalMap: normalrough + metalnessChannel: Material.A + roughnessChannel: Material.A + } + ] + //! [textured principled] + + SequentialAnimation on rotation { + loops: Animation.Infinite + PropertyAnimation { + duration: 5000 + to: Qt.vector3d(360, 360, 360) + from: Qt.vector3d(0, 0, 0) + } + } + } + } +} diff --git a/tests/manual/principledmaterial/maps/OpenfootageNET_garage-1024.hdr b/tests/manual/principledmaterial/maps/OpenfootageNET_garage-1024.hdr new file mode 100644 index 0000000000000000000000000000000000000000..01e9e38ac2eb48679de45be85aca47f658da44d6 Binary files /dev/null and b/tests/manual/principledmaterial/maps/OpenfootageNET_garage-1024.hdr differ diff --git a/examples/quick3d/principledmaterial/maps/metallic/basemetal.astc b/tests/manual/principledmaterial/maps/metallic/basemetal.astc similarity index 100% rename from examples/quick3d/principledmaterial/maps/metallic/basemetal.astc rename to tests/manual/principledmaterial/maps/metallic/basemetal.astc diff --git a/examples/quick3d/principledmaterial/maps/metallic/normalrough.astc b/tests/manual/principledmaterial/maps/metallic/normalrough.astc similarity index 100% rename from examples/quick3d/principledmaterial/maps/metallic/normalrough.astc rename to tests/manual/principledmaterial/maps/metallic/normalrough.astc diff --git a/tests/manual/principledmaterial/materials.qrc b/tests/manual/principledmaterial/materials.qrc new file mode 100644 index 0000000000000000000000000000000000000000..6c28bfc42e810c5051827b84d3a068ed9bc61d05 --- /dev/null +++ b/tests/manual/principledmaterial/materials.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/"> + <file>maps/OpenfootageNET_garage-1024.hdr</file> + <file>maps/metallic/normalrough.astc</file> + <file>maps/metallic/basemetal.astc</file> + </qresource> +</RCC> diff --git a/tests/manual/principledmaterial/principledmaterial.pro b/tests/manual/principledmaterial/principledmaterial.pro new file mode 100644 index 0000000000000000000000000000000000000000..4b4520f457f282edf680d819e077f6b9e13b4d05 --- /dev/null +++ b/tests/manual/principledmaterial/principledmaterial.pro @@ -0,0 +1,14 @@ +QT += quick quick3d-private + +target.path = $$[QT_INSTALL_EXAMPLES]/quick3d/principledmaterial +INSTALLS += target + +SOURCES += \ + main.cpp + +RESOURCES += \ + qml.qrc \ + materials.qrc + +OTHER_FILES += \ + doc/src/*.* diff --git a/tests/manual/principledmaterial/qml.qrc b/tests/manual/principledmaterial/qml.qrc new file mode 100644 index 0000000000000000000000000000000000000000..a54696dfb6d9cccb75685b426f9d801e0ac4c70c --- /dev/null +++ b/tests/manual/principledmaterial/qml.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>MaterialControl.qml</file> + </qresource> +</RCC>