diff options
author | Jonas Karlsson <[email protected]> | 2025-05-28 20:05:22 +0200 |
---|---|---|
committer | Jonas Karlsson <[email protected]> | 2025-05-30 12:47:42 +0200 |
commit | 9cda9ae1ee5fa02a4626cf28b9a12b5116a09901 (patch) | |
tree | a12ee6a12e218c7d04d9af6c9b002a19d95ae366 | |
parent | 21b11ceec186d54ae37b7035a457b617990faf8d (diff) |
This is for testing lightmap baking of primitives and various
properties.
Change-Id: If9dcba14a560b0db8a62088088e4117d06b3b1c3
Reviewed-by: Jonas Karlsson <[email protected]>
Reviewed-by: Kristoffer Skau <[email protected]>
-rw-r--r-- | tests/manual/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/manual/bakedprimitives/CMakeLists.txt | 27 | ||||
-rw-r--r-- | tests/manual/bakedprimitives/SettingsPane.qml | 246 | ||||
-rw-r--r-- | tests/manual/bakedprimitives/main.cpp | 20 | ||||
-rw-r--r-- | tests/manual/bakedprimitives/main.qml | 132 |
5 files changed, 426 insertions, 0 deletions
diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt index 2b383a33..c29841dd 100644 --- a/tests/manual/CMakeLists.txt +++ b/tests/manual/CMakeLists.txt @@ -8,6 +8,7 @@ endif() add_subdirectory(3d_input) add_subdirectory(blendmodes) +add_subdirectory(bakedprimitives) add_subdirectory(cameralookat) add_subdirectory(cones_and_cylinders) add_subdirectory(dynamic3DTest) diff --git a/tests/manual/bakedprimitives/CMakeLists.txt b/tests/manual/bakedprimitives/CMakeLists.txt new file mode 100644 index 00000000..8772cca6 --- /dev/null +++ b/tests/manual/bakedprimitives/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright (C) 2025 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt_internal_add_manual_test(manual_test_bakedprimitives + GUI + SOURCES + main.cpp + LIBRARIES + Qt::Gui + Qt::Quick + Qt::Quick3D + Qt::Quick3DHelpers + Qt::Quick3DPrivate +) + +# Resources: +set(qml_resource_files + "main.qml" + "SettingsPane.qml" +) + +qt_internal_add_resource(manual_test_bakedprimitives "qml" + PREFIX + "/" + FILES + ${qml_resource_files} +) diff --git a/tests/manual/bakedprimitives/SettingsPane.qml b/tests/manual/bakedprimitives/SettingsPane.qml new file mode 100644 index 00000000..def16d42 --- /dev/null +++ b/tests/manual/bakedprimitives/SettingsPane.qml @@ -0,0 +1,246 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +Item { + id: root + width: settingsDrawer.width + height: parent.height + + property var viewport + + property bool lmEnabled: checkboxBakingEnabled.checked + property string shape0Source: shapeSelector0.currentText + property string shape1Source: shapeSelector1.currentText + property string shape2Source: shapeSelector2.currentText + property string shape3Source: shapeSelector3.currentText + + property string shape0Key: shapeKey0.text + property string shape1Key: shapeKey1.text + property string shape2Key: shapeKey2.text + property string shape3Key: shapeKey3.text + + property real shape0TPU: shape0TPU.value + property real shape1TPU: shape1TPU.value + property real shape2TPU: shape2TPU.value + property real shape3TPU: shape3TPU.value + + property real viewX: settingsDrawer.visible ? (settingsDrawer.x + settingsDrawer.width) : 0 + + RoundButton { + id: iconOpen + padding: 10 + x: padding + root.viewX + y: padding + text: "=" + onClicked: { + settingsDrawer.visible = !settingsDrawer.visible + } + } + + Drawer { + id: settingsDrawer + edge: Qt.LeftEdge + interactive: false + modal: false + height: parent.height + + enter: Transition { + NumberAnimation { + property: "position" + to: 1.0 + duration: 400 + easing.type: Easing.InOutQuad + } + } + + exit: Transition { + NumberAnimation { + property: "position" + to: 0.0 + duration: 400 + easing.type: Easing.InOutQuad + } + } + + Page { + anchors.fill: parent + + header: ToolBar { + width: parent.width + Label { + anchors.horizontalCenter: parent.horizontalCenter + text: "Settings" + font.pointSize: 17 + } + } + + ScrollView { + anchors.fill: parent + ScrollBar.vertical.policy: ScrollBar.AlwaysOn + padding: 10 + contentHeight: settingsArea.implicitHeight + + ColumnLayout { + id: settingsArea + width: parent.width + spacing: 5 + + component SliderWithValue: RowLayout { + id: sliderWithValue + property alias value: slider.value + property alias from: slider.from + property alias to: slider.to + property alias stepSize: slider.stepSize + property int numDecimals: 3 + readonly property bool highlight: slider.hovered + || slider.pressed + Slider { + id: slider + stepSize: 0.01 + Layout.minimumWidth: 200 + Layout.maximumWidth: 200 + } + Label { + id: valueText + text: slider.value.toFixed( + sliderWithValue.numDecimals) + Layout.minimumWidth: 80 + Layout.maximumWidth: 80 + } + } + + CheckBox { + id: checkboxBakingEnabled + checked: true + text: qsTr("Enable Baking") + } + + Button { + text: "Bake lightmap" + onClicked: viewport.bakeLightmap() + } + + Button { + text: "Denoise lightmap" + onClicked: viewport.denoiseLightmap() + } + + Label { + text: "Shape A" + font.pointSize: 12 + font.bold: true + } + + ComboBox { + id: shapeSelector0 + model: ["#Sphere", "#Cone", "#Cube", "#Cylinder"] + currentIndex: 2 + } + + TextField { + id: shapeKey0 + text: "keyA" + } + + Text { + text: "Texels per unit: " + shape0TPU.value.toFixed(1) + } + + Slider { + id: shape0TPU + from: 0 + to: 1 + stepSize: 0.1 + } + + Label { + text: "Shape B" + font.pointSize: 12 + font.bold: true + } + + ComboBox { + id: shapeSelector1 + model: ["#Sphere", "#Cone", "#Cube", "#Cylinder"] + currentIndex: 0 + } + + TextField { + id: shapeKey1 + text: "keyB" + } + + Text { + text: "Texels per unit: " + shape1TPU.value.toFixed(1) + } + + Slider { + id: shape1TPU + from: 0 + to: 1 + stepSize: 0.1 + } + + Label { + text: "Shape C" + font.pointSize: 12 + font.bold: true + } + + ComboBox { + id: shapeSelector2 + model: ["#Sphere", "#Cone", "#Cube", "#Cylinder"] + currentIndex: 1 + } + + TextField { + id: shapeKey2 + text: "keyC" + } + + Text { + text: "Texels per unit: " + shape2TPU.value.toFixed(1) + } + + Slider { + id: shape2TPU + from: 0 + to: 1 + stepSize: 0.1 + } + + Label { + text: "Shape D" + font.pointSize: 12 + font.bold: true + } + + ComboBox { + id: shapeSelector3 + model: ["#Sphere", "#Cone", "#Cube", "#Cylinder"] + currentIndex: 3 + } + + TextField { + id: shapeKey3 + text: "keyD" + } + + Text { + text: "Texels per unit: " + shape3TPU.value.toFixed(1) + } + + Slider { + id: shape3TPU + from: 0 + to: 1 + stepSize: 0.1 + } + } + } + } + } +} diff --git a/tests/manual/bakedprimitives/main.cpp b/tests/manual/bakedprimitives/main.cpp new file mode 100644 index 00000000..e699cd9d --- /dev/null +++ b/tests/manual/bakedprimitives/main.cpp @@ -0,0 +1,20 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QGuiApplication> +#include <QQmlApplicationEngine> +#include <QtQuick3D/qquick3d.h> + +int main(int argc, char *argv[]) +{ + qputenv("QT_QUICK_CONTROLS_STYLE", "Basic"); + QGuiApplication app(argc, argv); + QSurfaceFormat::setDefaultFormat(QQuick3D::idealSurfaceFormat()); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + if (engine.rootObjects().isEmpty()) + return -1; + + return app.exec(); +} diff --git a/tests/manual/bakedprimitives/main.qml b/tests/manual/bakedprimitives/main.qml new file mode 100644 index 00000000..46a36f85 --- /dev/null +++ b/tests/manual/bakedprimitives/main.qml @@ -0,0 +1,132 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import QtQuick3D +import QtQuick3D.Helpers + +Window { + width: 1280 + height: 720 + visible: true + + View3D { + id: view3d + anchors.fill: parent + + environment: SceneEnvironment { + backgroundMode: SceneEnvironment.Color + clearColor: "black" + } + + PerspectiveCamera { + id: camera + z: 300 + y: 100 + } + + property int lightBakeMode: settings.lmEnabled ? Light.BakeModeAll : Light.BakeModeDisabled + + PointLight { + bakeMode: view3d.lightBakeMode + y: 190 + castsShadow: true + shadowFactor: 75 + shadowBias: 20 + } + + PointLight { + bakeMode: view3d.lightBakeMode + y: 190 + x: 300 + castsShadow: true + shadowFactor: 75 + shadowBias: 20 + color: "pink" + } + + PointLight { + bakeMode: view3d.lightBakeMode + y: 30 + x: -300 + castsShadow: true + shadowFactor: 75 + shadowBias: 20 + color: "cyan" + } + + Model { + source: settings.shape0Source + usedInBakedLighting: true + bakedLightmap: BakedLightmap { + enabled: settings.lmEnabled + key: settings.shape0Key + } + texelsPerUnit: settings.shape0TPU + materials: PrincipledMaterial { + baseColor: "red" + } + scale: Qt.vector3d(3, 0.1, 3) + } + + Model { + source: settings.shape1Source + usedInBakedLighting: true + bakedLightmap: BakedLightmap { + enabled: settings.lmEnabled + key: settings.shape1Key + } + texelsPerUnit: settings.shape1TPU + materials: PrincipledMaterial { + baseColor: "blue" + } + position: Qt.vector3d(0, 100, 0) + scale: Qt.vector3d(0.5, 0.5, 0.5) + eulerRotation: Qt.vector3d(45, 0, 0) + } + + Model { + source: settings.shape2Source + usedInBakedLighting: true + bakedLightmap: BakedLightmap { + enabled: settings.lmEnabled + key: settings.shape2Key + } + texelsPerUnit: settings.shape2TPU + materials: PrincipledMaterial { + baseColor: "orange" + } + position: Qt.vector3d(100, 100, 0) + scale: Qt.vector3d(0.5, 0.5, 0.5) + eulerRotation: Qt.vector3d(45, 0, 0) + } + + Model { + source: settings.shape3Source + usedInBakedLighting: true + bakedLightmap: BakedLightmap { + enabled: settings.lmEnabled + key: settings.shape3Key + } + texelsPerUnit: settings.shape3TPU + materials: PrincipledMaterial { + baseColor: "cyan" + } + position: Qt.vector3d(-100, 100, 100) + scale: Qt.vector3d(0.5, 0.5, 0.5) + eulerRotation: Qt.vector3d(45, 0, 0) + } + } + + WasdController { + controlledObject: camera + speed: 0.4 + shiftSpeed: 0.8 + } + + SettingsPane { + id: settings + viewport: view3d + } +} |