summaryrefslogtreecommitdiffstats
path: root/src/extras/defaults
diff options
context:
space:
mode:
Diffstat (limited to 'src/extras/defaults')
-rw-r--r--src/extras/defaults/defaults.pri14
-rw-r--r--src/extras/defaults/qdiffusemapmaterial.cpp7
-rw-r--r--src/extras/defaults/qdiffusemapmaterial.h2
-rw-r--r--src/extras/defaults/qdiffusespecularmapmaterial.cpp7
-rw-r--r--src/extras/defaults/qdiffusespecularmapmaterial.h2
-rw-r--r--src/extras/defaults/qfirstpersoncameracontroller.cpp143
-rw-r--r--src/extras/defaults/qfirstpersoncameracontroller.h59
-rw-r--r--src/extras/defaults/qfirstpersoncameracontroller_p.h11
-rw-r--r--src/extras/defaults/qforwardrenderer.cpp61
-rw-r--r--src/extras/defaults/qforwardrenderer.h14
-rw-r--r--src/extras/defaults/qgoochmaterial.cpp2
-rw-r--r--src/extras/defaults/qgoochmaterial.h2
-rw-r--r--src/extras/defaults/qmetalroughmaterial.cpp240
-rw-r--r--src/extras/defaults/qmetalroughmaterial.h93
-rw-r--r--src/extras/defaults/qmetalroughmaterial_p.h106
-rw-r--r--src/extras/defaults/qnormaldiffusemapalphamaterial.cpp7
-rw-r--r--src/extras/defaults/qnormaldiffusemapalphamaterial_p.h2
-rw-r--r--src/extras/defaults/qnormaldiffusemapmaterial.cpp8
-rw-r--r--src/extras/defaults/qnormaldiffusemapmaterial.h2
-rw-r--r--src/extras/defaults/qnormaldiffusemapmaterial_p.h2
-rw-r--r--src/extras/defaults/qnormaldiffusespecularmapmaterial.cpp7
-rw-r--r--src/extras/defaults/qnormaldiffusespecularmapmaterial.h2
-rw-r--r--src/extras/defaults/qorbitcameracontroller.cpp20
-rw-r--r--src/extras/defaults/qorbitcameracontroller.h2
-rw-r--r--src/extras/defaults/qorbitcameracontroller_p.h7
-rw-r--r--src/extras/defaults/qpervertexcolormaterial.cpp7
-rw-r--r--src/extras/defaults/qpervertexcolormaterial.h2
-rw-r--r--src/extras/defaults/qphongalphamaterial.cpp7
-rw-r--r--src/extras/defaults/qphongalphamaterial.h6
-rw-r--r--src/extras/defaults/qphongmaterial.cpp8
-rw-r--r--src/extras/defaults/qphongmaterial.h2
-rw-r--r--src/extras/defaults/qskyboxentity.cpp56
-rw-r--r--src/extras/defaults/qskyboxentity.h13
-rw-r--r--src/extras/defaults/qskyboxentity_p.h6
-rw-r--r--src/extras/defaults/qt3dwindow.cpp90
-rw-r--r--src/extras/defaults/qt3dwindow.h28
-rw-r--r--src/extras/defaults/qt3dwindow_p.h92
-rw-r--r--src/extras/defaults/qtexturedmetalroughmaterial.cpp373
-rw-r--r--src/extras/defaults/qtexturedmetalroughmaterial.h96
-rw-r--r--src/extras/defaults/qtexturedmetalroughmaterial_p.h115
-rw-r--r--src/extras/defaults/qtexturematerial.cpp209
-rw-r--r--src/extras/defaults/qtexturematerial.h87
-rw-r--r--src/extras/defaults/qtexturematerial_p.h104
43 files changed, 1934 insertions, 189 deletions
diff --git a/src/extras/defaults/defaults.pri b/src/extras/defaults/defaults.pri
index 21ef6fef6..8a18fb6e9 100644
--- a/src/extras/defaults/defaults.pri
+++ b/src/extras/defaults/defaults.pri
@@ -4,6 +4,7 @@ HEADERS += \
$$PWD/qphongmaterial.h \
$$PWD/qphongmaterial_p.h \
$$PWD/qdiffusemapmaterial_p.h \
+ $$PWD/qdiffusemapmaterial.h \
$$PWD/qnormaldiffusespecularmapmaterial.h \
$$PWD/qnormaldiffusespecularmapmaterial_p.h \
$$PWD/qnormaldiffusemapmaterial.h \
@@ -23,13 +24,19 @@ HEADERS += \
$$PWD/qphongalphamaterial.h \
$$PWD/qphongalphamaterial_p.h \
$$PWD/qt3dwindow.h \
+ $$PWD/qt3dwindow_p.h \
$$PWD/qfirstpersoncameracontroller.h \
$$PWD/qfirstpersoncameracontroller_p.h \
$$PWD/qorbitcameracontroller.h \
$$PWD/qorbitcameracontroller_p.h \
+ $$PWD/qtexturematerial.h \
+ $$PWD/qtexturematerial_p.h \
+ $$PWD/qmetalroughmaterial.h \
+ $$PWD/qmetalroughmaterial_p.h \
+ $$PWD/qtexturedmetalroughmaterial.h \
+ $$PWD/qtexturedmetalroughmaterial_p.h \
$$PWD/qmorphphongmaterial.h \
- $$PWD/qmorphphongmaterial_p.h \
- $$PWD/qdiffusemapmaterial.h
+ $$PWD/qmorphphongmaterial_p.h
SOURCES += \
$$PWD/qphongmaterial.cpp \
@@ -46,5 +53,8 @@ SOURCES += \
$$PWD/qt3dwindow.cpp \
$$PWD/qfirstpersoncameracontroller.cpp \
$$PWD/qorbitcameracontroller.cpp \
+ $$PWD/qtexturematerial.cpp \
+ $$PWD/qmetalroughmaterial.cpp \
+ $$PWD/qtexturedmetalroughmaterial.cpp \
$$PWD/qmorphphongmaterial.cpp
diff --git a/src/extras/defaults/qdiffusemapmaterial.cpp b/src/extras/defaults/qdiffusemapmaterial.cpp
index b3aa3bf00..a6da98a2e 100644
--- a/src/extras/defaults/qdiffusemapmaterial.cpp
+++ b/src/extras/defaults/qdiffusemapmaterial.cpp
@@ -39,6 +39,7 @@
#include "qdiffusemapmaterial.h"
#include "qdiffusemapmaterial_p.h"
+
#include <Qt3DRender/qfilterkey.h>
#include <Qt3DRender/qmaterial.h>
#include <Qt3DRender/qeffect.h>
@@ -48,9 +49,9 @@
#include <Qt3DRender/qparameter.h>
#include <Qt3DRender/qrenderpass.h>
#include <Qt3DRender/qgraphicsapifilter.h>
-#include <QUrl>
-#include <QVector3D>
-#include <QVector4D>
+#include <QtCore/QUrl>
+#include <QtGui/QVector3D>
+#include <QtGui/QVector4D>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qdiffusemapmaterial.h b/src/extras/defaults/qdiffusemapmaterial.h
index b6bba9b36..e6c632ed2 100644
--- a/src/extras/defaults/qdiffusemapmaterial.h
+++ b/src/extras/defaults/qdiffusemapmaterial.h
@@ -42,7 +42,7 @@
#include <Qt3DExtras/qt3dextras_global.h>
#include <Qt3DRender/qmaterial.h>
-#include <QColor>
+#include <QtGui/QColor>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qdiffusespecularmapmaterial.cpp b/src/extras/defaults/qdiffusespecularmapmaterial.cpp
index 4b79eea2b..615ee6305 100644
--- a/src/extras/defaults/qdiffusespecularmapmaterial.cpp
+++ b/src/extras/defaults/qdiffusespecularmapmaterial.cpp
@@ -39,6 +39,7 @@
#include "qdiffusespecularmapmaterial.h"
#include "qdiffusespecularmapmaterial_p.h"
+
#include <Qt3DRender/qfilterkey.h>
#include <Qt3DRender/qmaterial.h>
#include <Qt3DRender/qeffect.h>
@@ -48,9 +49,9 @@
#include <Qt3DRender/qparameter.h>
#include <Qt3DRender/qrenderpass.h>
#include <Qt3DRender/qgraphicsapifilter.h>
-#include <QUrl>
-#include <QVector3D>
-#include <QVector4D>
+#include <QtCore/QUrl>
+#include <QtGui/QVector3D>
+#include <QtGui/QVector4D>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qdiffusespecularmapmaterial.h b/src/extras/defaults/qdiffusespecularmapmaterial.h
index d5dd053bd..d86948673 100644
--- a/src/extras/defaults/qdiffusespecularmapmaterial.h
+++ b/src/extras/defaults/qdiffusespecularmapmaterial.h
@@ -42,7 +42,7 @@
#include <Qt3DExtras/qt3dextras_global.h>
#include <Qt3DRender/qmaterial.h>
-#include <QColor>
+#include <QtGui/QColor>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qfirstpersoncameracontroller.cpp b/src/extras/defaults/qfirstpersoncameracontroller.cpp
index e31448eb8..5321bfcf2 100644
--- a/src/extras/defaults/qfirstpersoncameracontroller.cpp
+++ b/src/extras/defaults/qfirstpersoncameracontroller.cpp
@@ -1,66 +1,53 @@
/****************************************************************************
**
** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
+** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
+** $QT_BEGIN_LICENSE:LGPL3$
** 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.
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
+** 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.LGPLv3 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.html.
**
-** "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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "qfirstpersoncameracontroller_p.h"
#include "qfirstpersoncameracontroller.h"
-#include <Qt3DRender/QCamera>
-#include <Qt3DInput/QAxis>
-#include <Qt3DInput/QAnalogAxisInput>
-#include <Qt3DInput/QButtonAxisInput>
+#include "qfirstpersoncameracontroller_p.h"
+
#include <Qt3DInput/QAction>
#include <Qt3DInput/QActionInput>
-#include <Qt3DInput/QLogicalDevice>
+#include <Qt3DInput/QAnalogAxisInput>
+#include <Qt3DInput/QAxis>
+#include <Qt3DInput/QButtonAxisInput>
+#include <Qt3DLogic/QFrameAction>
#include <Qt3DInput/QKeyboardDevice>
+#include <Qt3DInput/QLogicalDevice>
#include <Qt3DInput/QMouseDevice>
#include <Qt3DInput/QMouseEvent>
-#include <Qt3DLogic/QFrameAction>
+#include <Qt3DRender/QCamera>
QT_BEGIN_NAMESPACE
@@ -80,6 +67,8 @@ QFirstPersonCameraControllerPrivate::QFirstPersonCameraControllerPrivate()
, m_fineMotionKeyInput(new Qt3DInput::QActionInput())
, m_mouseRxInput(new Qt3DInput::QAnalogAxisInput())
, m_mouseRyInput(new Qt3DInput::QAnalogAxisInput())
+ , m_mouseTzXInput(new Qt3DInput::QAnalogAxisInput())
+ , m_mouseTzYInput(new Qt3DInput::QAnalogAxisInput())
, m_keyboardTxPosInput(new Qt3DInput::QButtonAxisInput())
, m_keyboardTyPosInput(new Qt3DInput::QButtonAxisInput())
, m_keyboardTzPosInput(new Qt3DInput::QButtonAxisInput())
@@ -92,6 +81,8 @@ QFirstPersonCameraControllerPrivate::QFirstPersonCameraControllerPrivate()
, m_frameAction(new Qt3DLogic::QFrameAction())
, m_linearSpeed(10.0f)
, m_lookSpeed(180.0f)
+ , m_acceleration(-1.0f)
+ , m_deceleration(-1.0f)
, m_firstPersonUp(QVector3D(0.0f, 1.0f, 0.0f))
{}
@@ -121,6 +112,16 @@ void QFirstPersonCameraControllerPrivate::init()
m_mouseRyInput->setSourceDevice(m_mouseDevice);
m_ryAxis->addInput(m_mouseRyInput);
+ // Mouse Wheel X
+ m_mouseTzXInput->setAxis(Qt3DInput::QMouseDevice::WheelX);
+ m_mouseTzXInput->setSourceDevice(m_mouseDevice);
+ m_tzAxis->addInput(m_mouseTzXInput);
+
+ // Mouse Wheel Y
+ m_mouseTzYInput->setAxis(Qt3DInput::QMouseDevice::WheelY);
+ m_mouseTzYInput->setSourceDevice(m_mouseDevice);
+ m_tzAxis->addInput(m_mouseTzYInput);
+
// Keyboard Pos Tx
m_keyboardTxPosInput->setButtons(QVector<int>() << Qt::Key_Right);
m_keyboardTxPosInput->setScale(1.0f);
@@ -167,6 +168,8 @@ void QFirstPersonCameraControllerPrivate::init()
m_logicalDevice->addAxis(m_tyAxis);
m_logicalDevice->addAxis(m_tzAxis);
+ applyAccelerations();
+
Q_Q(QFirstPersonCameraController);
//// FrameAction
@@ -181,6 +184,23 @@ void QFirstPersonCameraControllerPrivate::init()
q->addComponent(m_logicalDevice);
}
+void QFirstPersonCameraControllerPrivate::applyAccelerations()
+{
+ const auto inputs = {
+ m_keyboardTxPosInput,
+ m_keyboardTyPosInput,
+ m_keyboardTzPosInput,
+ m_keyboardTxNegInput,
+ m_keyboardTyNegInput,
+ m_keyboardTzNegInput
+ };
+
+ for (auto input : inputs) {
+ input->setAcceleration(m_acceleration);
+ input->setDeceleration(m_deceleration);
+ }
+}
+
void QFirstPersonCameraControllerPrivate::_q_onTriggered(float dt)
{
if (m_camera != nullptr) {
@@ -215,6 +235,9 @@ void QFirstPersonCameraControllerPrivate::_q_onTriggered(float dt)
\li While the left mouse button is pressed, mouse movement along x-axis pans the camera and
movement along y-axis tilts it.
\row
+ \li Mouse scroll wheel
+ \li Zooms the camera in and out without changing the view center.
+ \row
\li Shift key
\li Turns the fine motion control active while pressed. Makes mouse pan and tilt less
sensitive.
@@ -273,6 +296,28 @@ float QFirstPersonCameraController::lookSpeed() const
return d->m_lookSpeed;
}
+/*!
+ \property QFirstPersonCameraController::acceleration
+
+ Holds the current acceleration of the camera controller.
+*/
+float QFirstPersonCameraController::acceleration() const
+{
+ Q_D(const QFirstPersonCameraController);
+ return d->m_acceleration;
+}
+
+/*!
+ \property QFirstPersonCameraController::deceleration
+
+ Holds the current deceleration of the camera controller.
+*/
+float QFirstPersonCameraController::deceleration() const
+{
+ Q_D(const QFirstPersonCameraController);
+ return d->m_deceleration;
+}
+
void QFirstPersonCameraController::setCamera(Qt3DRender::QCamera *camera)
{
Q_D(QFirstPersonCameraController);
@@ -312,6 +357,26 @@ void QFirstPersonCameraController::setLookSpeed(float lookSpeed)
}
}
+void QFirstPersonCameraController::setAcceleration(float acceleration)
+{
+ Q_D(QFirstPersonCameraController);
+ if (d->m_acceleration != acceleration) {
+ d->m_acceleration = acceleration;
+ d->applyAccelerations();
+ emit accelerationChanged(acceleration);
+ }
+}
+
+void QFirstPersonCameraController::setDeceleration(float deceleration)
+{
+ Q_D(QFirstPersonCameraController);
+ if (d->m_deceleration != deceleration) {
+ d->m_deceleration = deceleration;
+ d->applyAccelerations();
+ emit decelerationChanged(deceleration);
+ }
+}
+
} // Qt3DExtras
QT_END_NAMESPACE
diff --git a/src/extras/defaults/qfirstpersoncameracontroller.h b/src/extras/defaults/qfirstpersoncameracontroller.h
index e50d4db5a..3f7a6acc4 100644
--- a/src/extras/defaults/qfirstpersoncameracontroller.h
+++ b/src/extras/defaults/qfirstpersoncameracontroller.h
@@ -1,48 +1,34 @@
/****************************************************************************
**
** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: https://www.qt.io/licensing/
+** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt3D module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:BSD$
+** $QT_BEGIN_LICENSE:LGPL3$
** 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.
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
+** 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.LGPLv3 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.html.
**
-** "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."
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
@@ -70,7 +56,8 @@ class QT3DEXTRASSHARED_EXPORT QFirstPersonCameraController : public Qt3DCore::QE
Q_PROPERTY(Qt3DRender::QCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged)
Q_PROPERTY(float linearSpeed READ linearSpeed WRITE setLinearSpeed NOTIFY linearSpeedChanged)
Q_PROPERTY(float lookSpeed READ lookSpeed WRITE setLookSpeed NOTIFY lookSpeedChanged)
-
+ Q_PROPERTY(float acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged)
+ Q_PROPERTY(float deceleration READ deceleration WRITE setDeceleration NOTIFY decelerationChanged)
public:
explicit QFirstPersonCameraController(Qt3DCore::QNode *parent = nullptr);
~QFirstPersonCameraController();
@@ -78,15 +65,21 @@ public:
Qt3DRender::QCamera *camera() const;
float linearSpeed() const;
float lookSpeed() const;
+ float acceleration() const;
+ float deceleration() const;
void setCamera(Qt3DRender::QCamera *camera);
void setLinearSpeed(float linearSpeed);
void setLookSpeed(float lookSpeed);
+ void setAcceleration(float acceleration);
+ void setDeceleration(float deceleration);
Q_SIGNALS:
void cameraChanged();
void linearSpeedChanged();
void lookSpeedChanged();
+ void accelerationChanged(float acceleration);
+ void decelerationChanged(float deceleration);
private:
Q_DECLARE_PRIVATE(QFirstPersonCameraController)
diff --git a/src/extras/defaults/qfirstpersoncameracontroller_p.h b/src/extras/defaults/qfirstpersoncameracontroller_p.h
index 9ea830f85..48a7c7998 100644
--- a/src/extras/defaults/qfirstpersoncameracontroller_p.h
+++ b/src/extras/defaults/qfirstpersoncameracontroller_p.h
@@ -51,9 +51,11 @@
#ifndef QT3DEXTRAS_QFIRSTPERSONCAMERACONTROLLER_P_H
#define QT3DEXTRAS_QFIRSTPERSONCAMERACONTROLLER_P_H
+#include <Qt3DExtras/qfirstpersoncameracontroller.h>
+#include <QtGui/QVector3D>
+
#include <Qt3DCore/private/qentity_p.h>
-#include <QVector3D>
-#include "qfirstpersoncameracontroller.h"
+
//
// W A R N I N G
@@ -98,6 +100,7 @@ public:
QFirstPersonCameraControllerPrivate();
void init();
+ void applyAccelerations();
Qt3DRender::QCamera *m_camera;
@@ -115,6 +118,8 @@ public:
Qt3DInput::QAnalogAxisInput *m_mouseRxInput;
Qt3DInput::QAnalogAxisInput *m_mouseRyInput;
+ Qt3DInput::QAnalogAxisInput *m_mouseTzXInput;
+ Qt3DInput::QAnalogAxisInput *m_mouseTzYInput;
Qt3DInput::QButtonAxisInput *m_keyboardTxPosInput;
Qt3DInput::QButtonAxisInput *m_keyboardTyPosInput;
Qt3DInput::QButtonAxisInput *m_keyboardTzPosInput;
@@ -131,6 +136,8 @@ public:
float m_linearSpeed;
float m_lookSpeed;
+ float m_acceleration;
+ float m_deceleration;
QVector3D m_firstPersonUp;
void _q_onTriggered(float);
diff --git a/src/extras/defaults/qforwardrenderer.cpp b/src/extras/defaults/qforwardrenderer.cpp
index d556b58d3..3a5c6803b 100644
--- a/src/extras/defaults/qforwardrenderer.cpp
+++ b/src/extras/defaults/qforwardrenderer.cpp
@@ -134,6 +134,8 @@ QForwardRenderer::QForwardRenderer(QNode *parent)
QObject::connect(d->m_cameraSelector, &QCameraSelector::cameraChanged, this, &QForwardRenderer::cameraChanged);
QObject::connect(d->m_surfaceSelector, &QRenderSurfaceSelector::surfaceChanged, this, &QForwardRenderer::surfaceChanged);
QObject::connect(d->m_surfaceSelector, &QRenderSurfaceSelector::externalRenderTargetSizeChanged, this, &QForwardRenderer::externalRenderTargetSizeChanged);
+ QObject::connect(d->m_frustumCulling, &QFrustumCulling::enabledChanged, this, &QForwardRenderer::frustumCullingEnabledChanged);
+ QObject::connect(d->m_viewport, &QViewport::gammaChanged, this, &QForwardRenderer::gammaChanged);
d->init();
}
@@ -171,6 +173,18 @@ void QForwardRenderer::setExternalRenderTargetSize(const QSize &size)
d->m_surfaceSelector->setExternalRenderTargetSize(size);
}
+void QForwardRenderer::setFrustumCullingEnabled(bool enabled)
+{
+ Q_D(QForwardRenderer);
+ d->m_frustumCulling->setEnabled(enabled);
+}
+
+void QForwardRenderer::setGamma(float gamma)
+{
+ Q_D(QForwardRenderer);
+ d->m_viewport->setGamma(gamma);
+}
+
/*!
\qmlproperty rect ForwardRenderer::viewportRect
@@ -226,6 +240,21 @@ Qt3DCore::QEntity *QForwardRenderer::camera() const
}
/*!
+ \qmlproperty Object ForwardRenderer::window
+
+ Holds the current render surface.
+
+ \deprecated
+*/
+/*!
+ \property QForwardRenderer::window
+
+ Holds the current render surface.
+
+ \deprecated
+*/
+
+/*!
\qmlproperty Object ForwardRenderer::surface
Holds the current render surface.
@@ -247,6 +276,38 @@ QSize QForwardRenderer::externalRenderTargetSize() const
return d->m_surfaceSelector->externalRenderTargetSize();
}
+/*!
+ \qmlproperty color ForwardRenderer::frustumCulling
+
+ Indicates if the renderer applies frustum culling to the scene.
+*/
+/*!
+ \property QForwardRenderer::frustumCulling
+
+ Indicates if the renderer applies frustum culling to the scene.
+*/
+bool QForwardRenderer::isFrustumCullingEnabled() const
+{
+ Q_D(const QForwardRenderer);
+ return d->m_frustumCulling->isEnabled();
+}
+
+/*!
+ \qmlproperty color ForwardRenderer::gamma
+
+ Holds the gamma value the renderer applies to the scene.
+*/
+/*!
+ \property QForwardRenderer::gamma
+
+ Holds the gamma value the renderer applies to the scene.
+*/
+float QForwardRenderer::gamma() const
+{
+ Q_D(const QForwardRenderer);
+ return d->m_viewport->gamma();
+}
+
} // namespace Qt3DExtras
QT_END_NAMESPACE
diff --git a/src/extras/defaults/qforwardrenderer.h b/src/extras/defaults/qforwardrenderer.h
index 01f50f452..7b6078169 100644
--- a/src/extras/defaults/qforwardrenderer.h
+++ b/src/extras/defaults/qforwardrenderer.h
@@ -42,8 +42,9 @@
#include <Qt3DExtras/qt3dextras_global.h>
#include <Qt3DRender/qtechniquefilter.h>
-#include <QRectF>
-#include <QColor>
+#include <QtCore/QRectF>
+#include <QtGui/QColor>
+
QT_BEGIN_NAMESPACE
@@ -57,10 +58,13 @@ class QT3DEXTRASSHARED_EXPORT QForwardRenderer : public Qt3DRender::QTechniqueFi
{
Q_OBJECT
Q_PROPERTY(QObject *surface READ surface WRITE setSurface NOTIFY surfaceChanged)
+ Q_PROPERTY(QObject *window READ surface WRITE setSurface NOTIFY surfaceChanged)
Q_PROPERTY(QRectF viewportRect READ viewportRect WRITE setViewportRect NOTIFY viewportRectChanged)
Q_PROPERTY(QColor clearColor READ clearColor WRITE setClearColor NOTIFY clearColorChanged)
Q_PROPERTY(Qt3DCore::QEntity *camera READ camera WRITE setCamera NOTIFY cameraChanged)
Q_PROPERTY(QSize externalRenderTargetSize READ externalRenderTargetSize WRITE setExternalRenderTargetSize NOTIFY externalRenderTargetSizeChanged)
+ Q_PROPERTY(bool frustumCulling READ isFrustumCullingEnabled WRITE setFrustumCullingEnabled NOTIFY frustumCullingEnabledChanged)
+ Q_PROPERTY(float gamma READ gamma WRITE setGamma NOTIFY gammaChanged REVISION 9)
public:
explicit QForwardRenderer(Qt3DCore::QNode *parent = nullptr);
~QForwardRenderer();
@@ -70,6 +74,8 @@ public:
Qt3DCore::QEntity *camera() const;
QObject *surface() const;
QSize externalRenderTargetSize() const;
+ bool isFrustumCullingEnabled() const;
+ float gamma() const;
public Q_SLOTS:
void setViewportRect(const QRectF &viewportRect);
@@ -77,6 +83,8 @@ public Q_SLOTS:
void setCamera(Qt3DCore::QEntity *camera);
void setSurface(QObject * surface);
void setExternalRenderTargetSize(const QSize &size);
+ void setFrustumCullingEnabled(bool enabled);
+ void setGamma(float gamma);
Q_SIGNALS:
void viewportRectChanged(const QRectF &viewportRect);
@@ -84,6 +92,8 @@ Q_SIGNALS:
void cameraChanged(Qt3DCore::QEntity *camera);
void surfaceChanged(QObject *surface);
void externalRenderTargetSizeChanged(const QSize &size);
+ void frustumCullingEnabledChanged(bool enabled);
+ void gammaChanged(float gamma);
private:
Q_DECLARE_PRIVATE(QForwardRenderer)
diff --git a/src/extras/defaults/qgoochmaterial.cpp b/src/extras/defaults/qgoochmaterial.cpp
index f2f34fc84..ba7ef8dab 100644
--- a/src/extras/defaults/qgoochmaterial.cpp
+++ b/src/extras/defaults/qgoochmaterial.cpp
@@ -39,13 +39,13 @@
#include "qgoochmaterial.h"
#include "qgoochmaterial_p.h"
+
#include <Qt3DRender/qfilterkey.h>
#include <Qt3DRender/qeffect.h>
#include <Qt3DRender/qgraphicsapifilter.h>
#include <Qt3DRender/qparameter.h>
#include <Qt3DRender/qrenderpass.h>
#include <Qt3DRender/qtechnique.h>
-
#include <QtCore/qurl.h>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qgoochmaterial.h b/src/extras/defaults/qgoochmaterial.h
index 232257513..6afddfe8b 100644
--- a/src/extras/defaults/qgoochmaterial.h
+++ b/src/extras/defaults/qgoochmaterial.h
@@ -42,7 +42,7 @@
#include <Qt3DExtras/qt3dextras_global.h>
#include <Qt3DRender/qmaterial.h>
-#include <QColor>
+#include <QtGui/QColor>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qmetalroughmaterial.cpp b/src/extras/defaults/qmetalroughmaterial.cpp
new file mode 100644
index 000000000..ea213ab82
--- /dev/null
+++ b/src/extras/defaults/qmetalroughmaterial.cpp
@@ -0,0 +1,240 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include "qmetalroughmaterial.h"
+#include "qmetalroughmaterial_p.h"
+#include <Qt3DRender/qfilterkey.h>
+#include <Qt3DRender/qmaterial.h>
+#include <Qt3DRender/qeffect.h>
+#include <Qt3DRender/qtexture.h>
+#include <Qt3DRender/qtechnique.h>
+#include <Qt3DRender/qshaderprogram.h>
+#include <Qt3DRender/qparameter.h>
+#include <Qt3DRender/qrenderpass.h>
+#include <Qt3DRender/qgraphicsapifilter.h>
+#include <QUrl>
+#include <QVector3D>
+#include <QVector4D>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DRender;
+
+namespace Qt3DExtras {
+
+QMetalRoughMaterialPrivate::QMetalRoughMaterialPrivate()
+ : QMaterialPrivate()
+ , m_environmentIrradianceTexture(new QTexture2D())
+ , m_environmentSpecularTexture(new QTexture2D())
+ , m_baseColorParameter(new QParameter(QStringLiteral("baseColor"), QColor("grey")))
+ , m_metalnessParameter(new QParameter(QStringLiteral("metalness"), 0.0f))
+ , m_roughnessParameter(new QParameter(QStringLiteral("roughness"), 0.0f))
+ , m_environmentIrradianceParameter(new QParameter(QStringLiteral("envLight.irradiance"), m_environmentIrradianceTexture))
+ , m_environmentSpecularParameter(new QParameter(QStringLiteral("envLight.specular"), m_environmentSpecularTexture))
+ , m_metalRoughEffect(new QEffect())
+ , m_metalRoughGL3Technique(new QTechnique())
+ , m_metalRoughGL3RenderPass(new QRenderPass())
+ , m_metalRoughGL3Shader(new QShaderProgram())
+ , m_filterKey(new QFilterKey)
+{
+ m_environmentIrradianceTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_environmentIrradianceTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_environmentIrradianceTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_environmentIrradianceTexture->setGenerateMipMaps(true);
+ m_environmentIrradianceTexture->setMaximumAnisotropy(16.0f);
+
+ m_environmentSpecularTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_environmentSpecularTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_environmentSpecularTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_environmentSpecularTexture->setGenerateMipMaps(true);
+ m_environmentSpecularTexture->setMaximumAnisotropy(16.0f);
+}
+
+void QMetalRoughMaterialPrivate::init()
+{
+ connect(m_baseColorParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QMetalRoughMaterialPrivate::handleBaseColorChanged);
+ connect(m_metalnessParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QMetalRoughMaterialPrivate::handleMetallicChanged);
+ connect(m_roughnessParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QMetalRoughMaterialPrivate::handleRoughnessChanged);
+
+ m_metalRoughGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/metalrough.vert"))));
+ m_metalRoughGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/metalroughuniform.frag"))));
+
+ m_metalRoughGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_metalRoughGL3Technique->graphicsApiFilter()->setMajorVersion(3);
+ m_metalRoughGL3Technique->graphicsApiFilter()->setMinorVersion(1);
+ m_metalRoughGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
+
+ Q_Q(QMetalRoughMaterial);
+ m_filterKey->setParent(q);
+ m_filterKey->setName(QStringLiteral("renderingStyle"));
+ m_filterKey->setValue(QStringLiteral("forward"));
+
+ m_metalRoughGL3Technique->addFilterKey(m_filterKey);
+ m_metalRoughGL3RenderPass->setShaderProgram(m_metalRoughGL3Shader);
+ m_metalRoughGL3Technique->addRenderPass(m_metalRoughGL3RenderPass);
+ m_metalRoughEffect->addTechnique(m_metalRoughGL3Technique);
+
+ m_metalRoughEffect->addParameter(m_baseColorParameter);
+ m_metalRoughEffect->addParameter(m_metalnessParameter);
+ m_metalRoughEffect->addParameter(m_roughnessParameter);
+
+ // Note that even though those parameters are not exposed in the API,
+ // they need to be kept around for now due to a bug in some drivers/GPUs
+ // (at least Intel) which cause issues with unbound textures even if you
+ // don't try to sample from them.
+ // Can probably go away once we generate the shaders and deal in this
+ // case in a better way.
+ m_metalRoughEffect->addParameter(m_environmentIrradianceParameter);
+ m_metalRoughEffect->addParameter(m_environmentSpecularParameter);
+
+ q->setEffect(m_metalRoughEffect);
+}
+
+void QMetalRoughMaterialPrivate::handleBaseColorChanged(const QVariant &var)
+{
+ Q_Q(QMetalRoughMaterial);
+ emit q->baseColorChanged(var.value<QColor>());
+}
+
+void QMetalRoughMaterialPrivate::handleMetallicChanged(const QVariant &var)
+{
+ Q_Q(QMetalRoughMaterial);
+ emit q->metalnessChanged(var.toFloat());
+}
+void QMetalRoughMaterialPrivate::handleRoughnessChanged(const QVariant &var)
+{
+ Q_Q(QMetalRoughMaterial);
+ emit q->roughnessChanged(var.toFloat());
+}
+
+/*!
+ \class Qt3DExtras::QMetalRoughMaterial
+ \brief The QMetalRoughMaterial provides a default implementation of PBR
+ lighting.
+ \inmodule Qt3DExtras
+ \since 5.9
+ \inherits Qt3DRender::QMaterial
+
+ This material uses an effect with a single render pass approach and performs per fragment
+ lighting. Techniques are provided for OpenGL 3 only.
+*/
+
+/*!
+ Constructs a new QMetalRoughMaterial instance with parent object \a parent.
+*/
+QMetalRoughMaterial::QMetalRoughMaterial(QNode *parent)
+ : QMaterial(*new QMetalRoughMaterialPrivate, parent)
+{
+ Q_D(QMetalRoughMaterial);
+ d->init();
+}
+
+/*! \internal */
+QMetalRoughMaterial::QMetalRoughMaterial(QMetalRoughMaterialPrivate &dd, QNode *parent)
+ : QMaterial(dd, parent)
+{
+ Q_D(QMetalRoughMaterial);
+ d->init();
+}
+
+/*!
+ Destroys the QMetalRoughMaterial instance.
+*/
+QMetalRoughMaterial::~QMetalRoughMaterial()
+{
+}
+
+/*!
+ \property QMetalRoughMaterial::baseColor
+
+ Holds the current base color of the material.
+*/
+QColor QMetalRoughMaterial::baseColor() const
+{
+ Q_D(const QMetalRoughMaterial);
+ return d->m_baseColorParameter->value().value<QColor>();
+}
+
+/*!
+ \property QMetalRoughMaterial::metalness
+
+ Holds the current metalness level of the material, since is a value between 0 (purely dielectric, the default)
+ and 1 (purely metallic).
+*/
+float QMetalRoughMaterial::metalness() const
+{
+ Q_D(const QMetalRoughMaterial);
+ return d->m_metalnessParameter->value().toFloat();
+}
+
+/*!
+ \property QMetalRoughMaterial::roughness
+
+ Holds the current roughness level of the material.
+*/
+float QMetalRoughMaterial::roughness() const
+{
+ Q_D(const QMetalRoughMaterial);
+ return d->m_roughnessParameter->value().toFloat();
+}
+
+void QMetalRoughMaterial::setBaseColor(const QColor &baseColor)
+{
+ Q_D(QMetalRoughMaterial);
+ d->m_baseColorParameter->setValue(QVariant::fromValue(baseColor));
+}
+
+void QMetalRoughMaterial::setMetalness(float metalness)
+{
+ Q_D(QMetalRoughMaterial);
+ d->m_metalnessParameter->setValue(QVariant::fromValue(metalness));
+}
+
+void QMetalRoughMaterial::setRoughness(float roughness)
+{
+ Q_D(QMetalRoughMaterial);
+ d->m_roughnessParameter->setValue(QVariant::fromValue(roughness));
+}
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
diff --git a/src/extras/defaults/qmetalroughmaterial.h b/src/extras/defaults/qmetalroughmaterial.h
new file mode 100644
index 000000000..28c9438a7
--- /dev/null
+++ b/src/extras/defaults/qmetalroughmaterial.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** 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_QMETALROUGHMATERIAL_H
+#define QT3DEXTRAS_QMETALROUGHMATERIAL_H
+
+#include <Qt3DExtras/qt3dextras_global.h>
+#include <Qt3DRender/qmaterial.h>
+#include <QtGui/qcolor.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+class QAbstractTexture;
+}
+
+namespace Qt3DExtras {
+
+class QMetalRoughMaterialPrivate;
+
+class QT3DEXTRASSHARED_EXPORT QMetalRoughMaterial : public Qt3DRender::QMaterial
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor baseColor READ baseColor WRITE setBaseColor NOTIFY baseColorChanged)
+ Q_PROPERTY(float metalness READ metalness WRITE setMetalness NOTIFY metalnessChanged)
+ Q_PROPERTY(float roughness READ roughness WRITE setRoughness NOTIFY roughnessChanged)
+
+public:
+ explicit QMetalRoughMaterial(Qt3DCore::QNode *parent = nullptr);
+ ~QMetalRoughMaterial();
+
+ QColor baseColor() const;
+ float metalness() const;
+ float roughness() const;
+
+public Q_SLOTS:
+ void setBaseColor(const QColor &baseColor);
+ void setMetalness(float metalness);
+ void setRoughness(float roughness);
+
+Q_SIGNALS:
+ void baseColorChanged(const QColor &baseColor);
+ void metalnessChanged(float metalness);
+ void roughnessChanged(float roughness);
+
+protected:
+ explicit QMetalRoughMaterial(QMetalRoughMaterialPrivate &dd, Qt3DCore::QNode *parent = nullptr);
+
+private:
+ Q_DECLARE_PRIVATE(QMetalRoughMaterial)
+};
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QMETALROUGHMATERIAL_H
diff --git a/src/extras/defaults/qmetalroughmaterial_p.h b/src/extras/defaults/qmetalroughmaterial_p.h
new file mode 100644
index 000000000..3090b9757
--- /dev/null
+++ b/src/extras/defaults/qmetalroughmaterial_p.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** 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_QMETALROUGHMATERIAL_P_H
+#define QT3DEXTRAS_QMETALROUGHMATERIAL_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 <Qt3DRender/private/qmaterial_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QFilterKey;
+class QEffect;
+class QAbstractTexture;
+class QTechnique;
+class QParameter;
+class QShaderProgram;
+class QRenderPass;
+
+} // namespace Qt3DRender
+
+namespace Qt3DExtras {
+
+class QMetalRoughMaterial;
+
+class QMetalRoughMaterialPrivate : public Qt3DRender::QMaterialPrivate
+{
+public:
+ QMetalRoughMaterialPrivate();
+
+ void init();
+
+ void handleBaseColorChanged(const QVariant &var);
+ void handleMetallicChanged(const QVariant &var);
+ void handleRoughnessChanged(const QVariant &var);
+
+ Qt3DRender::QAbstractTexture *m_environmentIrradianceTexture;
+ Qt3DRender::QAbstractTexture *m_environmentSpecularTexture;
+ Qt3DRender::QParameter *m_baseColorParameter;
+ Qt3DRender::QParameter *m_metalnessParameter;
+ Qt3DRender::QParameter *m_roughnessParameter;
+ Qt3DRender::QParameter *m_environmentIrradianceParameter;
+ Qt3DRender::QParameter *m_environmentSpecularParameter;
+ Qt3DRender::QEffect *m_metalRoughEffect;
+ Qt3DRender::QTechnique *m_metalRoughGL3Technique;
+ Qt3DRender::QRenderPass *m_metalRoughGL3RenderPass;
+ Qt3DRender::QShaderProgram *m_metalRoughGL3Shader;
+ Qt3DRender::QFilterKey *m_filterKey;
+
+ Q_DECLARE_PUBLIC(QMetalRoughMaterial)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QMETALROUGHMATERIAL_P_H
+
diff --git a/src/extras/defaults/qnormaldiffusemapalphamaterial.cpp b/src/extras/defaults/qnormaldiffusemapalphamaterial.cpp
index 92564ee3f..eb6398341 100644
--- a/src/extras/defaults/qnormaldiffusemapalphamaterial.cpp
+++ b/src/extras/defaults/qnormaldiffusemapalphamaterial.cpp
@@ -49,10 +49,9 @@
#include <Qt3DRender/qgraphicsapifilter.h>
#include <Qt3DRender/qalphacoverage.h>
#include <Qt3DRender/qdepthtest.h>
-
-#include <QUrl>
-#include <QVector3D>
-#include <QVector4D>
+#include <QtCore/QUrl>
+#include <QtGui/QVector3D>
+#include <QtGui/QVector4D>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qnormaldiffusemapalphamaterial_p.h b/src/extras/defaults/qnormaldiffusemapalphamaterial_p.h
index 91b0961f1..5994d87eb 100644
--- a/src/extras/defaults/qnormaldiffusemapalphamaterial_p.h
+++ b/src/extras/defaults/qnormaldiffusemapalphamaterial_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <qnormaldiffusemapmaterial_p.h>
+#include <Qt3DExtras/private/qnormaldiffusemapmaterial_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qnormaldiffusemapmaterial.cpp b/src/extras/defaults/qnormaldiffusemapmaterial.cpp
index 8373c4d5d..35cea095a 100644
--- a/src/extras/defaults/qnormaldiffusemapmaterial.cpp
+++ b/src/extras/defaults/qnormaldiffusemapmaterial.cpp
@@ -39,6 +39,7 @@
#include "qnormaldiffusemapmaterial.h"
#include "qnormaldiffusemapmaterial_p.h"
+
#include <Qt3DRender/qfilterkey.h>
#include <Qt3DRender/qeffect.h>
#include <Qt3DRender/qtexture.h>
@@ -47,10 +48,9 @@
#include <Qt3DRender/qshaderprogram.h>
#include <Qt3DRender/qrenderpass.h>
#include <Qt3DRender/qgraphicsapifilter.h>
-
-#include <QUrl>
-#include <QVector3D>
-#include <QVector4D>
+#include <QtCore/QUrl>
+#include <QtGui/QVector3D>
+#include <QtGui/QVector4D>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qnormaldiffusemapmaterial.h b/src/extras/defaults/qnormaldiffusemapmaterial.h
index f60a27b86..c38d53352 100644
--- a/src/extras/defaults/qnormaldiffusemapmaterial.h
+++ b/src/extras/defaults/qnormaldiffusemapmaterial.h
@@ -42,7 +42,7 @@
#include <Qt3DExtras/qt3dextras_global.h>
#include <Qt3DRender/qmaterial.h>
-#include <QColor>
+#include <QtGui/QColor>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qnormaldiffusemapmaterial_p.h b/src/extras/defaults/qnormaldiffusemapmaterial_p.h
index 8dff59218..d88b01f1f 100644
--- a/src/extras/defaults/qnormaldiffusemapmaterial_p.h
+++ b/src/extras/defaults/qnormaldiffusemapmaterial_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <Qt3DRender/private/qmaterial_p.h>
+#include <private/qmaterial_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qnormaldiffusespecularmapmaterial.cpp b/src/extras/defaults/qnormaldiffusespecularmapmaterial.cpp
index e4a83c50c..c6f8ced9c 100644
--- a/src/extras/defaults/qnormaldiffusespecularmapmaterial.cpp
+++ b/src/extras/defaults/qnormaldiffusespecularmapmaterial.cpp
@@ -39,6 +39,7 @@
#include "qnormaldiffusespecularmapmaterial.h"
#include "qnormaldiffusespecularmapmaterial_p.h"
+
#include <Qt3DRender/qfilterkey.h>
#include <Qt3DRender/qmaterial.h>
#include <Qt3DRender/qeffect.h>
@@ -48,9 +49,9 @@
#include <Qt3DRender/qparameter.h>
#include <Qt3DRender/qrenderpass.h>
#include <Qt3DRender/qgraphicsapifilter.h>
-#include <QUrl>
-#include <QVector3D>
-#include <QVector4D>
+#include <QtCore/QUrl>
+#include <QtGui/QVector3D>
+#include <QtGui/QVector4D>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qnormaldiffusespecularmapmaterial.h b/src/extras/defaults/qnormaldiffusespecularmapmaterial.h
index 586715971..164b07710 100644
--- a/src/extras/defaults/qnormaldiffusespecularmapmaterial.h
+++ b/src/extras/defaults/qnormaldiffusespecularmapmaterial.h
@@ -42,7 +42,7 @@
#include <Qt3DExtras/qt3dextras_global.h>
#include <Qt3DRender/qmaterial.h>
-#include <QColor>
+#include <QtGui/QColor>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qorbitcameracontroller.cpp b/src/extras/defaults/qorbitcameracontroller.cpp
index 95b0e19dc..565a75ea1 100644
--- a/src/extras/defaults/qorbitcameracontroller.cpp
+++ b/src/extras/defaults/qorbitcameracontroller.cpp
@@ -34,9 +34,9 @@
**
****************************************************************************/
-#include "qorbitcameracontroller_p.h"
#include "qorbitcameracontroller.h"
-#include <QtGlobal>
+#include "qorbitcameracontroller_p.h"
+
#include <Qt3DRender/QCamera>
#include <Qt3DInput/QAxis>
#include <Qt3DInput/QAnalogAxisInput>
@@ -48,6 +48,7 @@
#include <Qt3DInput/QMouseDevice>
#include <Qt3DInput/QMouseEvent>
#include <Qt3DLogic/QFrameAction>
+#include <QtCore/QtGlobal>
QT_BEGIN_NAMESPACE
@@ -79,6 +80,9 @@ namespace Qt3DExtras {
\li While both the left and the right mouse button are pressed, mouse movement along y-axis
zooms the camera in and out without changing the view center.
\row
+ \li Mouse scroll wheel
+ \li Zooms the camera in and out without changing the view center.
+ \row
\li Arrow keys
\li Move the camera vertically and horizontally relative to camera viewport.
\row
@@ -113,6 +117,8 @@ QOrbitCameraControllerPrivate::QOrbitCameraControllerPrivate()
, m_shiftButtonInput(new Qt3DInput::QActionInput())
, m_mouseRxInput(new Qt3DInput::QAnalogAxisInput())
, m_mouseRyInput(new Qt3DInput::QAnalogAxisInput())
+ , m_mouseTzXInput(new Qt3DInput::QAnalogAxisInput())
+ , m_mouseTzYInput(new Qt3DInput::QAnalogAxisInput())
, m_keyboardTxPosInput(new Qt3DInput::QButtonAxisInput())
, m_keyboardTyPosInput(new Qt3DInput::QButtonAxisInput())
, m_keyboardTzPosInput(new Qt3DInput::QButtonAxisInput())
@@ -165,6 +171,16 @@ void QOrbitCameraControllerPrivate::init()
m_mouseRyInput->setSourceDevice(m_mouseDevice);
m_ryAxis->addInput(m_mouseRyInput);
+ // Mouse Wheel X
+ m_mouseTzXInput->setAxis(Qt3DInput::QMouseDevice::WheelX);
+ m_mouseTzXInput->setSourceDevice(m_mouseDevice);
+ m_tzAxis->addInput(m_mouseTzXInput);
+
+ // Mouse Wheel Y
+ m_mouseTzYInput->setAxis(Qt3DInput::QMouseDevice::WheelY);
+ m_mouseTzYInput->setSourceDevice(m_mouseDevice);
+ m_tzAxis->addInput(m_mouseTzYInput);
+
// Keyboard Pos Tx
m_keyboardTxPosInput->setButtons(QVector<int>() << Qt::Key_Right);
m_keyboardTxPosInput->setScale(1.0f);
diff --git a/src/extras/defaults/qorbitcameracontroller.h b/src/extras/defaults/qorbitcameracontroller.h
index e48e39142..7cb8b3eb7 100644
--- a/src/extras/defaults/qorbitcameracontroller.h
+++ b/src/extras/defaults/qorbitcameracontroller.h
@@ -37,8 +37,8 @@
#ifndef QT3DEXTRAS_QORBITCAMERACONTROLLER_H
#define QT3DEXTRAS_QORBITCAMERACONTROLLER_H
-#include <Qt3DExtras/qt3dextras_global.h>
#include <Qt3DCore/QEntity>
+#include <Qt3DExtras/qt3dextras_global.h>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qorbitcameracontroller_p.h b/src/extras/defaults/qorbitcameracontroller_p.h
index d207df712..8105d4375 100644
--- a/src/extras/defaults/qorbitcameracontroller_p.h
+++ b/src/extras/defaults/qorbitcameracontroller_p.h
@@ -48,9 +48,10 @@
// We mean it.
//
+#include <Qt3DExtras/qorbitcameracontroller.h>
+#include <QtGui/QVector3D>
+
#include <Qt3DCore/private/qentity_p.h>
-#include <QVector3D>
-#include "qorbitcameracontroller.h"
QT_BEGIN_NAMESPACE
@@ -105,6 +106,8 @@ public:
Qt3DInput::QAnalogAxisInput *m_mouseRxInput;
Qt3DInput::QAnalogAxisInput *m_mouseRyInput;
+ Qt3DInput::QAnalogAxisInput *m_mouseTzXInput;
+ Qt3DInput::QAnalogAxisInput *m_mouseTzYInput;
Qt3DInput::QButtonAxisInput *m_keyboardTxPosInput;
Qt3DInput::QButtonAxisInput *m_keyboardTyPosInput;
Qt3DInput::QButtonAxisInput *m_keyboardTzPosInput;
diff --git a/src/extras/defaults/qpervertexcolormaterial.cpp b/src/extras/defaults/qpervertexcolormaterial.cpp
index 514f994c1..5619a71e7 100644
--- a/src/extras/defaults/qpervertexcolormaterial.cpp
+++ b/src/extras/defaults/qpervertexcolormaterial.cpp
@@ -39,6 +39,7 @@
#include "qpervertexcolormaterial.h"
#include "qpervertexcolormaterial_p.h"
+
#include <Qt3DRender/qfilterkey.h>
#include <Qt3DRender/qmaterial.h>
#include <Qt3DRender/qeffect.h>
@@ -47,9 +48,9 @@
#include <Qt3DRender/qparameter.h>
#include <Qt3DRender/qrenderpass.h>
#include <Qt3DRender/qgraphicsapifilter.h>
-#include <QUrl>
-#include <QVector3D>
-#include <QVector4D>
+#include <QtCore/QUrl>
+#include <QtGui/QVector3D>
+#include <QtGui/QVector4D>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qpervertexcolormaterial.h b/src/extras/defaults/qpervertexcolormaterial.h
index 485e2fe0e..8b64eb2d3 100644
--- a/src/extras/defaults/qpervertexcolormaterial.h
+++ b/src/extras/defaults/qpervertexcolormaterial.h
@@ -42,7 +42,7 @@
#include <Qt3DExtras/qt3dextras_global.h>
#include <Qt3DRender/qmaterial.h>
-#include <QColor>
+#include <QtGui/QColor>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qphongalphamaterial.cpp b/src/extras/defaults/qphongalphamaterial.cpp
index 7a05610c2..d7f054d71 100644
--- a/src/extras/defaults/qphongalphamaterial.cpp
+++ b/src/extras/defaults/qphongalphamaterial.cpp
@@ -39,6 +39,7 @@
#include "qphongalphamaterial.h"
#include "qphongalphamaterial_p.h"
+
#include <Qt3DRender/qfilterkey.h>
#include <Qt3DRender/qmaterial.h>
#include <Qt3DRender/qeffect.h>
@@ -50,9 +51,9 @@
#include <Qt3DRender/qblendequation.h>
#include <Qt3DRender/qblendequationarguments.h>
#include <Qt3DRender/qnodepthmask.h>
-#include <QUrl>
-#include <QVector3D>
-#include <QVector4D>
+#include <QtCore/QUrl>
+#include <QtGui/QVector3D>
+#include <QtGui/QVector4D>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qphongalphamaterial.h b/src/extras/defaults/qphongalphamaterial.h
index b67524ef7..667c5b283 100644
--- a/src/extras/defaults/qphongalphamaterial.h
+++ b/src/extras/defaults/qphongalphamaterial.h
@@ -41,10 +41,10 @@
#define QT3DEXTRAS_QPHONGALPHAMATERIAL_H
#include <Qt3DExtras/qt3dextras_global.h>
-#include <Qt3DRender/qmaterial.h>
-#include <Qt3DRender/qblendequationarguments.h>
#include <Qt3DRender/qblendequation.h>
-#include <QColor>
+#include <Qt3DRender/qblendequationarguments.h>
+#include <Qt3DRender/qmaterial.h>
+#include <QtGui/QColor>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qphongmaterial.cpp b/src/extras/defaults/qphongmaterial.cpp
index c294984b6..449eb7351 100644
--- a/src/extras/defaults/qphongmaterial.cpp
+++ b/src/extras/defaults/qphongmaterial.cpp
@@ -39,6 +39,7 @@
#include "qphongmaterial.h"
#include "qphongmaterial_p.h"
+
#include <Qt3DRender/qfilterkey.h>
#include <Qt3DRender/qmaterial.h>
#include <Qt3DRender/qeffect.h>
@@ -47,9 +48,10 @@
#include <Qt3DRender/qparameter.h>
#include <Qt3DRender/qrenderpass.h>
#include <Qt3DRender/qgraphicsapifilter.h>
-#include <QUrl>
-#include <QVector3D>
-#include <QVector4D>
+#include <QtCore/QUrl>
+#include <QtGui/QVector3D>
+#include <QtGui/QVector4D>
+
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qphongmaterial.h b/src/extras/defaults/qphongmaterial.h
index d4b8a0f0e..d78c8c2ff 100644
--- a/src/extras/defaults/qphongmaterial.h
+++ b/src/extras/defaults/qphongmaterial.h
@@ -42,7 +42,7 @@
#include <Qt3DExtras/qt3dextras_global.h>
#include <Qt3DRender/qmaterial.h>
-#include <QColor>
+#include <QtGui/QColor>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/defaults/qskyboxentity.cpp b/src/extras/defaults/qskyboxentity.cpp
index 32e68e6fc..3c7b0dd4e 100644
--- a/src/extras/defaults/qskyboxentity.cpp
+++ b/src/extras/defaults/qskyboxentity.cpp
@@ -51,6 +51,7 @@
#include <Qt3DExtras/qcuboidmesh.h>
#include <Qt3DRender/qrenderpass.h>
#include <Qt3DRender/qgraphicsapifilter.h>
+#include <Qt3DRender/qseamlesscubemap.h>
#include <Qt3DRender/qshaderprogram.h>
QT_BEGIN_NAMESPACE
@@ -65,6 +66,7 @@ QSkyboxEntityPrivate::QSkyboxEntityPrivate()
, m_effect(new QEffect())
, m_material(new QMaterial())
, m_skyboxTexture(new QTextureCubeMap())
+ , m_loadedTexture(new QTextureLoader())
, m_gl3Shader(new QShaderProgram())
, m_gl2es2Shader(new QShaderProgram())
, m_gl2Technique(new QTechnique())
@@ -75,6 +77,7 @@ QSkyboxEntityPrivate::QSkyboxEntityPrivate()
, m_es2RenderPass(new QRenderPass())
, m_gl3RenderPass(new QRenderPass())
, m_mesh(new QCuboidMesh())
+ , m_gammaStrengthParameter(new QParameter(QStringLiteral("gammaStrength"), 0.0f))
, m_textureParameter(new QParameter(QStringLiteral("skyboxTexture"), m_skyboxTexture))
, m_posXImage(new QTextureImage())
, m_posYImage(new QTextureImage())
@@ -84,6 +87,7 @@ QSkyboxEntityPrivate::QSkyboxEntityPrivate()
, m_negZImage(new QTextureImage())
, m_extension(QStringLiteral(".png"))
{
+ m_loadedTexture->setGenerateMipMaps(false);
}
/*!
@@ -127,9 +131,11 @@ void QSkyboxEntityPrivate::init()
cullFront->setMode(QCullFace::Front);
QDepthTest *depthTest = new QDepthTest();
depthTest->setDepthFunction(QDepthTest::LessOrEqual);
+ QSeamlessCubemap *seamlessCubemap = new QSeamlessCubemap();
m_gl3RenderPass->addRenderState(cullFront);
m_gl3RenderPass->addRenderState(depthTest);
+ m_gl3RenderPass->addRenderState(seamlessCubemap);
m_gl2RenderPass->addRenderState(cullFront);
m_gl2RenderPass->addRenderState(depthTest);
m_es2RenderPass->addRenderState(cullFront);
@@ -144,6 +150,7 @@ void QSkyboxEntityPrivate::init()
m_effect->addTechnique(m_es2Technique);
m_material->setEffect(m_effect);
+ m_material->addParameter(m_gammaStrengthParameter);
m_material->addParameter(m_textureParameter);
m_mesh->setXYMeshResolution(QSize(2, 2));
@@ -151,11 +158,17 @@ void QSkyboxEntityPrivate::init()
m_mesh->setYZMeshResolution(QSize(2, 2));
m_posXImage->setFace(QTextureCubeMap::CubeMapPositiveX);
+ m_posXImage->setMirrored(false);
m_posYImage->setFace(QTextureCubeMap::CubeMapPositiveY);
+ m_posYImage->setMirrored(false);
m_posZImage->setFace(QTextureCubeMap::CubeMapPositiveZ);
+ m_posZImage->setMirrored(false);
m_negXImage->setFace(QTextureCubeMap::CubeMapNegativeX);
+ m_negXImage->setMirrored(false);
m_negYImage->setFace(QTextureCubeMap::CubeMapNegativeY);
+ m_negYImage->setMirrored(false);
m_negZImage->setFace(QTextureCubeMap::CubeMapNegativeZ);
+ m_negZImage->setMirrored(false);
m_skyboxTexture->setMagnificationFilter(QTextureCubeMap::Linear);
m_skyboxTexture->setMinificationFilter(QTextureCubeMap::Linear);
@@ -178,12 +191,18 @@ void QSkyboxEntityPrivate::init()
*/
void QSkyboxEntityPrivate::reloadTexture()
{
- m_posXImage->setSource(QUrl(m_baseName + QStringLiteral("_posx") + m_extension));
- m_posYImage->setSource(QUrl(m_baseName + QStringLiteral("_posy") + m_extension));
- m_posZImage->setSource(QUrl(m_baseName + QStringLiteral("_posz") + m_extension));
- m_negXImage->setSource(QUrl(m_baseName + QStringLiteral("_negx") + m_extension));
- m_negYImage->setSource(QUrl(m_baseName + QStringLiteral("_negy") + m_extension));
- m_negZImage->setSource(QUrl(m_baseName + QStringLiteral("_negz") + m_extension));
+ if (m_extension == QStringLiteral(".dds")) {
+ m_loadedTexture->setSource(QUrl(m_baseName + m_extension));
+ m_textureParameter->setValue(QVariant::fromValue(m_loadedTexture));
+ } else {
+ m_posXImage->setSource(QUrl(m_baseName + QStringLiteral("_posx") + m_extension));
+ m_posYImage->setSource(QUrl(m_baseName + QStringLiteral("_posy") + m_extension));
+ m_posZImage->setSource(QUrl(m_baseName + QStringLiteral("_posz") + m_extension));
+ m_negXImage->setSource(QUrl(m_baseName + QStringLiteral("_negx") + m_extension));
+ m_negYImage->setSource(QUrl(m_baseName + QStringLiteral("_negy") + m_extension));
+ m_negZImage->setSource(QUrl(m_baseName + QStringLiteral("_negz") + m_extension));
+ m_textureParameter->setValue(QVariant::fromValue(m_skyboxTexture));
+ }
}
/*!
@@ -232,7 +251,7 @@ void QSkyboxEntity::setBaseName(const QString &baseName)
Q_D(QSkyboxEntity);
if (baseName != d->m_baseName) {
d->m_baseName = baseName;
- emit sourceDirectoryChanged(baseName);
+ emit baseNameChanged(baseName);
d->reloadTexture();
}
}
@@ -267,6 +286,29 @@ QString QSkyboxEntity::extension() const
return d->m_extension;
}
+/*!
+ * Sets the gamma correction enable state to \a enabled.
+ * \since 5.9
+ */
+void QSkyboxEntity::setGammaCorrectEnabled(bool enabled)
+{
+ Q_D(QSkyboxEntity);
+ if (enabled != isGammaCorrectEnabled()) {
+ d->m_gammaStrengthParameter->setValue(enabled ? 1.0f : 0.0f);
+ emit gammaCorrectEnabledChanged(enabled);
+ }
+}
+
+/*!
+ * Returns true if gamma correction is enabled for this skybox.
+ * \since 5.9
+ */
+bool QSkyboxEntity::isGammaCorrectEnabled() const
+{
+ Q_D(const QSkyboxEntity);
+ return !qFuzzyIsNull(d->m_gammaStrengthParameter->value().toFloat());
+}
+
} // namespace Qt3DExtras
QT_END_NAMESPACE
diff --git a/src/extras/defaults/qskyboxentity.h b/src/extras/defaults/qskyboxentity.h
index a11d2f0a0..e49782dc2 100644
--- a/src/extras/defaults/qskyboxentity.h
+++ b/src/extras/defaults/qskyboxentity.h
@@ -52,19 +52,26 @@ class QSkyboxEntityPrivate;
class QT3DEXTRASSHARED_EXPORT QSkyboxEntity : public Qt3DCore::QEntity
{
Q_OBJECT
+ Q_PROPERTY(QString baseName READ baseName WRITE setBaseName NOTIFY baseNameChanged)
+ Q_PROPERTY(QString extension READ extension WRITE setExtension NOTIFY extensionChanged)
+ Q_PROPERTY(bool gammaCorrect READ isGammaCorrectEnabled WRITE setGammaCorrectEnabled NOTIFY gammaCorrectEnabledChanged REVISION 9)
public:
explicit QSkyboxEntity(Qt3DCore::QNode *parent = nullptr);
~QSkyboxEntity();
- void setBaseName(const QString &path);
QString baseName() const;
+ QString extension() const;
+ bool isGammaCorrectEnabled() const;
+public Q_SLOTS:
+ void setBaseName(const QString &path);
void setExtension(const QString &extension);
- QString extension() const;
+ void setGammaCorrectEnabled(bool enabled);
Q_SIGNALS:
- void sourceDirectoryChanged(const QString &path);
+ void baseNameChanged(const QString &path);
void extensionChanged(const QString &extension);
+ void gammaCorrectEnabledChanged(bool enabled);
private:
Q_DECLARE_PRIVATE(QSkyboxEntity)
diff --git a/src/extras/defaults/qskyboxentity_p.h b/src/extras/defaults/qskyboxentity_p.h
index effe97fce..88a40e2eb 100644
--- a/src/extras/defaults/qskyboxentity_p.h
+++ b/src/extras/defaults/qskyboxentity_p.h
@@ -51,8 +51,9 @@
// We mean it.
//
+#include <QtGui/QVector3D>
+
#include <Qt3DCore/private/qentity_p.h>
-#include <QVector3D>
QT_BEGIN_NAMESPACE
@@ -60,6 +61,7 @@ namespace Qt3DRender {
class QFilterKey;
class QTextureCubeMap;
+class QTextureLoader;
class QShaderProgram;
class QSkyboxEntity;
class QTextureImage;
@@ -87,6 +89,7 @@ class QSkyboxEntityPrivate : public Qt3DCore::QEntityPrivate
Qt3DRender::QEffect *m_effect;
Qt3DRender::QMaterial *m_material;
Qt3DRender::QTextureCubeMap *m_skyboxTexture;
+ Qt3DRender::QTextureLoader *m_loadedTexture;
Qt3DRender::QShaderProgram *m_gl3Shader;
Qt3DRender::QShaderProgram *m_gl2es2Shader;
Qt3DRender::QTechnique *m_gl2Technique;
@@ -97,6 +100,7 @@ class QSkyboxEntityPrivate : public Qt3DCore::QEntityPrivate
Qt3DRender::QRenderPass *m_es2RenderPass;
Qt3DRender::QRenderPass *m_gl3RenderPass;
QCuboidMesh *m_mesh;
+ Qt3DRender::QParameter *m_gammaStrengthParameter;
Qt3DRender::QParameter *m_textureParameter;
Qt3DRender::QTextureImage *m_posXImage;
Qt3DRender:: QTextureImage *m_posYImage;
diff --git a/src/extras/defaults/qt3dwindow.cpp b/src/extras/defaults/qt3dwindow.cpp
index 06ff14212..635d81956 100644
--- a/src/extras/defaults/qt3dwindow.cpp
+++ b/src/extras/defaults/qt3dwindow.cpp
@@ -49,27 +49,25 @@
****************************************************************************/
#include "qt3dwindow.h"
+#include "qt3dwindow_p.h"
+#include <Qt3DCore/qaspectengine.h>
+#include <Qt3DCore/qentity.h>
#include <Qt3DExtras/qforwardrenderer.h>
#include <Qt3DRender/qrendersettings.h>
#include <Qt3DRender/qrenderaspect.h>
#include <Qt3DInput/qinputaspect.h>
#include <Qt3DInput/qinputsettings.h>
#include <Qt3DLogic/qlogicaspect.h>
-
-#include <Qt3DCore/qaspectengine.h>
#include <Qt3DRender/qcamera.h>
-#include <Qt3DCore/qentity.h>
-
#include <QtGui/qopenglcontext.h>
QT_BEGIN_NAMESPACE
namespace Qt3DExtras {
-Qt3DWindow::Qt3DWindow(QScreen *screen)
- : QWindow(screen)
- , m_aspectEngine(new Qt3DCore::QAspectEngine)
+Qt3DWindowPrivate::Qt3DWindowPrivate()
+ : m_aspectEngine(new Qt3DCore::QAspectEngine)
, m_renderAspect(new Qt3DRender::QRenderAspect)
, m_inputAspect(new Qt3DInput::QInputAspect)
, m_logicAspect(new Qt3DLogic::QLogicAspect)
@@ -81,6 +79,16 @@ Qt3DWindow::Qt3DWindow(QScreen *screen)
, m_userRoot(nullptr)
, m_initialized(false)
{
+}
+
+Qt3DWindow::Qt3DWindow(QScreen *screen)
+ : QWindow(*new Qt3DWindowPrivate(), nullptr)
+{
+ Q_D(Qt3DWindow);
+
+ if (!d->parentWindow)
+ d->connectToScreen(screen ? screen : d->topLevelScreen.data());
+
setSurfaceType(QSurface::OpenGLSurface);
resize(1024, 768);
@@ -99,74 +107,89 @@ Qt3DWindow::Qt3DWindow(QScreen *screen)
format.setStencilBufferSize(8);
setFormat(format);
QSurfaceFormat::setDefaultFormat(format);
- create();
- m_aspectEngine->registerAspect(m_renderAspect);
- m_aspectEngine->registerAspect(m_inputAspect);
- m_aspectEngine->registerAspect(m_logicAspect);
+ d->m_aspectEngine->registerAspect(d->m_renderAspect);
+ d->m_aspectEngine->registerAspect(d->m_inputAspect);
+ d->m_aspectEngine->registerAspect(d->m_logicAspect);
- m_defaultCamera->setParent(m_root);
- m_forwardRenderer->setCamera(m_defaultCamera);
- m_forwardRenderer->setSurface(this);
- m_renderSettings->setActiveFrameGraph(m_forwardRenderer);
- m_inputSettings->setEventSource(this);
+ d->m_defaultCamera->setParent(d->m_root);
+ d->m_forwardRenderer->setCamera(d->m_defaultCamera);
+ d->m_forwardRenderer->setSurface(this);
+ d->m_renderSettings->setActiveFrameGraph(d->m_forwardRenderer);
+ d->m_inputSettings->setEventSource(this);
}
Qt3DWindow::~Qt3DWindow()
{
+ Q_D(Qt3DWindow);
+ delete d->m_aspectEngine;
}
void Qt3DWindow::registerAspect(Qt3DCore::QAbstractAspect *aspect)
{
Q_ASSERT(!isVisible());
- m_aspectEngine->registerAspect(aspect);
+ Q_D(Qt3DWindow);
+ d->m_aspectEngine->registerAspect(aspect);
}
void Qt3DWindow::registerAspect(const QString &name)
{
Q_ASSERT(!isVisible());
- m_aspectEngine->registerAspect(name);
+ Q_D(Qt3DWindow);
+ d->m_aspectEngine->registerAspect(name);
}
void Qt3DWindow::setRootEntity(Qt3DCore::QEntity *root)
{
- if (m_userRoot != root) {
- if (m_userRoot != nullptr)
- m_userRoot->setParent(static_cast<Qt3DCore::QNode*>(nullptr));
+ Q_D(Qt3DWindow);
+ if (d->m_userRoot != root) {
+ if (d->m_userRoot != nullptr)
+ d->m_userRoot->setParent(static_cast<Qt3DCore::QNode*>(nullptr));
if (root != nullptr)
- root->setParent(m_root);
- m_userRoot = root;
+ root->setParent(d->m_root);
+ d->m_userRoot = root;
}
}
void Qt3DWindow::setActiveFrameGraph(Qt3DRender::QFrameGraphNode *activeFrameGraph)
{
- m_renderSettings->setActiveFrameGraph(activeFrameGraph);
+ Q_D(Qt3DWindow);
+ d->m_renderSettings->setActiveFrameGraph(activeFrameGraph);
}
Qt3DRender::QFrameGraphNode *Qt3DWindow::activeFrameGraph() const
{
- return m_renderSettings->activeFrameGraph();
+ Q_D(const Qt3DWindow);
+ return d->m_renderSettings->activeFrameGraph();
}
Qt3DExtras::QForwardRenderer *Qt3DWindow::defaultFrameGraph() const
{
- return m_forwardRenderer;
+ Q_D(const Qt3DWindow);
+ return d->m_forwardRenderer;
}
Qt3DRender::QCamera *Qt3DWindow::camera() const
{
- return m_defaultCamera;
+ Q_D(const Qt3DWindow);
+ return d->m_defaultCamera;
+}
+
+Qt3DRender::QRenderSettings *Qt3DWindow::renderSettings() const
+{
+ Q_D(const Qt3DWindow);
+ return d->m_renderSettings;
}
void Qt3DWindow::showEvent(QShowEvent *e)
{
- if (!m_initialized) {
- m_root->addComponent(m_renderSettings);
- m_root->addComponent(m_inputSettings);
- m_aspectEngine->setRootEntity(Qt3DCore::QEntityPtr(m_root));
+ Q_D(Qt3DWindow);
+ if (!d->m_initialized) {
+ d->m_root->addComponent(d->m_renderSettings);
+ d->m_root->addComponent(d->m_inputSettings);
+ d->m_aspectEngine->setRootEntity(Qt3DCore::QEntityPtr(d->m_root));
- m_initialized = true;
+ d->m_initialized = true;
}
QWindow::showEvent(e);
@@ -174,7 +197,8 @@ void Qt3DWindow::showEvent(QShowEvent *e)
void Qt3DWindow::resizeEvent(QResizeEvent *)
{
- m_defaultCamera->setAspectRatio(float(width()) / float(height()));
+ Q_D(Qt3DWindow);
+ d->m_defaultCamera->setAspectRatio(float(width()) / float(height()));
}
} // Qt3DExtras
diff --git a/src/extras/defaults/qt3dwindow.h b/src/extras/defaults/qt3dwindow.h
index 109e1be75..6ec1bbf8b 100644
--- a/src/extras/defaults/qt3dwindow.h
+++ b/src/extras/defaults/qt3dwindow.h
@@ -51,8 +51,8 @@
#ifndef QT3DWINDOW_H
#define QT3DWINDOW_H
-#include <QWindow>
#include <Qt3DExtras/qt3dextras_global.h>
+#include <QtGui/QWindow>
QT_BEGIN_NAMESPACE
@@ -84,6 +84,8 @@ class QLogicAspect;
namespace Qt3DExtras {
+class Qt3DWindowPrivate;
+
class QT3DEXTRASSHARED_EXPORT Qt3DWindow : public QWindow
{
Q_OBJECT
@@ -101,6 +103,7 @@ public:
Qt3DExtras::QForwardRenderer *defaultFrameGraph() const;
Qt3DRender::QCamera *camera() const;
+ Qt3DRender::QRenderSettings *renderSettings() const;
public Q_SLOTS:
@@ -111,28 +114,7 @@ protected:
void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
private:
- QScopedPointer<Qt3DCore::QAspectEngine> m_aspectEngine;
-
- // Aspects
- Qt3DRender::QRenderAspect *m_renderAspect;
- Qt3DInput::QInputAspect *m_inputAspect;
- Qt3DLogic::QLogicAspect *m_logicAspect;
-
- // Renderer configuration
- Qt3DRender::QRenderSettings *m_renderSettings;
- Qt3DExtras::QForwardRenderer *m_forwardRenderer;
- Qt3DRender::QCamera *m_defaultCamera;
-
- // Input configuration
- Qt3DInput::QInputSettings *m_inputSettings;
-
- // Logic configuration
-
- // Scene
- Qt3DCore::QEntity *m_root;
- Qt3DCore::QEntity *m_userRoot;
-
- bool m_initialized;
+ Q_DECLARE_PRIVATE(Qt3DWindow)
};
} // Qt3DExtras
diff --git a/src/extras/defaults/qt3dwindow_p.h b/src/extras/defaults/qt3dwindow_p.h
new file mode 100644
index 000000000..731d5298e
--- /dev/null
+++ b/src/extras/defaults/qt3dwindow_p.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DWINDOW_P_H
+#define QT3DWINDOW_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 <QtGui/private/qwindow_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DExtras {
+
+class Qt3DWindowPrivate : public QWindowPrivate
+{
+public:
+ Qt3DWindowPrivate();
+
+ Qt3DCore::QAspectEngine *m_aspectEngine;
+
+ // Aspects
+ Qt3DRender::QRenderAspect *m_renderAspect;
+ Qt3DInput::QInputAspect *m_inputAspect;
+ Qt3DLogic::QLogicAspect *m_logicAspect;
+
+ // Renderer configuration
+ Qt3DRender::QRenderSettings *m_renderSettings;
+ Qt3DExtras::QForwardRenderer *m_forwardRenderer;
+ Qt3DRender::QCamera *m_defaultCamera;
+
+ // Input configuration
+ Qt3DInput::QInputSettings *m_inputSettings;
+
+ // Logic configuration
+
+ // Scene
+ Qt3DCore::QEntity *m_root;
+ Qt3DCore::QEntity *m_userRoot;
+
+ bool m_initialized;
+
+ Q_DECLARE_PUBLIC(Qt3DWindow)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DWINDOW_P_H
diff --git a/src/extras/defaults/qtexturedmetalroughmaterial.cpp b/src/extras/defaults/qtexturedmetalroughmaterial.cpp
new file mode 100644
index 000000000..e09517866
--- /dev/null
+++ b/src/extras/defaults/qtexturedmetalroughmaterial.cpp
@@ -0,0 +1,373 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include "qtexturedmetalroughmaterial.h"
+#include "qtexturedmetalroughmaterial_p.h"
+#include <Qt3DRender/qfilterkey.h>
+#include <Qt3DRender/qmaterial.h>
+#include <Qt3DRender/qeffect.h>
+#include <Qt3DRender/qtexture.h>
+#include <Qt3DRender/qtechnique.h>
+#include <Qt3DRender/qshaderprogram.h>
+#include <Qt3DRender/qparameter.h>
+#include <Qt3DRender/qrenderpass.h>
+#include <Qt3DRender/qgraphicsapifilter.h>
+#include <QUrl>
+#include <QVector3D>
+#include <QVector4D>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DRender;
+
+namespace Qt3DExtras {
+
+QTexturedMetalRoughMaterialPrivate::QTexturedMetalRoughMaterialPrivate()
+ : QMaterialPrivate()
+ , m_baseColorTexture(new QTexture2D())
+ , m_metalnessTexture(new QTexture2D())
+ , m_roughnessTexture(new QTexture2D())
+ , m_ambientOcclusionTexture(new QTexture2D())
+ , m_normalTexture(new QTexture2D())
+ , m_environmentIrradianceTexture(new QTexture2D())
+ , m_environmentSpecularTexture(new QTexture2D())
+ , m_baseColorParameter(new QParameter(QStringLiteral("baseColorMap"), m_baseColorTexture))
+ , m_metalnessParameter(new QParameter(QStringLiteral("metalnessMap"), m_metalnessTexture))
+ , m_roughnessParameter(new QParameter(QStringLiteral("roughnessMap"), m_roughnessTexture))
+ , m_ambientOcclusionParameter(new QParameter(QStringLiteral("ambientOcclusionMap"), m_ambientOcclusionTexture))
+ , m_normalParameter(new QParameter(QStringLiteral("normalMap"), m_normalTexture))
+ , m_environmentIrradianceParameter(new QParameter(QStringLiteral("envLight.irradiance"), m_environmentIrradianceTexture))
+ , m_environmentSpecularParameter(new QParameter(QStringLiteral("envLight.specular"), m_environmentSpecularTexture))
+ , m_metalRoughEffect(new QEffect())
+ , m_metalRoughGL3Technique(new QTechnique())
+ , m_metalRoughGL3RenderPass(new QRenderPass())
+ , m_metalRoughGL3Shader(new QShaderProgram())
+ , m_filterKey(new QFilterKey)
+{
+ m_baseColorTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_baseColorTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_baseColorTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_baseColorTexture->setGenerateMipMaps(true);
+ m_baseColorTexture->setMaximumAnisotropy(16.0f);
+
+ m_metalnessTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_metalnessTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_metalnessTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_metalnessTexture->setGenerateMipMaps(true);
+ m_metalnessTexture->setMaximumAnisotropy(16.0f);
+
+ m_roughnessTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_roughnessTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_roughnessTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_roughnessTexture->setGenerateMipMaps(true);
+ m_roughnessTexture->setMaximumAnisotropy(16.0f);
+
+ m_ambientOcclusionTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_ambientOcclusionTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_ambientOcclusionTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_ambientOcclusionTexture->setGenerateMipMaps(true);
+ m_ambientOcclusionTexture->setMaximumAnisotropy(16.0f);
+
+ m_normalTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_normalTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_normalTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_normalTexture->setGenerateMipMaps(true);
+ m_normalTexture->setMaximumAnisotropy(16.0f);
+
+ m_environmentIrradianceTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_environmentIrradianceTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_environmentIrradianceTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_environmentIrradianceTexture->setGenerateMipMaps(true);
+ m_environmentIrradianceTexture->setMaximumAnisotropy(16.0f);
+
+ m_environmentSpecularTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_environmentSpecularTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_environmentSpecularTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_environmentSpecularTexture->setGenerateMipMaps(true);
+ m_environmentSpecularTexture->setMaximumAnisotropy(16.0f);
+}
+
+void QTexturedMetalRoughMaterialPrivate::init()
+{
+ connect(m_baseColorParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QTexturedMetalRoughMaterialPrivate::handleBaseColorChanged);
+ connect(m_metalnessParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QTexturedMetalRoughMaterialPrivate::handleMetallicChanged);
+ connect(m_roughnessParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QTexturedMetalRoughMaterialPrivate::handleRoughnessChanged);
+ connect(m_ambientOcclusionParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QTexturedMetalRoughMaterialPrivate::handleAmbientOcclusionChanged);
+ connect(m_normalParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QTexturedMetalRoughMaterialPrivate::handleNormalChanged);
+
+ m_metalRoughGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/metalrough.vert"))));
+ m_metalRoughGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/metalrough.frag"))));
+
+ m_metalRoughGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_metalRoughGL3Technique->graphicsApiFilter()->setMajorVersion(3);
+ m_metalRoughGL3Technique->graphicsApiFilter()->setMinorVersion(1);
+ m_metalRoughGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
+
+ Q_Q(QTexturedMetalRoughMaterial);
+ m_filterKey->setParent(q);
+ m_filterKey->setName(QStringLiteral("renderingStyle"));
+ m_filterKey->setValue(QStringLiteral("forward"));
+
+ m_metalRoughGL3Technique->addFilterKey(m_filterKey);
+ m_metalRoughGL3RenderPass->setShaderProgram(m_metalRoughGL3Shader);
+ m_metalRoughGL3Technique->addRenderPass(m_metalRoughGL3RenderPass);
+ m_metalRoughEffect->addTechnique(m_metalRoughGL3Technique);
+
+ m_metalRoughEffect->addParameter(m_baseColorParameter);
+ m_metalRoughEffect->addParameter(m_metalnessParameter);
+ m_metalRoughEffect->addParameter(m_roughnessParameter);
+ m_metalRoughEffect->addParameter(m_ambientOcclusionParameter);
+ m_metalRoughEffect->addParameter(m_normalParameter);
+
+ // Note that even though those parameters are not exposed in the API,
+ // they need to be kept around for now due to a bug in some drivers/GPUs
+ // (at least Intel) which cause issues with unbound textures even if you
+ // don't try to sample from them.
+ // Can probably go away once we generate the shaders and deal in this
+ // case in a better way.
+ m_metalRoughEffect->addParameter(m_environmentIrradianceParameter);
+ m_metalRoughEffect->addParameter(m_environmentSpecularParameter);
+
+ q->setEffect(m_metalRoughEffect);
+}
+
+void QTexturedMetalRoughMaterialPrivate::handleBaseColorChanged(const QVariant &var)
+{
+ Q_Q(QTexturedMetalRoughMaterial);
+ emit q->baseColorChanged(var.value<QAbstractTexture *>());
+}
+
+void QTexturedMetalRoughMaterialPrivate::handleMetallicChanged(const QVariant &var)
+{
+ Q_Q(QTexturedMetalRoughMaterial);
+ emit q->metalnessChanged(var.value<QAbstractTexture *>());
+}
+void QTexturedMetalRoughMaterialPrivate::handleRoughnessChanged(const QVariant &var)
+{
+ Q_Q(QTexturedMetalRoughMaterial);
+ emit q->roughnessChanged(var.value<QAbstractTexture *>());
+}
+void QTexturedMetalRoughMaterialPrivate::handleAmbientOcclusionChanged(const QVariant &var)
+{
+ Q_Q(QTexturedMetalRoughMaterial);
+ emit q->ambientOcclusionChanged(var.value<QAbstractTexture *>());
+}
+
+void QTexturedMetalRoughMaterialPrivate::handleNormalChanged(const QVariant &var)
+{
+ Q_Q(QTexturedMetalRoughMaterial);
+ emit q->normalChanged(var.value<QAbstractTexture *>());
+}
+
+/*!
+ \class Qt3DExtras::QTexturedMetalRoughMaterial
+ \brief The QTexturedMetalRoughMaterial provides a default implementation of PBR
+ lighting, environment maps and bump effect where the components are read from texture
+ maps (including normal maps).
+ \inmodule Qt3DExtras
+ \since 5.9
+ \inherits Qt3DRender::QMaterial
+
+ This material uses an effect with a single render pass approach and performs per fragment
+ lighting. Techniques are provided for OpenGL 3 only.
+*/
+
+/*!
+ Constructs a new QTexturedMetalRoughMaterial instance with parent object \a parent.
+*/
+QTexturedMetalRoughMaterial::QTexturedMetalRoughMaterial(QNode *parent)
+ : QMaterial(*new QTexturedMetalRoughMaterialPrivate, parent)
+{
+ Q_D(QTexturedMetalRoughMaterial);
+ d->init();
+}
+
+/*! \internal */
+QTexturedMetalRoughMaterial::QTexturedMetalRoughMaterial(QTexturedMetalRoughMaterialPrivate &dd, QNode *parent)
+ : QMaterial(dd, parent)
+{
+ Q_D(QTexturedMetalRoughMaterial);
+ d->init();
+}
+
+/*!
+ Destroys the QTexturedMetalRoughMaterial instance.
+*/
+QTexturedMetalRoughMaterial::~QTexturedMetalRoughMaterial()
+{
+}
+
+/*!
+ \property QTexturedMetalRoughMaterial::baseColor
+
+ Holds the current base color map texture.
+
+ By default, the base color texture has the following properties:
+
+ \list
+ \li Linear minification and magnification filters
+ \li Linear mipmap with mipmapping enabled
+ \li Repeat wrap mode
+ \li Maximum anisotropy of 16.0
+ \endlist
+*/
+QAbstractTexture *QTexturedMetalRoughMaterial::baseColor() const
+{
+ Q_D(const QTexturedMetalRoughMaterial);
+ return d->m_baseColorParameter->value().value<QAbstractTexture *>();
+}
+
+/*!
+ \property QTexturedMetalRoughMaterial::metalness
+
+ Holds the current metalness map texture.
+
+ By default, the metalness texture has the following properties:
+
+ \list
+ \li Linear minification and magnification filters
+ \li Linear mipmap with mipmapping enabled
+ \li Repeat wrap mode
+ \li Maximum anisotropy of 16.0
+ \endlist
+*/
+QAbstractTexture *QTexturedMetalRoughMaterial::metalness() const
+{
+ Q_D(const QTexturedMetalRoughMaterial);
+ return d->m_metalnessParameter->value().value<QAbstractTexture *>();
+}
+
+/*!
+ \property QTexturedMetalRoughMaterial::roughness
+
+ Holds the current roughness map texture.
+
+ By default, the roughness texture has the following properties:
+
+ \list
+ \li Linear minification and magnification filters
+ \li Linear mipmap with mipmapping enabled
+ \li Repeat wrap mode
+ \li Maximum anisotropy of 16.0
+ \endlist
+*/
+QAbstractTexture *QTexturedMetalRoughMaterial::roughness() const
+{
+ Q_D(const QTexturedMetalRoughMaterial);
+ return d->m_roughnessParameter->value().value<QAbstractTexture *>();
+}
+
+/*!
+ \property QTexturedMetalRoughMaterial::ambientOcclusion
+
+ Holds the current ambient occlusion map texture.
+
+ By default, the ambient occlusion texture has the following properties:
+
+ \list
+ \li Linear minification and magnification filters
+ \li Linear mipmap with mipmapping enabled
+ \li Repeat wrap mode
+ \li Maximum anisotropy of 16.0
+ \endlist
+*/
+QAbstractTexture *QTexturedMetalRoughMaterial::ambientOcclusion() const
+{
+ Q_D(const QTexturedMetalRoughMaterial);
+ return d->m_ambientOcclusionParameter->value().value<QAbstractTexture *>();
+}
+
+/*!
+ \property QTexturedMetalRoughMaterial::normal
+
+ Holds the current normal map texture.
+
+ By default, the normal texture has the following properties:
+
+ \list
+ \li Linear minification and magnification filters
+ \li Repeat wrap mode
+ \li Maximum anisotropy of 16.0
+ \endlist
+*/
+QAbstractTexture *QTexturedMetalRoughMaterial::normal() const
+{
+ Q_D(const QTexturedMetalRoughMaterial);
+ return d->m_normalParameter->value().value<QAbstractTexture *>();
+}
+
+
+void QTexturedMetalRoughMaterial::setBaseColor(QAbstractTexture *baseColor)
+{
+ Q_D(QTexturedMetalRoughMaterial);
+ d->m_baseColorParameter->setValue(QVariant::fromValue(baseColor));
+}
+
+void QTexturedMetalRoughMaterial::setMetalness(QAbstractTexture *metalness)
+{
+ Q_D(QTexturedMetalRoughMaterial);
+ d->m_metalnessParameter->setValue(QVariant::fromValue(metalness));
+}
+
+void QTexturedMetalRoughMaterial::setRoughness(QAbstractTexture *roughness)
+{
+ Q_D(QTexturedMetalRoughMaterial);
+ d->m_roughnessParameter->setValue(QVariant::fromValue(roughness));
+}
+
+void QTexturedMetalRoughMaterial::setAmbientOcclusion(QAbstractTexture *ambientOcclusion)
+{
+ Q_D(QTexturedMetalRoughMaterial);
+ d->m_ambientOcclusionParameter->setValue(QVariant::fromValue(ambientOcclusion));
+}
+
+void QTexturedMetalRoughMaterial::setNormal(QAbstractTexture *normal)
+{
+ Q_D(QTexturedMetalRoughMaterial);
+ d->m_normalParameter->setValue(QVariant::fromValue(normal));
+}
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
diff --git a/src/extras/defaults/qtexturedmetalroughmaterial.h b/src/extras/defaults/qtexturedmetalroughmaterial.h
new file mode 100644
index 000000000..62755a781
--- /dev/null
+++ b/src/extras/defaults/qtexturedmetalroughmaterial.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** 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_H
+#define QT3DEXTRAS_QTEXTUREDMETALROUGHMATERIAL_H
+
+#include <Qt3DExtras/qt3dextras_global.h>
+#include <Qt3DRender/qmaterial.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DExtras {
+
+class QTexturedMetalRoughMaterialPrivate;
+
+class QT3DEXTRASSHARED_EXPORT QTexturedMetalRoughMaterial : public Qt3DRender::QMaterial
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt3DRender::QAbstractTexture *baseColor READ baseColor WRITE setBaseColor NOTIFY baseColorChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTexture *metalness READ metalness WRITE setMetalness NOTIFY metalnessChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTexture *roughness READ roughness WRITE setRoughness NOTIFY roughnessChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTexture *ambientOcclusion READ ambientOcclusion WRITE setAmbientOcclusion NOTIFY ambientOcclusionChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTexture *normal READ normal WRITE setNormal NOTIFY normalChanged)
+
+public:
+ explicit QTexturedMetalRoughMaterial(Qt3DCore::QNode *parent = nullptr);
+ ~QTexturedMetalRoughMaterial();
+
+ Qt3DRender::QAbstractTexture *baseColor() const;
+ Qt3DRender::QAbstractTexture *metalness() const;
+ Qt3DRender::QAbstractTexture *roughness() const;
+ Qt3DRender::QAbstractTexture *ambientOcclusion() const;
+ Qt3DRender::QAbstractTexture *normal() const;
+
+public Q_SLOTS:
+ void setBaseColor(Qt3DRender::QAbstractTexture *baseColor);
+ void setMetalness(Qt3DRender::QAbstractTexture *metalness);
+ void setRoughness(Qt3DRender::QAbstractTexture *roughness);
+ void setAmbientOcclusion(Qt3DRender::QAbstractTexture *ambientOcclusion);
+ void setNormal(Qt3DRender::QAbstractTexture *normal);
+
+Q_SIGNALS:
+ void baseColorChanged(Qt3DRender::QAbstractTexture *baseColor);
+ void metalnessChanged(Qt3DRender::QAbstractTexture *metalness);
+ void roughnessChanged(Qt3DRender::QAbstractTexture *roughness);
+ void ambientOcclusionChanged(Qt3DRender::QAbstractTexture *ambientOcclusion);
+ void normalChanged(Qt3DRender::QAbstractTexture *normal);
+
+protected:
+ explicit QTexturedMetalRoughMaterial(QTexturedMetalRoughMaterialPrivate &dd, Qt3DCore::QNode *parent = nullptr);
+
+private:
+ Q_DECLARE_PRIVATE(QTexturedMetalRoughMaterial)
+};
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QTEXTUREDMETALROUGHMATERIAL_H
diff --git a/src/extras/defaults/qtexturedmetalroughmaterial_p.h b/src/extras/defaults/qtexturedmetalroughmaterial_p.h
new file mode 100644
index 000000000..8972726e5
--- /dev/null
+++ b/src/extras/defaults/qtexturedmetalroughmaterial_p.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** 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 <Qt3DRender/private/qmaterial_p.h>
+
+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 handleBaseColorChanged(const QVariant &var);
+ void handleMetallicChanged(const QVariant &var);
+ void handleRoughnessChanged(const QVariant &var);
+ void handleAmbientOcclusionChanged(const QVariant &var);
+ void handleNormalChanged(const QVariant &var);
+
+ Qt3DRender::QAbstractTexture *m_baseColorTexture;
+ 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_metalnessParameter;
+ Qt3DRender::QParameter *m_roughnessParameter;
+ Qt3DRender::QParameter *m_ambientOcclusionParameter;
+ Qt3DRender::QParameter *m_normalParameter;
+ Qt3DRender::QParameter *m_environmentIrradianceParameter;
+ Qt3DRender::QParameter *m_environmentSpecularParameter;
+ 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
+
diff --git a/src/extras/defaults/qtexturematerial.cpp b/src/extras/defaults/qtexturematerial.cpp
new file mode 100644
index 000000000..0038dd44a
--- /dev/null
+++ b/src/extras/defaults/qtexturematerial.cpp
@@ -0,0 +1,209 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include "qtexturematerial.h"
+#include "qtexturematerial_p.h"
+#include <Qt3DRender/qfilterkey.h>
+#include <Qt3DRender/qmaterial.h>
+#include <Qt3DRender/qeffect.h>
+#include <Qt3DRender/qtexture.h>
+#include <Qt3DRender/qtechnique.h>
+#include <Qt3DRender/qshaderprogram.h>
+#include <Qt3DRender/qparameter.h>
+#include <Qt3DRender/qrenderpass.h>
+#include <Qt3DRender/qgraphicsapifilter.h>
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DRender;
+
+namespace Qt3DExtras {
+
+QTextureMaterialPrivate::QTextureMaterialPrivate()
+ : QMaterialPrivate()
+ , m_textureEffect(new QEffect)
+ , m_textureParameter(new QParameter(QStringLiteral("diffuseTexture"), new QTexture2D))
+ , m_textureOffsetParameter(new QParameter(QStringLiteral("texCoordOffset"), QVector2D(0.0f, 0.0f)))
+ , m_textureGL3Technique(new QTechnique)
+ , m_textureGL2Technique(new QTechnique)
+ , m_textureES2Technique(new QTechnique)
+ , m_textureGL3RenderPass(new QRenderPass)
+ , m_textureGL2RenderPass(new QRenderPass)
+ , m_textureES2RenderPass(new QRenderPass)
+ , m_textureGL3Shader(new QShaderProgram)
+ , m_textureGL2ES2Shader(new QShaderProgram)
+ , m_filterKey(new QFilterKey)
+{
+}
+
+void QTextureMaterialPrivate::init()
+{
+ connect(m_textureParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QTextureMaterialPrivate::handleTextureChanged);
+ connect(m_textureOffsetParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QTextureMaterialPrivate::handleTextureOffsetChanged);
+
+ m_textureGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/unlittexture.vert"))));
+ m_textureGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/unlittexture.frag"))));
+ m_textureGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/unlittexture.vert"))));
+ m_textureGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/unlittexture.frag"))));
+
+ m_textureGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_textureGL3Technique->graphicsApiFilter()->setMajorVersion(3);
+ m_textureGL3Technique->graphicsApiFilter()->setMinorVersion(1);
+ m_textureGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
+
+ m_textureGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_textureGL2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_textureGL2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_textureGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ m_textureES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES);
+ m_textureES2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_textureES2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_textureES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ Q_Q(QTextureMaterial);
+ m_filterKey->setParent(q);
+ m_filterKey->setName(QStringLiteral("renderingStyle"));
+ m_filterKey->setValue(QStringLiteral("forward"));
+
+ m_textureGL3Technique->addFilterKey(m_filterKey);
+ m_textureGL2Technique->addFilterKey(m_filterKey);
+ m_textureES2Technique->addFilterKey(m_filterKey);
+
+ m_textureGL3RenderPass->setShaderProgram(m_textureGL3Shader);
+ m_textureGL2RenderPass->setShaderProgram(m_textureGL2ES2Shader);
+ m_textureES2RenderPass->setShaderProgram(m_textureGL2ES2Shader);
+
+ m_textureGL3Technique->addRenderPass(m_textureGL3RenderPass);
+ m_textureGL2Technique->addRenderPass(m_textureGL2RenderPass);
+ m_textureES2Technique->addRenderPass(m_textureES2RenderPass);
+
+ m_textureEffect->addTechnique(m_textureGL3Technique);
+ m_textureEffect->addTechnique(m_textureGL2Technique);
+ m_textureEffect->addTechnique(m_textureES2Technique);
+
+ m_textureEffect->addParameter(m_textureParameter);
+ m_textureEffect->addParameter(m_textureOffsetParameter);
+
+ q->setEffect(m_textureEffect);
+}
+
+void QTextureMaterialPrivate::handleTextureChanged(const QVariant &var)
+{
+ Q_Q(QTextureMaterial);
+ emit q->textureChanged(var.value<QAbstractTexture *>());
+}
+
+void QTextureMaterialPrivate::handleTextureOffsetChanged(const QVariant &var)
+{
+ Q_Q(QTextureMaterial);
+ emit q->textureOffsetChanged(var.value<QVector2D>());
+}
+
+/*!
+ \class Qt3DExtras::QTextureMaterial
+ \brief The QTextureMaterial provides a default implementation of a simple unlit
+ texture material.
+ \inmodule Qt3DExtras
+ \since 5.9
+ \inherits Qt3DRender::QMaterial
+
+ This material uses an effect with a single render pass approach. Techniques are provided
+ for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2.
+*/
+
+/*!
+ Constructs a new QTextureMaterial instance with parent object \a parent.
+ */
+QTextureMaterial::QTextureMaterial(QNode *parent)
+ : QMaterial(*new QTextureMaterialPrivate, parent)
+{
+ Q_D(QTextureMaterial);
+ d->init();
+}
+
+/*!
+ Destroys the QTextureMaterial instance.
+*/
+QTextureMaterial::~QTextureMaterial()
+{
+}
+
+/*!
+ \property QTextureMaterial::texture
+
+ Holds the current texture used by the material.
+*/
+QAbstractTexture *QTextureMaterial::texture() const
+{
+ Q_D(const QTextureMaterial);
+ return d->m_textureParameter->value().value<QAbstractTexture *>();
+}
+
+/*!
+ \property QTextureMaterial::textureOffset
+
+ Holds the current texture offset. It is applied to texture
+ coordinates at render time. Defaults to (0.0, 0.0).
+
+*/
+QVector2D QTextureMaterial::textureOffset() const
+{
+ Q_D(const QTextureMaterial);
+ return d->m_textureOffsetParameter->value().value<QVector2D>();
+}
+
+void QTextureMaterial::setTexture(QAbstractTexture *texture)
+{
+ Q_D(QTextureMaterial);
+ d->m_textureParameter->setValue(QVariant::fromValue(texture));
+}
+
+void QTextureMaterial::setTextureOffset(QVector2D textureOffset)
+{
+ Q_D(QTextureMaterial);
+ d->m_textureOffsetParameter->setValue(QVariant::fromValue(textureOffset));
+}
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
diff --git a/src/extras/defaults/qtexturematerial.h b/src/extras/defaults/qtexturematerial.h
new file mode 100644
index 000000000..3101b9a1b
--- /dev/null
+++ b/src/extras/defaults/qtexturematerial.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** 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_QTEXTUREMATERIAL_H
+#define QT3DEXTRAS_QTEXTUREMATERIAL_H
+
+#include <Qt3DExtras/qt3dextras_global.h>
+#include <Qt3DRender/qmaterial.h>
+#include <QVector2D>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QAbstractTexture;
+
+} // namespace Qt3DRender
+
+namespace Qt3DExtras {
+
+class QTextureMaterialPrivate;
+
+class QT3DEXTRASSHARED_EXPORT QTextureMaterial : public Qt3DRender::QMaterial
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt3DRender::QAbstractTexture *texture READ texture WRITE setTexture NOTIFY textureChanged)
+ Q_PROPERTY(QVector2D textureOffset READ textureOffset WRITE setTextureOffset NOTIFY textureOffsetChanged)
+public:
+ explicit QTextureMaterial(Qt3DCore::QNode *parent = nullptr);
+ ~QTextureMaterial();
+
+ Qt3DRender::QAbstractTexture *texture() const;
+ QVector2D textureOffset() const;
+
+public Q_SLOTS:
+ void setTexture(Qt3DRender::QAbstractTexture *texture);
+ void setTextureOffset(QVector2D textureOffset);
+
+Q_SIGNALS:
+ void textureChanged(Qt3DRender::QAbstractTexture *texture);
+ void textureOffsetChanged(QVector2D textureOffset);
+
+private:
+ Q_DECLARE_PRIVATE(QTextureMaterial)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QTEXTUREMATERIAL_H
diff --git a/src/extras/defaults/qtexturematerial_p.h b/src/extras/defaults/qtexturematerial_p.h
new file mode 100644
index 000000000..5a8e78154
--- /dev/null
+++ b/src/extras/defaults/qtexturematerial_p.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** 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_QTEXTUREMATERIAL_P_H
+#define QT3DEXTRAS_QTEXTUREMATERIAL_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 <Qt3DRender/private/qmaterial_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QFilterKey;
+class QEffect;
+class QAbstractTexture;
+class QTechnique;
+class QParameter;
+class QShaderProgram;
+class QRenderPass;
+
+} // namespace Qt3DRender
+
+namespace Qt3DExtras {
+
+class QTextureMaterial;
+
+class QTextureMaterialPrivate : public Qt3DRender::QMaterialPrivate
+{
+ QTextureMaterialPrivate();
+
+ void init();
+
+ void handleTextureChanged(const QVariant &var);
+ void handleTextureOffsetChanged(const QVariant &var);
+
+ Qt3DRender::QEffect *m_textureEffect;
+ Qt3DRender::QParameter *m_textureParameter;
+ Qt3DRender::QParameter *m_textureOffsetParameter;
+ Qt3DRender::QTechnique *m_textureGL3Technique;
+ Qt3DRender::QTechnique *m_textureGL2Technique;
+ Qt3DRender::QTechnique *m_textureES2Technique;
+ Qt3DRender::QRenderPass *m_textureGL3RenderPass;
+ Qt3DRender::QRenderPass *m_textureGL2RenderPass;
+ Qt3DRender::QRenderPass *m_textureES2RenderPass;
+ Qt3DRender::QShaderProgram *m_textureGL3Shader;
+ Qt3DRender::QShaderProgram *m_textureGL2ES2Shader;
+ Qt3DRender::QFilterKey *m_filterKey;
+
+ Q_DECLARE_PUBLIC(QTextureMaterial)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QTEXTUREMATERIAL_P_H
+