From 9c5bf588ab310e274fddffb252962e8abfa66bd2 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Fri, 27 Jan 2017 15:39:09 +0100 Subject: Adding PBR lighting to Qt3DExtras This is a first implementation which only exploits environment maps for lighting. It still needs to interact with the lights coming from Qt 3D API. It also provided a fully texture map based material. Improvements and plain colors variant of the material will come in later commits. Change-Id: Ifc6079e5c40484b6daac05692780495013b7c401 Reviewed-by: Sean Harmer --- .../defaults/qtexturedmetalroughmaterial_p.h | 119 +++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 src/extras/defaults/qtexturedmetalroughmaterial_p.h (limited to 'src/extras/defaults/qtexturedmetalroughmaterial_p.h') diff --git a/src/extras/defaults/qtexturedmetalroughmaterial_p.h b/src/extras/defaults/qtexturedmetalroughmaterial_p.h new file mode 100644 index 000000000..9a5825efa --- /dev/null +++ b/src/extras/defaults/qtexturedmetalroughmaterial_p.h @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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$ +** +****************************************************************************/ + +#ifndef QT3DEXTRAS_QTEXTUREDMETALROUGHMATERIAL_P_H +#define QT3DEXTRAS_QTEXTUREDMETALROUGHMATERIAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +class QFilterKey; +class QEffect; +class QAbstractTexture; +class QTechnique; +class QParameter; +class QShaderProgram; +class QRenderPass; + +} // namespace Qt3DRender + +namespace Qt3DExtras { + +class QTexturedMetalRoughMaterial; + +class QTexturedMetalRoughMaterialPrivate : public Qt3DRender::QMaterialPrivate +{ +public: + QTexturedMetalRoughMaterialPrivate(); + + void init(); + + void handleAlbedoChanged(const QVariant &var); + void handleMetallicChanged(const QVariant &var); + void handleRoughnessChanged(const QVariant &var); + void handleAmbientOcclusionChanged(const QVariant &var); + void handleNormalChanged(const QVariant &var); + void handleEnvironmentIrradianceChanged(const QVariant &var); + void handleEnvironmentSpecularChanged(const QVariant &var); + void handleExposureChanged(const QVariant &var); + + Qt3DRender::QAbstractTexture *m_albedoTexture; + Qt3DRender::QAbstractTexture *m_metallicTexture; + Qt3DRender::QAbstractTexture *m_roughnessTexture; + Qt3DRender::QAbstractTexture *m_ambientOcclusionTexture; + Qt3DRender::QAbstractTexture *m_normalTexture; + Qt3DRender::QAbstractTexture *m_environmentIrradianceTexture; + Qt3DRender::QAbstractTexture *m_environmentSpecularTexture; + Qt3DRender::QParameter *m_albedoParameter; + Qt3DRender::QParameter *m_metallicParameter; + Qt3DRender::QParameter *m_roughnessParameter; + Qt3DRender::QParameter *m_ambientOcclusionParameter; + Qt3DRender::QParameter *m_normalParameter; + Qt3DRender::QParameter *m_environmentIrradianceParameter; + Qt3DRender::QParameter *m_environmentSpecularParameter; + Qt3DRender::QParameter *m_exposureParameter; + Qt3DRender::QEffect *m_metalRoughEffect; + Qt3DRender::QTechnique *m_metalRoughGL3Technique; + Qt3DRender::QRenderPass *m_metalRoughGL3RenderPass; + Qt3DRender::QShaderProgram *m_metalRoughGL3Shader; + Qt3DRender::QFilterKey *m_filterKey; + + Q_DECLARE_PUBLIC(QTexturedMetalRoughMaterial) +}; + +} // Qt3DExtras + +QT_END_NAMESPACE + +#endif // QT3DEXTRAS_QTEXTUREDMETALROUGHMATERIAL_P_H + -- cgit v1.2.3 From ae1a3bee761c29edffc5fdbe7b77140f1620a04a Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Mon, 30 Jan 2017 10:31:44 +0100 Subject: QTexturedMetalRoughMaterial: albedo really is baseColor Change-Id: I0e46976e2fa03eb1ad2f77b8c672bcc31c4da973 Reviewed-by: Sean Harmer --- src/extras/defaults/qtexturedmetalroughmaterial_p.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/extras/defaults/qtexturedmetalroughmaterial_p.h') diff --git a/src/extras/defaults/qtexturedmetalroughmaterial_p.h b/src/extras/defaults/qtexturedmetalroughmaterial_p.h index 9a5825efa..84b0e7d77 100644 --- a/src/extras/defaults/qtexturedmetalroughmaterial_p.h +++ b/src/extras/defaults/qtexturedmetalroughmaterial_p.h @@ -78,7 +78,7 @@ public: void init(); - void handleAlbedoChanged(const QVariant &var); + void handleBaseColorChanged(const QVariant &var); void handleMetallicChanged(const QVariant &var); void handleRoughnessChanged(const QVariant &var); void handleAmbientOcclusionChanged(const QVariant &var); @@ -87,14 +87,14 @@ public: void handleEnvironmentSpecularChanged(const QVariant &var); void handleExposureChanged(const QVariant &var); - Qt3DRender::QAbstractTexture *m_albedoTexture; + Qt3DRender::QAbstractTexture *m_baseColorTexture; Qt3DRender::QAbstractTexture *m_metallicTexture; Qt3DRender::QAbstractTexture *m_roughnessTexture; Qt3DRender::QAbstractTexture *m_ambientOcclusionTexture; Qt3DRender::QAbstractTexture *m_normalTexture; Qt3DRender::QAbstractTexture *m_environmentIrradianceTexture; Qt3DRender::QAbstractTexture *m_environmentSpecularTexture; - Qt3DRender::QParameter *m_albedoParameter; + Qt3DRender::QParameter *m_baseColorParameter; Qt3DRender::QParameter *m_metallicParameter; Qt3DRender::QParameter *m_roughnessParameter; Qt3DRender::QParameter *m_ambientOcclusionParameter; -- cgit v1.2.3 From 708720b8a1056aec2c62a3a2467a324d62a25ee1 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Tue, 31 Jan 2017 16:37:26 +0100 Subject: Remove exposure property from metal/rough materials This is now controlled on the camera lens as it should be. No need to have that per material instance anymore. Change-Id: I2e46a38f2cc2f2e2d670ed73a2be6d98464b21b1 Reviewed-by: Sean Harmer --- src/extras/defaults/qtexturedmetalroughmaterial_p.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/extras/defaults/qtexturedmetalroughmaterial_p.h') diff --git a/src/extras/defaults/qtexturedmetalroughmaterial_p.h b/src/extras/defaults/qtexturedmetalroughmaterial_p.h index 84b0e7d77..54fdb73b2 100644 --- a/src/extras/defaults/qtexturedmetalroughmaterial_p.h +++ b/src/extras/defaults/qtexturedmetalroughmaterial_p.h @@ -85,7 +85,6 @@ public: void handleNormalChanged(const QVariant &var); void handleEnvironmentIrradianceChanged(const QVariant &var); void handleEnvironmentSpecularChanged(const QVariant &var); - void handleExposureChanged(const QVariant &var); Qt3DRender::QAbstractTexture *m_baseColorTexture; Qt3DRender::QAbstractTexture *m_metallicTexture; @@ -101,7 +100,6 @@ public: Qt3DRender::QParameter *m_normalParameter; Qt3DRender::QParameter *m_environmentIrradianceParameter; Qt3DRender::QParameter *m_environmentSpecularParameter; - Qt3DRender::QParameter *m_exposureParameter; Qt3DRender::QEffect *m_metalRoughEffect; Qt3DRender::QTechnique *m_metalRoughGL3Technique; Qt3DRender::QRenderPass *m_metalRoughGL3RenderPass; -- cgit v1.2.3 From b5f76df191c10dfcd0688fc79bd3af12dbe74bbb Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Thu, 16 Feb 2017 11:15:54 +0100 Subject: Metal/Rough materials: metallic -> metalness Rename decided during API review in order to match with roughness. Change-Id: I4b1a13e6028ba410fb31a80e6c64f9539581f8c4 Task-Id: QTBUG-58894 Reviewed-by: Paul Lemire --- src/extras/defaults/qtexturedmetalroughmaterial_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/extras/defaults/qtexturedmetalroughmaterial_p.h') diff --git a/src/extras/defaults/qtexturedmetalroughmaterial_p.h b/src/extras/defaults/qtexturedmetalroughmaterial_p.h index 54fdb73b2..084824304 100644 --- a/src/extras/defaults/qtexturedmetalroughmaterial_p.h +++ b/src/extras/defaults/qtexturedmetalroughmaterial_p.h @@ -87,14 +87,14 @@ public: void handleEnvironmentSpecularChanged(const QVariant &var); Qt3DRender::QAbstractTexture *m_baseColorTexture; - Qt3DRender::QAbstractTexture *m_metallicTexture; + Qt3DRender::QAbstractTexture *m_metalnessTexture; Qt3DRender::QAbstractTexture *m_roughnessTexture; Qt3DRender::QAbstractTexture *m_ambientOcclusionTexture; Qt3DRender::QAbstractTexture *m_normalTexture; Qt3DRender::QAbstractTexture *m_environmentIrradianceTexture; Qt3DRender::QAbstractTexture *m_environmentSpecularTexture; Qt3DRender::QParameter *m_baseColorParameter; - Qt3DRender::QParameter *m_metallicParameter; + Qt3DRender::QParameter *m_metalnessParameter; Qt3DRender::QParameter *m_roughnessParameter; Qt3DRender::QParameter *m_ambientOcclusionParameter; Qt3DRender::QParameter *m_normalParameter; -- cgit v1.2.3 From 2a485273c1da1f56412bfd19795ac5a29331b770 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Thu, 23 Feb 2017 16:27:24 +0100 Subject: Remove env light API from metal/rough materials Now that EnvironmentLight is available in Qt3DRender this is no longer necessary. We have a much better way to set the environment lighting now. Change-Id: I492d1383aaf4e60b434c7ab94f3696e499545f9f Reviewed-by: Sean Harmer --- src/extras/defaults/qtexturedmetalroughmaterial_p.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/extras/defaults/qtexturedmetalroughmaterial_p.h') diff --git a/src/extras/defaults/qtexturedmetalroughmaterial_p.h b/src/extras/defaults/qtexturedmetalroughmaterial_p.h index 084824304..8972726e5 100644 --- a/src/extras/defaults/qtexturedmetalroughmaterial_p.h +++ b/src/extras/defaults/qtexturedmetalroughmaterial_p.h @@ -83,8 +83,6 @@ public: void handleRoughnessChanged(const QVariant &var); void handleAmbientOcclusionChanged(const QVariant &var); void handleNormalChanged(const QVariant &var); - void handleEnvironmentIrradianceChanged(const QVariant &var); - void handleEnvironmentSpecularChanged(const QVariant &var); Qt3DRender::QAbstractTexture *m_baseColorTexture; Qt3DRender::QAbstractTexture *m_metalnessTexture; -- cgit v1.2.3