summaryrefslogtreecommitdiffstats
path: root/src/extras/defaults
diff options
context:
space:
mode:
Diffstat (limited to 'src/extras/defaults')
-rw-r--r--src/extras/defaults/defaults.pri39
-rw-r--r--src/extras/defaults/qdiffusemapmaterial.cpp316
-rw-r--r--src/extras/defaults/qdiffusemapmaterial.h100
-rw-r--r--src/extras/defaults/qdiffusemapmaterial_p.h111
-rw-r--r--src/extras/defaults/qdiffusespecularmapmaterial.cpp330
-rw-r--r--src/extras/defaults/qdiffusespecularmapmaterial.h99
-rw-r--r--src/extras/defaults/qdiffusespecularmapmaterial_p.h114
-rw-r--r--src/extras/defaults/qforwardrenderer.cpp197
-rw-r--r--src/extras/defaults/qforwardrenderer.h92
-rw-r--r--src/extras/defaults/qforwardrenderer_p.h92
-rw-r--r--src/extras/defaults/qgoochmaterial.cpp358
-rw-r--r--src/extras/defaults/qgoochmaterial.h102
-rw-r--r--src/extras/defaults/qgoochmaterial_p.h107
-rw-r--r--src/extras/defaults/qnormaldiffusemapalphamaterial.cpp173
-rw-r--r--src/extras/defaults/qnormaldiffusemapalphamaterial.h67
-rw-r--r--src/extras/defaults/qnormaldiffusemapalphamaterial_p.h87
-rw-r--r--src/extras/defaults/qnormaldiffusemapmaterial.cpp363
-rw-r--r--src/extras/defaults/qnormaldiffusemapmaterial.h107
-rw-r--r--src/extras/defaults/qnormaldiffusemapmaterial_p.h115
-rw-r--r--src/extras/defaults/qnormaldiffusespecularmapmaterial.cpp379
-rw-r--r--src/extras/defaults/qnormaldiffusespecularmapmaterial.h101
-rw-r--r--src/extras/defaults/qnormaldiffusespecularmapmaterial_p.h116
-rw-r--r--src/extras/defaults/qpervertexcolormaterial.cpp163
-rw-r--r--src/extras/defaults/qpervertexcolormaterial.h69
-rw-r--r--src/extras/defaults/qpervertexcolormaterial_p.h99
-rw-r--r--src/extras/defaults/qphongalphamaterial.cpp327
-rw-r--r--src/extras/defaults/qphongalphamaterial.h94
-rw-r--r--src/extras/defaults/qphongalphamaterial_p.h116
-rw-r--r--src/extras/defaults/qphongmaterial.cpp275
-rw-r--r--src/extras/defaults/qphongmaterial.h90
-rw-r--r--src/extras/defaults/qphongmaterial_p.h108
-rw-r--r--src/extras/defaults/qskyboxentity.cpp293
-rw-r--r--src/extras/defaults/qskyboxentity.h81
-rw-r--r--src/extras/defaults/qskyboxentity_p.h122
34 files changed, 5402 insertions, 0 deletions
diff --git a/src/extras/defaults/defaults.pri b/src/extras/defaults/defaults.pri
new file mode 100644
index 000000000..1560f55ec
--- /dev/null
+++ b/src/extras/defaults/defaults.pri
@@ -0,0 +1,39 @@
+INCLUDEPATH += $$PWD
+
+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 \
+ $$PWD/qnormaldiffusemapmaterial_p.h \
+ $$PWD/qnormaldiffusemapalphamaterial.h \
+ $$PWD/qnormaldiffusemapalphamaterial_p.h \
+ $$PWD/qdiffusespecularmapmaterial.h \
+ $$PWD/qdiffusespecularmapmaterial_p.h \
+ $$PWD/qforwardrenderer.h \
+ $$PWD/qforwardrenderer_p.h \
+ $$PWD/qpervertexcolormaterial.h \
+ $$PWD/qpervertexcolormaterial_p.h \
+ $$PWD/qskyboxentity.h \
+ $$PWD/qskyboxentity_p.h \
+ $$PWD/qgoochmaterial.h \
+ $$PWD/qgoochmaterial_p.h \
+ $$PWD/qphongalphamaterial.h \
+ $$PWD/qphongalphamaterial_p.h
+
+SOURCES += \
+ $$PWD/qphongmaterial.cpp \
+ $$PWD/qdiffusemapmaterial.cpp \
+ $$PWD/qnormaldiffusespecularmapmaterial.cpp \
+ $$PWD/qnormaldiffusemapmaterial.cpp \
+ $$PWD/qnormaldiffusemapalphamaterial.cpp \
+ $$PWD/qdiffusespecularmapmaterial.cpp \
+ $$PWD/qforwardrenderer.cpp \
+ $$PWD/qpervertexcolormaterial.cpp \
+ $$PWD/qskyboxentity.cpp \
+ $$PWD/qgoochmaterial.cpp \
+ $$PWD/qphongalphamaterial.cpp
+
diff --git a/src/extras/defaults/qdiffusemapmaterial.cpp b/src/extras/defaults/qdiffusemapmaterial.cpp
new file mode 100644
index 000000000..854d0a809
--- /dev/null
+++ b/src/extras/defaults/qdiffusemapmaterial.cpp
@@ -0,0 +1,316 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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 "qdiffusemapmaterial.h"
+#include "qdiffusemapmaterial_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 {
+
+QDiffuseMapMaterialPrivate::QDiffuseMapMaterialPrivate()
+ : QMaterialPrivate()
+ , m_diffuseMapEffect(new QEffect())
+ , m_diffuseTexture(new QTexture2D())
+ , m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f)))
+ , m_diffuseParameter(new QParameter(QStringLiteral("diffuseTexture"), m_diffuseTexture))
+ , m_specularParameter(new QParameter(QStringLiteral("ks"), QColor::fromRgbF(0.01f, 0.01f, 0.01f, 1.0f)))
+ , m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f))
+ , m_textureScaleParameter(new QParameter(QStringLiteral("texCoordScale"), 1.0f))
+ , m_diffuseMapGL3Technique(new QTechnique())
+ , m_diffuseMapGL2Technique(new QTechnique())
+ , m_diffuseMapES2Technique(new QTechnique())
+ , m_diffuseMapGL3RenderPass(new QRenderPass())
+ , m_diffuseMapGL2RenderPass(new QRenderPass())
+ , m_diffuseMapES2RenderPass(new QRenderPass())
+ , m_diffuseMapGL3Shader(new QShaderProgram())
+ , m_diffuseMapGL2ES2Shader(new QShaderProgram())
+ , m_filterKey(new QFilterKey)
+{
+ m_diffuseTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_diffuseTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_diffuseTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_diffuseTexture->setGenerateMipMaps(true);
+ m_diffuseTexture->setMaximumAnisotropy(16.0f);
+}
+
+void QDiffuseMapMaterialPrivate::init()
+{
+ connect(m_ambientParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QDiffuseMapMaterialPrivate::handleAmbientChanged);
+ connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QDiffuseMapMaterialPrivate::handleDiffuseChanged);
+ connect(m_specularParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QDiffuseMapMaterialPrivate::handleSpecularChanged);
+ connect(m_shininessParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QDiffuseMapMaterialPrivate::handleShininessChanged);
+ connect(m_textureScaleParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QDiffuseMapMaterialPrivate::handleTextureScaleChanged);
+
+ m_diffuseMapGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/diffusemap.vert"))));
+ m_diffuseMapGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/diffusemap.frag"))));
+ m_diffuseMapGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/diffusemap.vert"))));
+ m_diffuseMapGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/diffusemap.frag"))));
+
+ m_diffuseMapGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_diffuseMapGL3Technique->graphicsApiFilter()->setMajorVersion(3);
+ m_diffuseMapGL3Technique->graphicsApiFilter()->setMinorVersion(1);
+ m_diffuseMapGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
+
+ m_diffuseMapGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_diffuseMapGL2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_diffuseMapGL2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_diffuseMapGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ m_diffuseMapES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES);
+ m_diffuseMapES2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_diffuseMapES2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_diffuseMapES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ Q_Q(QDiffuseMapMaterial);
+ m_filterKey->setParent(q);
+ m_filterKey->setName(QStringLiteral("renderingStyle"));
+ m_filterKey->setValue(QStringLiteral("forward"));
+
+ m_diffuseMapGL3Technique->addFilterKey(m_filterKey);
+ m_diffuseMapGL2Technique->addFilterKey(m_filterKey);
+ m_diffuseMapES2Technique->addFilterKey(m_filterKey);
+
+ m_diffuseMapGL3RenderPass->setShaderProgram(m_diffuseMapGL3Shader);
+ m_diffuseMapGL2RenderPass->setShaderProgram(m_diffuseMapGL2ES2Shader);
+ m_diffuseMapES2RenderPass->setShaderProgram(m_diffuseMapGL2ES2Shader);
+
+ m_diffuseMapGL3Technique->addRenderPass(m_diffuseMapGL3RenderPass);
+ m_diffuseMapGL2Technique->addRenderPass(m_diffuseMapGL2RenderPass);
+ m_diffuseMapES2Technique->addRenderPass(m_diffuseMapES2RenderPass);
+
+ m_diffuseMapEffect->addTechnique(m_diffuseMapGL3Technique);
+ m_diffuseMapEffect->addTechnique(m_diffuseMapGL2Technique);
+ m_diffuseMapEffect->addTechnique(m_diffuseMapES2Technique);
+
+ m_diffuseMapEffect->addParameter(m_ambientParameter);
+ m_diffuseMapEffect->addParameter(m_diffuseParameter);
+ m_diffuseMapEffect->addParameter(m_specularParameter);
+ m_diffuseMapEffect->addParameter(m_shininessParameter);
+ m_diffuseMapEffect->addParameter(m_textureScaleParameter);
+
+ q->setEffect(m_diffuseMapEffect);
+}
+
+void QDiffuseMapMaterialPrivate::handleAmbientChanged(const QVariant &var)
+{
+ Q_Q(QDiffuseMapMaterial);
+ emit q->ambientChanged(var.value<QColor>());
+}
+
+void QDiffuseMapMaterialPrivate::handleDiffuseChanged(const QVariant &var)
+{
+ Q_Q(QDiffuseMapMaterial);
+ emit q->diffuseChanged(var.value<QAbstractTexture *>());
+}
+
+void QDiffuseMapMaterialPrivate::handleSpecularChanged(const QVariant &var)
+{
+ Q_Q(QDiffuseMapMaterial);
+ emit q->specularChanged(var.value<QColor>());
+}
+
+void QDiffuseMapMaterialPrivate::handleShininessChanged(const QVariant &var)
+{
+ Q_Q(QDiffuseMapMaterial);
+ emit q->shininessChanged(var.toFloat());
+}
+
+void QDiffuseMapMaterialPrivate::handleTextureScaleChanged(const QVariant &var)
+{
+ Q_Q(QDiffuseMapMaterial);
+ emit q->textureScaleChanged(var.toFloat());
+}
+
+/*!
+ \class Qt3DRender::QDiffuseMapMaterial
+ \brief The QDiffuseMapMaterial provides a default implementation of the phong lighting effect where the diffuse light component
+ is read from a texture map.
+ \inmodule Qt3DRender
+ \since 5.5
+
+ The specular lighting effect is based on the combination of 3 lighting components ambient, diffuse and specular.
+ The relative strengths of these components is controlled by means of their reflectivity coefficients which are modelled as RGB triplets:
+
+ \list
+ \li Ambient is the color that is emitted by an object without any other light source.
+ \li Diffuse is the color that is emitted for rought surface reflections with the lights.
+ \li Specular is the color emitted for shiny surface reflections with the lights.
+ \li The shininess of a surface is controlled by a float property.
+ \endlist
+
+ This material uses an effect with a single render pass approach and performs per fragment lighting.
+ Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2.
+*/
+
+/*!
+ Constructs a new Qt3DRender::QDiffuseMapMaterial instance with parent object \a parent.
+ */
+QDiffuseMapMaterial::QDiffuseMapMaterial(QNode *parent)
+ : QMaterial(*new QDiffuseMapMaterialPrivate, parent)
+{
+ Q_D(QDiffuseMapMaterial);
+ d->init();
+}
+
+/*!
+ Destroys the QDiffuseMapMaterial instance.
+*/
+QDiffuseMapMaterial::~QDiffuseMapMaterial()
+{
+}
+
+/*!
+ \property Qt3DRender::QDiffuseMapMaterial::ambient
+
+ Holds the current ambient color.
+*/
+
+QColor QDiffuseMapMaterial::ambient() const
+{
+ Q_D(const QDiffuseMapMaterial);
+ return d->m_ambientParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QDiffuseMapMaterial::specular
+
+ Holds the current specular color.
+*/
+QColor QDiffuseMapMaterial::specular() const
+{
+ Q_D(const QDiffuseMapMaterial);
+ return d->m_specularParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QDiffuseMapMaterial::shininess
+
+ Holds the current shininess as a float value.
+*/
+float QDiffuseMapMaterial::shininess() const
+{
+ Q_D(const QDiffuseMapMaterial);
+ return d->m_shininessParameter->value().toFloat();
+}
+
+/*!
+ \property Qt3DRender::QDiffuseMapMaterial::diffuse
+
+ Holds the current QTexture used as the diffuse map.
+
+ By default, the diffuse 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 *QDiffuseMapMaterial::diffuse() const
+{
+ Q_D(const QDiffuseMapMaterial);
+ return d->m_diffuseParameter->value().value<QAbstractTexture *>();
+}
+
+/*!
+ \property Qt3DRender::QDiffuseMapMaterial::textureScale
+
+ Holds the current texture scale as a float value.
+
+*/
+float QDiffuseMapMaterial::textureScale() const
+{
+ Q_D(const QDiffuseMapMaterial);
+ return d->m_textureScaleParameter->value().toFloat();
+}
+
+void QDiffuseMapMaterial::setAmbient(const QColor &ambient)
+{
+ Q_D(const QDiffuseMapMaterial);
+ d->m_ambientParameter->setValue(ambient);
+}
+
+void QDiffuseMapMaterial::setSpecular(const QColor &specular)
+{
+ Q_D(QDiffuseMapMaterial);
+ d->m_specularParameter->setValue(specular);
+}
+
+void QDiffuseMapMaterial::setShininess(float shininess)
+{
+ Q_D(QDiffuseMapMaterial);
+ d->m_shininessParameter->setValue(shininess);
+}
+
+void QDiffuseMapMaterial::setDiffuse(QAbstractTexture *diffuseMap)
+{
+ Q_D(QDiffuseMapMaterial);
+ d->m_diffuseParameter->setValue(QVariant::fromValue(diffuseMap));
+}
+
+void QDiffuseMapMaterial::setTextureScale(float textureScale)
+{
+ Q_D(QDiffuseMapMaterial);
+ d->m_textureScaleParameter->setValue(textureScale);
+}
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
diff --git a/src/extras/defaults/qdiffusemapmaterial.h b/src/extras/defaults/qdiffusemapmaterial.h
new file mode 100644
index 000000000..a0e6a88cf
--- /dev/null
+++ b/src/extras/defaults/qdiffusemapmaterial.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QDIFFUSEMAPMATERIAL_H
+#define QT3DEXTRAS_QDIFFUSEMAPMATERIAL_H
+
+#include <Qt3DExtras/qt3dextras_global.h>
+#include <Qt3DRender/qmaterial.h>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QAbstractTexture;
+
+} // namespace Qt3DRender
+
+namespace Qt3DExtras {
+
+class QDiffuseMapMaterialPrivate;
+
+class QT3DEXTRASSHARED_EXPORT QDiffuseMapMaterial : public Qt3DRender::QMaterial
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged)
+ Q_PROPERTY(QColor specular READ specular WRITE setSpecular NOTIFY specularChanged)
+ Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTexture *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(float textureScale READ textureScale WRITE setTextureScale NOTIFY textureScaleChanged)
+
+public:
+ explicit QDiffuseMapMaterial(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QDiffuseMapMaterial();
+
+ QColor ambient() const;
+ QColor specular() const;
+ float shininess() const;
+ Qt3DRender::QAbstractTexture *diffuse() const;
+ float textureScale() const;
+
+public Q_SLOTS:
+ void setAmbient(const QColor &color);
+ void setSpecular(const QColor &specular);
+ void setShininess(float shininess);
+ void setDiffuse(Qt3DRender::QAbstractTexture *diffuse);
+ void setTextureScale(float textureScale);
+
+Q_SIGNALS:
+ void ambientChanged(const QColor &ambient);
+ void diffuseChanged(Qt3DRender::QAbstractTexture *diffuse);
+ void specularChanged(const QColor &specular);
+ void shininessChanged(float shininess);
+ void textureScaleChanged(float textureScale);
+
+private:
+ Q_DECLARE_PRIVATE(QDiffuseMapMaterial)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRASQDIFFUSEMAPMATERIAL_H
diff --git a/src/extras/defaults/qdiffusemapmaterial_p.h b/src/extras/defaults/qdiffusemapmaterial_p.h
new file mode 100644
index 000000000..c0bcc01eb
--- /dev/null
+++ b/src/extras/defaults/qdiffusemapmaterial_p.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QDIFFUSEMAPMATERIAL_P_H
+#define QT3DEXTRAS_QDIFFUSEMAPMATERIAL_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 QDiffuseMapMaterial;
+
+class QDiffuseMapMaterialPrivate : public Qt3DRender::QMaterialPrivate
+{
+ QDiffuseMapMaterialPrivate();
+
+ void init();
+
+ void handleAmbientChanged(const QVariant &var);
+ void handleDiffuseChanged(const QVariant &var);
+ void handleSpecularChanged(const QVariant &var);
+ void handleShininessChanged(const QVariant &var);
+ void handleTextureScaleChanged(const QVariant &var);
+
+ Qt3DRender::QEffect *m_diffuseMapEffect;
+ Qt3DRender::QAbstractTexture *m_diffuseTexture;
+ Qt3DRender::QParameter *m_ambientParameter;
+ Qt3DRender::QParameter *m_diffuseParameter;
+ Qt3DRender::QParameter *m_specularParameter;
+ Qt3DRender::QParameter *m_shininessParameter;
+ Qt3DRender::QParameter *m_textureScaleParameter;
+ Qt3DRender::QTechnique *m_diffuseMapGL3Technique;
+ Qt3DRender::QTechnique *m_diffuseMapGL2Technique;
+ Qt3DRender::QTechnique *m_diffuseMapES2Technique;
+ Qt3DRender::QRenderPass *m_diffuseMapGL3RenderPass;
+ Qt3DRender::QRenderPass *m_diffuseMapGL2RenderPass;
+ Qt3DRender::QRenderPass *m_diffuseMapES2RenderPass;
+ Qt3DRender::QShaderProgram *m_diffuseMapGL3Shader;
+ Qt3DRender::QShaderProgram *m_diffuseMapGL2ES2Shader;
+ Qt3DRender::QFilterKey *m_filterKey;
+
+ Q_DECLARE_PUBLIC(QDiffuseMapMaterial)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QDIFFUSEAPMATERIAL_P_H
+
diff --git a/src/extras/defaults/qdiffusespecularmapmaterial.cpp b/src/extras/defaults/qdiffusespecularmapmaterial.cpp
new file mode 100644
index 000000000..a4ccb6121
--- /dev/null
+++ b/src/extras/defaults/qdiffusespecularmapmaterial.cpp
@@ -0,0 +1,330 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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 "qdiffusespecularmapmaterial.h"
+#include "qdiffusespecularmapmaterial_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 {
+
+QDiffuseSpecularMapMaterialPrivate::QDiffuseSpecularMapMaterialPrivate()
+ : QMaterialPrivate()
+ , m_diffuseSpecularMapEffect(new QEffect())
+ , m_diffuseTexture(new QTexture2D())
+ , m_specularTexture(new QTexture2D())
+ , m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f)))
+ , m_diffuseParameter(new QParameter(QStringLiteral("diffuseTexture"), m_diffuseTexture))
+ , m_specularParameter(new QParameter(QStringLiteral("specularTexture"), m_specularTexture))
+ , m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f))
+ , m_textureScaleParameter(new QParameter(QStringLiteral("texCoordScale"), 1.0f))
+ , m_diffuseSpecularMapGL3Technique(new QTechnique())
+ , m_diffuseSpecularMapGL2Technique(new QTechnique())
+ , m_diffuseSpecularMapES2Technique(new QTechnique())
+ , m_diffuseSpecularMapGL3RenderPass(new QRenderPass())
+ , m_diffuseSpecularMapGL2RenderPass(new QRenderPass())
+ , m_diffuseSpecularMapES2RenderPass(new QRenderPass())
+ , m_diffuseSpecularMapGL3Shader(new QShaderProgram())
+ , m_diffuseSpecularMapGL2ES2Shader(new QShaderProgram())
+ , m_filterKey(new QFilterKey)
+{
+ m_diffuseTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_diffuseTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_diffuseTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_diffuseTexture->setGenerateMipMaps(true);
+ m_diffuseTexture->setMaximumAnisotropy(16.0f);
+
+ m_specularTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_specularTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_specularTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_specularTexture->setGenerateMipMaps(true);
+ m_specularTexture->setMaximumAnisotropy(16.0f);
+}
+
+void QDiffuseSpecularMapMaterialPrivate::init()
+{
+ connect(m_ambientParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QDiffuseSpecularMapMaterialPrivate::handleAmbientChanged);
+ connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QDiffuseSpecularMapMaterialPrivate::handleDiffuseChanged);
+ connect(m_specularParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QDiffuseSpecularMapMaterialPrivate::handleSpecularChanged);
+ connect(m_shininessParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QDiffuseSpecularMapMaterialPrivate::handleShininessChanged);
+ connect(m_textureScaleParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QDiffuseSpecularMapMaterialPrivate::handleTextureScaleChanged);
+
+ m_diffuseSpecularMapGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/diffusemap.vert"))));
+ m_diffuseSpecularMapGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/diffusespecularmap.frag"))));
+ m_diffuseSpecularMapGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/diffusemap.vert"))));
+ m_diffuseSpecularMapGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/diffusespecularmap.frag"))));
+
+ m_diffuseSpecularMapGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_diffuseSpecularMapGL3Technique->graphicsApiFilter()->setMajorVersion(3);
+ m_diffuseSpecularMapGL3Technique->graphicsApiFilter()->setMinorVersion(1);
+ m_diffuseSpecularMapGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
+
+ m_diffuseSpecularMapGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_diffuseSpecularMapGL2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_diffuseSpecularMapGL2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_diffuseSpecularMapGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ m_diffuseSpecularMapES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES);
+ m_diffuseSpecularMapES2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_diffuseSpecularMapES2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_diffuseSpecularMapES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ Q_Q(QDiffuseSpecularMapMaterial);
+ m_filterKey->setParent(q);
+ m_filterKey->setName(QStringLiteral("renderingStyle"));
+ m_filterKey->setValue(QStringLiteral("forward"));
+
+ m_diffuseSpecularMapGL3Technique->addFilterKey(m_filterKey);
+ m_diffuseSpecularMapGL2Technique->addFilterKey(m_filterKey);
+ m_diffuseSpecularMapES2Technique->addFilterKey(m_filterKey);
+
+ m_diffuseSpecularMapGL3RenderPass->setShaderProgram(m_diffuseSpecularMapGL3Shader);
+ m_diffuseSpecularMapGL2RenderPass->setShaderProgram(m_diffuseSpecularMapGL2ES2Shader);
+ m_diffuseSpecularMapES2RenderPass->setShaderProgram(m_diffuseSpecularMapGL2ES2Shader);
+
+ m_diffuseSpecularMapGL3Technique->addRenderPass(m_diffuseSpecularMapGL3RenderPass);
+ m_diffuseSpecularMapGL2Technique->addRenderPass(m_diffuseSpecularMapGL2RenderPass);
+ m_diffuseSpecularMapES2Technique->addRenderPass(m_diffuseSpecularMapES2RenderPass);
+
+ m_diffuseSpecularMapEffect->addTechnique(m_diffuseSpecularMapGL3Technique);
+ m_diffuseSpecularMapEffect->addTechnique(m_diffuseSpecularMapGL2Technique);
+ m_diffuseSpecularMapEffect->addTechnique(m_diffuseSpecularMapES2Technique);
+
+ m_diffuseSpecularMapEffect->addParameter(m_ambientParameter);
+ m_diffuseSpecularMapEffect->addParameter(m_diffuseParameter);
+ m_diffuseSpecularMapEffect->addParameter(m_specularParameter);
+ m_diffuseSpecularMapEffect->addParameter(m_shininessParameter);
+ m_diffuseSpecularMapEffect->addParameter(m_textureScaleParameter);
+
+ q->setEffect(m_diffuseSpecularMapEffect);
+}
+
+void QDiffuseSpecularMapMaterialPrivate::handleAmbientChanged(const QVariant &var)
+{
+ Q_Q(QDiffuseSpecularMapMaterial);
+ emit q->ambientChanged(var.value<QColor>());
+}
+
+void QDiffuseSpecularMapMaterialPrivate::handleDiffuseChanged(const QVariant &var)
+{
+ Q_Q(QDiffuseSpecularMapMaterial);
+ emit q->diffuseChanged(var.value<QAbstractTexture *>());
+}
+
+void QDiffuseSpecularMapMaterialPrivate::handleSpecularChanged(const QVariant &var)
+{
+ Q_Q(QDiffuseSpecularMapMaterial);
+ emit q->specularChanged(var.value<QAbstractTexture *>());
+}
+
+void QDiffuseSpecularMapMaterialPrivate::handleShininessChanged(const QVariant &var)
+{
+ Q_Q(QDiffuseSpecularMapMaterial);
+ emit q->shininessChanged(var.toFloat());
+}
+
+void QDiffuseSpecularMapMaterialPrivate::handleTextureScaleChanged(const QVariant &var)
+{
+ Q_Q(QDiffuseSpecularMapMaterial);
+ emit q->textureScaleChanged(var.toFloat());
+}
+
+/*!
+ \class Qt3DRender::QDiffuseSpecularMapMaterial
+ \brief The QDiffuseSpecularMapMaterial provides a default implementation of the phong lighting and bump effect where the diffuse and specular light components
+ are read from texture maps.
+ \inmodule Qt3DRender
+ \since 5.5
+
+ The specular lighting effect is based on the combination of 3 lighting components ambient, diffuse and specular.
+ The relative strengths of these components is controlled by means of their reflectivity coefficients which are modelled as RGB triplets:
+
+ \list
+ \li Ambient is the color that is emitted by an object without any other light source.
+ \li Diffuse is the color that is emitted for rought surface reflections with the lights.
+ \li Specular is the color emitted for shiny surface reflections with the lights.
+ \li The shininess of a surface is controlled by a float property.
+ \endlist
+
+ This material uses an effect with a single render pass approach and performs per fragment lighting.
+ Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2.
+*/
+
+/*!
+ Constructs a new Qt3DRender::QDiffuseSpecularMapMaterial instance with parent object \a parent.
+*/
+QDiffuseSpecularMapMaterial::QDiffuseSpecularMapMaterial(QNode *parent)
+ : QMaterial(*new QDiffuseSpecularMapMaterialPrivate, parent)
+{
+ Q_D(QDiffuseSpecularMapMaterial);
+ d->init();
+}
+
+/*!
+ Destroys the QDiffuseSpecularMapMaterial instance.
+*/
+QDiffuseSpecularMapMaterial::~QDiffuseSpecularMapMaterial()
+{
+}
+
+/*!
+ \property Qt3DRender::QDiffuseSpecularMapMaterial::ambient
+
+ Holds the current ambient color.
+*/
+QColor QDiffuseSpecularMapMaterial::ambient() const
+{
+ Q_D(const QDiffuseSpecularMapMaterial);
+ return d->m_ambientParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QDiffuseSpecularMapMaterial::diffuse
+
+ Holds the current diffuse map texture.
+
+ By default, the diffuse 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 *QDiffuseSpecularMapMaterial::diffuse() const
+{
+ Q_D(const QDiffuseSpecularMapMaterial);
+ return d->m_diffuseParameter->value().value<QAbstractTexture *>();
+}
+
+/*!
+ \property Qt3DRender::QDiffuseSpecularMapMaterial::specular
+
+ Holds the current specular map texture.
+
+ By default, the specular 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 *QDiffuseSpecularMapMaterial::specular() const
+{
+ Q_D(const QDiffuseSpecularMapMaterial);
+ return d->m_specularParameter->value().value<QAbstractTexture *>();
+}
+
+/*!
+ \property Qt3DRender::QDiffuseSpecularMapMaterial::shininess
+
+ Holds the current shininess as a float value.
+*/
+float QDiffuseSpecularMapMaterial::shininess() const
+{
+ Q_D(const QDiffuseSpecularMapMaterial);
+ return d->m_shininessParameter->value().toFloat();
+}
+
+/*!
+ \property Qt3DRender::QDiffuseSpecularMapMaterial::textureScale
+
+ Holds the current texture scale as a float value.
+*/
+float QDiffuseSpecularMapMaterial::textureScale() const
+{
+ Q_D(const QDiffuseSpecularMapMaterial);
+ return d->m_textureScaleParameter->value().toFloat();
+}
+
+void QDiffuseSpecularMapMaterial::setAmbient(const QColor &ambient)
+{
+ Q_D(QDiffuseSpecularMapMaterial);
+ d->m_ambientParameter->setValue(ambient);
+}
+
+void QDiffuseSpecularMapMaterial::setDiffuse(QAbstractTexture *diffuse)
+{
+ Q_D(QDiffuseSpecularMapMaterial);
+ d->m_diffuseParameter->setValue(QVariant::fromValue(diffuse));
+}
+
+void QDiffuseSpecularMapMaterial::setSpecular(QAbstractTexture *specular)
+{
+ Q_D(QDiffuseSpecularMapMaterial);
+ d->m_specularParameter->setValue(QVariant::fromValue(specular));
+}
+
+void QDiffuseSpecularMapMaterial::setShininess(float shininess)
+{
+ Q_D(QDiffuseSpecularMapMaterial);
+ d->m_shininessParameter->setValue(shininess);
+}
+
+void QDiffuseSpecularMapMaterial::setTextureScale(float textureScale)
+{
+ Q_D(QDiffuseSpecularMapMaterial);
+ d->m_textureScaleParameter->setValue(textureScale);
+}
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
diff --git a/src/extras/defaults/qdiffusespecularmapmaterial.h b/src/extras/defaults/qdiffusespecularmapmaterial.h
new file mode 100644
index 000000000..43e84bf90
--- /dev/null
+++ b/src/extras/defaults/qdiffusespecularmapmaterial.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QDIFFUSESPECULARMAPMATERIAL_H
+#define QT3DEXTRAS_QDIFFUSESPECULARMAPMATERIAL_H
+
+#include <Qt3DExtras/qt3dextras_global.h>
+#include <Qt3DRender/qmaterial.h>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QAbstractTexture;
+} // namespace Qt3DRender
+
+namespace Qt3DExtras {
+
+class QDiffuseSpecularMapMaterialPrivate;
+
+class QT3DEXTRASSHARED_EXPORT QDiffuseSpecularMapMaterial : public Qt3DRender::QMaterial
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged)
+ Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTexture *specular READ specular WRITE setSpecular NOTIFY specularChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTexture *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(float textureScale READ textureScale WRITE setTextureScale NOTIFY textureScaleChanged)
+
+public:
+ explicit QDiffuseSpecularMapMaterial(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QDiffuseSpecularMapMaterial();
+
+ QColor ambient() const;
+ Qt3DRender::QAbstractTexture *diffuse() const;
+ Qt3DRender::QAbstractTexture *specular() const;
+ float shininess() const;
+ float textureScale() const;
+
+public Q_SLOTS:
+ void setAmbient(const QColor &ambient);
+ void setDiffuse(Qt3DRender::QAbstractTexture *diffuse);
+ void setSpecular(Qt3DRender::QAbstractTexture *specular);
+ void setShininess(float shininess);
+ void setTextureScale(float textureScale);
+
+Q_SIGNALS:
+ void ambientChanged(const QColor &ambient);
+ void diffuseChanged(Qt3DRender::QAbstractTexture *diffuse);
+ void specularChanged(Qt3DRender::QAbstractTexture *specular);
+ void shininessChanged(float shininess);
+ void textureScaleChanged(float textureScale);
+
+private:
+ Q_DECLARE_PRIVATE(QDiffuseSpecularMapMaterial)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QDIFFUSESPECULARMAPMATERIAL_H
diff --git a/src/extras/defaults/qdiffusespecularmapmaterial_p.h b/src/extras/defaults/qdiffusespecularmapmaterial_p.h
new file mode 100644
index 000000000..b358e088a
--- /dev/null
+++ b/src/extras/defaults/qdiffusespecularmapmaterial_p.h
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QDIFFUSESPECULARMAPMATERIAL_P_H
+#define QT3DEXTRAS_QDIFFUSESPECULARMAPMATERIAL_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 QDiffuseSpecularMapMaterial;
+
+class QDiffuseSpecularMapMaterialPrivate : public Qt3DRender::QMaterialPrivate
+{
+public:
+ QDiffuseSpecularMapMaterialPrivate();
+
+ void init();
+
+ void handleAmbientChanged(const QVariant &var);
+ void handleDiffuseChanged(const QVariant &var);
+ void handleSpecularChanged(const QVariant &var);
+ void handleShininessChanged(const QVariant &var);
+ void handleTextureScaleChanged(const QVariant &var);
+
+ Qt3DRender::QEffect *m_diffuseSpecularMapEffect;
+ Qt3DRender::QAbstractTexture *m_diffuseTexture;
+ Qt3DRender::QAbstractTexture *m_specularTexture;
+ Qt3DRender::QParameter *m_ambientParameter;
+ Qt3DRender::QParameter *m_diffuseParameter;
+ Qt3DRender::QParameter *m_specularParameter;
+ Qt3DRender::QParameter *m_shininessParameter;
+ Qt3DRender::QParameter *m_textureScaleParameter;
+ Qt3DRender::QTechnique *m_diffuseSpecularMapGL3Technique;
+ Qt3DRender::QTechnique *m_diffuseSpecularMapGL2Technique;
+ Qt3DRender::QTechnique *m_diffuseSpecularMapES2Technique;
+ Qt3DRender::QRenderPass *m_diffuseSpecularMapGL3RenderPass;
+ Qt3DRender::QRenderPass *m_diffuseSpecularMapGL2RenderPass;
+ Qt3DRender::QRenderPass *m_diffuseSpecularMapES2RenderPass;
+ Qt3DRender::QShaderProgram *m_diffuseSpecularMapGL3Shader;
+ Qt3DRender::QShaderProgram *m_diffuseSpecularMapGL2ES2Shader;
+ Qt3DRender::QFilterKey *m_filterKey;
+
+ Q_DECLARE_PUBLIC(QDiffuseSpecularMapMaterial)
+};
+
+} // Qt3DExtras
+
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QDIFFUSESPECULARMAPMATERIAL_P_H
+
diff --git a/src/extras/defaults/qforwardrenderer.cpp b/src/extras/defaults/qforwardrenderer.cpp
new file mode 100644
index 000000000..8e6dc9425
--- /dev/null
+++ b/src/extras/defaults/qforwardrenderer.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 "qforwardrenderer.h"
+#include "qforwardrenderer_p.h"
+
+#include <Qt3DRender/qviewport.h>
+#include <Qt3DRender/qcameraselector.h>
+#include <Qt3DRender/qclearbuffers.h>
+#include <Qt3DRender/qfilterkey.h>
+#include <Qt3DRender/qfrustumculling.h>
+#include <Qt3DRender/qrendersurfaceselector.h>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DRender;
+
+namespace Qt3DExtras {
+
+QForwardRendererPrivate::QForwardRendererPrivate()
+ : QTechniqueFilterPrivate()
+ , m_surfaceSelector(new QRenderSurfaceSelector)
+ , m_viewport(new QViewport())
+ , m_cameraSelector(new QCameraSelector())
+ , m_clearBuffer(new QClearBuffers())
+ , m_frustumCulling(new QFrustumCulling())
+{
+}
+
+void QForwardRendererPrivate::init()
+{
+ Q_Q(QForwardRenderer);
+
+ m_frustumCulling->setParent(m_clearBuffer);
+ m_clearBuffer->setParent(m_cameraSelector);
+ m_cameraSelector->setParent(m_viewport);
+ m_viewport->setParent(m_surfaceSelector);
+ m_surfaceSelector->setParent(q);
+
+ m_viewport->setNormalizedRect(QRectF(0.0f, 0.0f, 1.0f, 1.0f));
+ m_clearBuffer->setClearColor(Qt::white);
+ m_clearBuffer->setBuffers(QClearBuffers::ColorDepthBuffer);
+
+ QFilterKey *forwardRenderingStyle = new QFilterKey(q);
+ forwardRenderingStyle->setName(QStringLiteral("renderingStyle"));
+ forwardRenderingStyle->setValue(QStringLiteral("forward"));
+ q->addMatch(forwardRenderingStyle);
+}
+
+/*!
+ \class Qt3DRender::QForwardRenderer
+ \brief The Qt3DRender::QForwardRenderer provides a default \l {QFrameGraph}{FrameGraph} implementation of a forward renderer.
+ \inmodule Qt3DRender
+ \since 5.5
+
+ Forward rendering is how OpenGL is traditionally. It renders directly to the backbuffer
+ one object at a time shading each one as it goes.
+
+ Internally the Qt3DRender::QForwardRenderer is a subclass of Qt3DRender::QTechniqueFilter.
+ This a is a single leaf Framegraph tree which contains a Qt3DRender::QViewport, a Qt3DRender::QCameraSelector
+ and a Qt3DRender::QClearBuffers.
+ The Qt3DRender::QForwardRenderer has a default requirement annotation whose name is "renderingStyle" and value "forward".
+ If you need to filter out your techniques, you should do so based on that annotation.
+
+ By default the viewport occupies the whole screen and the clear color is white. Frustum culling is also enabled.
+*/
+
+/*!
+ Constructs a new Qt3DRender::QForwardRenderer instance with parent object \a parent.
+ */
+QForwardRenderer::QForwardRenderer(QNode *parent)
+ : QTechniqueFilter(*new QForwardRendererPrivate, parent)
+{
+ Q_D(QForwardRenderer);
+ QObject::connect(d->m_clearBuffer, SIGNAL(clearColorChanged(const QColor &)), this, SIGNAL(clearColorChanged(const QColor &)));
+ QObject::connect(d->m_viewport, SIGNAL(normalizedRectChanged(const QRectF &)), this, SIGNAL(viewportRectChanged(const QRectF &)));
+ QObject::connect(d->m_cameraSelector, SIGNAL(cameraChanged(Qt3DCore::QEntity *)), this, SIGNAL(cameraChanged(Qt3DCore::QEntity *)));
+ QObject::connect(d->m_surfaceSelector, SIGNAL(surfaceChanged(QObject *)), this, SIGNAL(surfaceChanged(QObject *)));
+ d->init();
+}
+
+/*!
+ Destroys the QForwardRenderer instance.
+*/
+QForwardRenderer::~QForwardRenderer()
+{
+}
+
+void QForwardRenderer::setViewportRect(const QRectF &viewportRect)
+{
+ Q_D(QForwardRenderer);
+ d->m_viewport->setNormalizedRect(viewportRect);
+}
+
+void QForwardRenderer::setClearColor(const QColor &clearColor)
+{
+ Q_D(QForwardRenderer);
+ d->m_clearBuffer->setClearColor(clearColor);
+}
+
+/*!
+ Sets the camera which should be used to render the scene to \a camera.
+
+ \note A camera is a QEntity having a QCameraLens as one of its components.
+*/
+void QForwardRenderer::setCamera(Qt3DCore::QEntity *camera)
+{
+ Q_D(QForwardRenderer);
+ d->m_cameraSelector->setCamera(camera);
+}
+
+void QForwardRenderer::setSurface(QObject *surface)
+{
+ Q_D(QForwardRenderer);
+ d->m_surfaceSelector->setSurface(surface);
+}
+
+/*!
+ \property Qt3DRender::QForwardRenderer::viewportRect
+
+ Holds the current viewport normalizedRect.
+ */
+QRectF QForwardRenderer::viewportRect() const
+{
+ Q_D(const QForwardRenderer);
+ return d->m_viewport->normalizedRect();
+}
+
+/*!
+ \property Qt3DRender::QForwardRenderer::clearColor
+
+ Holds the current clearColor.
+*/
+QColor QForwardRenderer::clearColor() const
+{
+ Q_D(const QForwardRenderer);
+ return d->m_clearBuffer->clearColor();
+}
+
+/*!
+ \property Qt3DRender::QForwardRenderer::camera
+
+ Holds the current QEntity camera used to render the scene.
+
+ \note A camera is a QEntity that has a QCameraLens as one of its components.
+*/
+Qt3DCore::QEntity *QForwardRenderer::camera() const
+{
+ Q_D(const QForwardRenderer);
+ return d->m_cameraSelector->camera();
+}
+
+QObject *QForwardRenderer::surface() const
+{
+ Q_D(const QForwardRenderer);
+ return d->m_surfaceSelector->surface();
+}
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
diff --git a/src/extras/defaults/qforwardrenderer.h b/src/extras/defaults/qforwardrenderer.h
new file mode 100644
index 000000000..34ea9055b
--- /dev/null
+++ b/src/extras/defaults/qforwardrenderer.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QFORWARDRENDERER_H
+#define QT3DEXTRAS_QFORWARDRENDERER_H
+
+#include <Qt3DExtras/qt3dextras_global.h>
+#include <Qt3DRender/qtechniquefilter.h>
+#include <QRectF>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+class QSurface;
+
+namespace Qt3DExtras {
+
+class QForwardRendererPrivate;
+
+class QT3DEXTRASSHARED_EXPORT QForwardRenderer : public Qt3DRender::QTechniqueFilter
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject *surface 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)
+public:
+ explicit QForwardRenderer(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QForwardRenderer();
+
+ QRectF viewportRect() const;
+ QColor clearColor() const;
+ Qt3DCore::QEntity *camera() const;
+ QObject *surface() const;
+
+public Q_SLOTS:
+ void setViewportRect(const QRectF &viewportRect);
+ void setClearColor(const QColor &clearColor);
+ void setCamera(Qt3DCore::QEntity *camera);
+ void setSurface(QObject * surface);
+
+Q_SIGNALS:
+ void viewportRectChanged(const QRectF &viewportRect);
+ void clearColorChanged(const QColor &clearColor);
+ void cameraChanged(Qt3DCore::QEntity *camera);
+ void surfaceChanged(QObject *surface);
+
+private:
+ Q_DECLARE_PRIVATE(QForwardRenderer)
+};
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QFORWARDRENDERER_H
diff --git a/src/extras/defaults/qforwardrenderer_p.h b/src/extras/defaults/qforwardrenderer_p.h
new file mode 100644
index 000000000..56d66a542
--- /dev/null
+++ b/src/extras/defaults/qforwardrenderer_p.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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_QFORWARDRENDERER_P_H
+#define QT3DEXTRAS_QFORWARDRENDERER_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/qtechniquefilter_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QForwardRenderer;
+class QViewport;
+class QClearBuffers;
+class QCameraSelector;
+class QFrustumCulling;
+class QRenderSurfaceSelector;
+
+} // namespace Qt3DRender
+
+namespace Qt3DExtras {
+
+class QForwardRendererPrivate: public Qt3DRender::QTechniqueFilterPrivate
+{
+public:
+ QForwardRendererPrivate();
+
+ Qt3DRender::QRenderSurfaceSelector *m_surfaceSelector;
+ Qt3DRender::QViewport *m_viewport;
+ Qt3DRender::QCameraSelector *m_cameraSelector;
+ Qt3DRender::QClearBuffers *m_clearBuffer;
+ Qt3DRender::QFrustumCulling *m_frustumCulling;
+
+ void init();
+
+ Q_DECLARE_PUBLIC(QForwardRenderer)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QFORWARDRENDERER_P_H
+
diff --git a/src/extras/defaults/qgoochmaterial.cpp b/src/extras/defaults/qgoochmaterial.cpp
new file mode 100644
index 000000000..7b4865734
--- /dev/null
+++ b/src/extras/defaults/qgoochmaterial.cpp
@@ -0,0 +1,358 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 "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
+
+namespace Qt3DRender {
+
+QGoochMaterialPrivate::QGoochMaterialPrivate()
+ : QMaterialPrivate()
+ , m_effect(new QEffect)
+ , m_diffuseParameter(new QParameter(QStringLiteral("kd"), QColor::fromRgbF(0.0f, 0.0f, 0.0f)))
+ , m_specularParameter(new QParameter(QStringLiteral("ks"), QColor::fromRgbF(0.0f, 0.0f, 0.0f)))
+ , m_coolParameter(new QParameter(QStringLiteral("kblue"), QColor::fromRgbF(0.0f, 0.0f, 0.4f)))
+ , m_warmParameter(new QParameter(QStringLiteral("kyellow"), QColor::fromRgbF(0.4f, 0.4f, 0.0f)))
+ , m_alphaParameter(new QParameter(QStringLiteral("alpha"), 0.25f))
+ , m_betaParameter(new QParameter(QStringLiteral("beta"), 0.5f))
+ , m_shininessParameter(new QParameter(QStringLiteral("shininess"), 100.0f))
+ , m_gl3Technique(new QTechnique)
+ , m_gl2Technique(new QTechnique)
+ , m_es2Technique(new QTechnique)
+ , m_gl3RenderPass(new QRenderPass)
+ , m_gl2RenderPass(new QRenderPass)
+ , m_es2RenderPass(new QRenderPass)
+ , m_gl3Shader(new QShaderProgram)
+ , m_gl2ES2Shader(new QShaderProgram)
+ , m_filterKey(new QFilterKey)
+{
+}
+
+void QGoochMaterialPrivate::init()
+{
+ Q_Q(QGoochMaterial);
+
+ connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QGoochMaterialPrivate::handleDiffuseChanged);
+ connect(m_specularParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QGoochMaterialPrivate::handleSpecularChanged);
+ connect(m_coolParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QGoochMaterialPrivate::handleCoolChanged);
+ connect(m_warmParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QGoochMaterialPrivate::handleWarmChanged);
+ connect(m_alphaParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QGoochMaterialPrivate::handleAlphaChanged);
+ connect(m_betaParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QGoochMaterialPrivate::handleBetaChanged);
+ connect(m_shininessParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QGoochMaterialPrivate::handleShininessChanged);
+
+ m_gl3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/gooch.vert"))));
+ m_gl3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/gooch.frag"))));
+ m_gl2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/gooch.vert"))));
+ m_gl2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/gooch.frag"))));
+
+ m_gl3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_gl3Technique->graphicsApiFilter()->setMajorVersion(3);
+ m_gl3Technique->graphicsApiFilter()->setMinorVersion(1);
+ m_gl3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
+
+ m_gl2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_gl2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_gl2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_gl2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ m_es2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES);
+ m_es2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_es2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_es2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ m_filterKey->setParent(q);
+ m_filterKey->setName(QStringLiteral("renderingStyle"));
+ m_filterKey->setValue(QStringLiteral("forward"));
+
+ m_gl3Technique->addFilterKey(m_filterKey);
+ m_gl2Technique->addFilterKey(m_filterKey);
+ m_es2Technique->addFilterKey(m_filterKey);
+
+ m_gl3RenderPass->setShaderProgram(m_gl3Shader);
+ m_gl2RenderPass->setShaderProgram(m_gl2ES2Shader);
+ m_es2RenderPass->setShaderProgram(m_gl2ES2Shader);
+
+ m_gl3Technique->addRenderPass(m_gl3RenderPass);
+ m_gl2Technique->addRenderPass(m_gl2RenderPass);
+ m_es2Technique->addRenderPass(m_es2RenderPass);
+
+ m_effect->addTechnique(m_gl3Technique);
+ m_effect->addTechnique(m_gl2Technique);
+ m_effect->addTechnique(m_es2Technique);
+
+ m_effect->addParameter(m_diffuseParameter);
+ m_effect->addParameter(m_specularParameter);
+ m_effect->addParameter(m_coolParameter);
+ m_effect->addParameter(m_warmParameter);
+ m_effect->addParameter(m_alphaParameter);
+ m_effect->addParameter(m_betaParameter);
+ m_effect->addParameter(m_shininessParameter);
+
+ q->setEffect(m_effect);
+}
+
+void QGoochMaterialPrivate::handleDiffuseChanged(const QVariant &var)
+{
+ Q_Q(QGoochMaterial);
+ emit q->diffuseChanged(var.value<QColor>());
+}
+
+void QGoochMaterialPrivate::handleSpecularChanged(const QVariant &var)
+{
+ Q_Q(QGoochMaterial);
+ emit q->specularChanged(var.value<QColor>());
+}
+
+void QGoochMaterialPrivate::handleCoolChanged(const QVariant &var)
+{
+ Q_Q(QGoochMaterial);
+ emit q->coolChanged(var.value<QColor>());
+}
+
+void QGoochMaterialPrivate::handleWarmChanged(const QVariant &var)
+{
+ Q_Q(QGoochMaterial);
+ emit q->warmChanged(var.value<QColor>());
+}
+
+void QGoochMaterialPrivate::handleAlphaChanged(const QVariant &var)
+{
+ Q_Q(QGoochMaterial);
+ emit q->alphaChanged(var.toFloat());
+}
+
+void QGoochMaterialPrivate::handleBetaChanged(const QVariant &var)
+{
+ Q_Q(QGoochMaterial);
+ emit q->betaChanged(var.toFloat());
+}
+
+void QGoochMaterialPrivate::handleShininessChanged(const QVariant &var)
+{
+ Q_Q(QGoochMaterial);
+ emit q->shininessChanged(var.toFloat());
+}
+
+/*!
+ \class Qt3DRender::QGoochMaterial
+ \brief The QGoochMaterial provides a material that implements the Gooch
+ shading model, popular in CAD and CAM applications.
+ \inmodule Qt3DRender
+ \since 5.5
+
+ The Gooch lighting model uses both color and brightness to help show the
+ curvature of 3D surfaces. This is often better than models such as Phong
+ that rely purely upon changes in brightness. In situations such as in CAD
+ and CAM applications where photorealism is not a goal, the Gooch shading
+ model in conjunction with some kind of silhouette edge inking is a popular
+ solution.
+
+ The Gooch lighting model is explained fully in the \l{original Gooch
+ paper}. The Gooch model mixes a diffuse objetc color with a user-provided
+ cool color and warm color to produce the end points of a color ramp that is
+ used to shade the object based upon the cosine of the angle between the
+ vector from the fragment to the light source and the fragment's normal
+ vector. Optionally, a specular highlight can be added on top. The relative
+ contributions to the cool and warm colors by the diffuse color are
+ controlled by the alpha and beta properties respecitvely.
+
+ This material uses an effect with a single render pass approach and
+ performs per fragment lighting. Techniques are provided for OpenGL 2,
+ OpenGL 3 or above as well as OpenGL ES 2.
+*/
+
+/*!
+ Constructs a new Qt3DCore::QGoochMaterial instance with parent object \a parent.
+*/
+QGoochMaterial::QGoochMaterial(QNode *parent)
+ : QMaterial(*new QGoochMaterialPrivate, parent)
+{
+ Q_D(QGoochMaterial);
+ d->init();
+}
+
+QGoochMaterial::QGoochMaterial(QGoochMaterialPrivate &dd, QNode *parent)
+ : QMaterial(dd, parent)
+{
+ Q_D(QGoochMaterial);
+ d->init();
+}
+
+/*!
+ \property Qt3DRender::QGoochMaterial::diffuse
+
+ Holds the current diffuse color.
+*/
+QColor QGoochMaterial::diffuse() const
+{
+ Q_D(const QGoochMaterial);
+ return d->m_diffuseParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QGoochMaterial::specular
+
+ Holds the current specular color.
+*/
+QColor QGoochMaterial::specular() const
+{
+ Q_D(const QGoochMaterial);
+ return d->m_specularParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QGoochMaterial::cool
+
+ Holds the current cool color.
+*/
+QColor QGoochMaterial::cool() const
+{
+ Q_D(const QGoochMaterial);
+ return d->m_coolParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QGoochMaterial::warm
+
+ Holds the current warm color.
+*/
+QColor QGoochMaterial::warm() const
+{
+ Q_D(const QGoochMaterial);
+ return d->m_warmParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QGoochMaterial::alpha
+
+ Holds the current alpha value. The start point of the color ramp
+ used by the Gooch shader is calculated as {c = cool + alpha * diffuse}.
+*/
+float QGoochMaterial::alpha() const
+{
+ Q_D(const QGoochMaterial);
+ return d->m_alphaParameter->value().toFloat();
+}
+
+/*!
+ \property Qt3DRender::QGoochMaterial::beta
+
+ Holds the current beta value. The start point of the color ramp
+ used by the Gooch shader is calculated as {c = warm + beta * diffuse}.
+*/
+float QGoochMaterial::beta() const
+{
+ Q_D(const QGoochMaterial);
+ return d->m_betaParameter->value().toFloat();
+}
+
+/*!
+ \property Qt3DRender::QGoochMaterial::shininess
+
+ Holds the current shininess value. Higher values of shininess result in
+ a smaller and brighter highlight.
+*/
+float QGoochMaterial::shininess() const
+{
+ Q_D(const QGoochMaterial);
+ return d->m_shininessParameter->value().toFloat();
+}
+
+void QGoochMaterial::setDiffuse(const QColor &diffuse)
+{
+ Q_D(QGoochMaterial);
+ return d->m_diffuseParameter->setValue(diffuse);
+}
+
+void QGoochMaterial::setSpecular(const QColor &specular)
+{
+ Q_D(QGoochMaterial);
+ return d->m_specularParameter->setValue(specular);
+}
+
+void QGoochMaterial::setCool(const QColor &cool)
+{
+ Q_D(QGoochMaterial);
+ return d->m_coolParameter->setValue(cool);
+}
+
+void QGoochMaterial::setWarm(const QColor &warm)
+{
+ Q_D(QGoochMaterial);
+ return d->m_warmParameter->setValue(warm);
+}
+
+void QGoochMaterial::setAlpha(float alpha)
+{
+ Q_D(QGoochMaterial);
+ return d->m_alphaParameter->setValue(alpha);
+}
+
+void QGoochMaterial::setBeta(float beta)
+{
+ Q_D(QGoochMaterial);
+ return d->m_betaParameter->setValue(beta);
+}
+
+void QGoochMaterial::setShininess(float shininess)
+{
+ Q_D(QGoochMaterial);
+ return d->m_shininessParameter->setValue(shininess);
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/extras/defaults/qgoochmaterial.h b/src/extras/defaults/qgoochmaterial.h
new file mode 100644
index 000000000..cf2c1c5fc
--- /dev/null
+++ b/src/extras/defaults/qgoochmaterial.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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_QGOOCHMATERIAL_H
+#define QT3DEXTRAS_QGOOCHMATERIAL_H
+
+#include <Qt3DRender/qmaterial.h>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QGoochMaterialPrivate;
+
+class QGoochMaterial : public QMaterial
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(QColor specular READ specular WRITE setSpecular NOTIFY specularChanged)
+ Q_PROPERTY(QColor cool READ cool WRITE setCool NOTIFY coolChanged)
+ Q_PROPERTY(QColor warm READ warm WRITE setWarm NOTIFY warmChanged)
+ Q_PROPERTY(float alpha READ alpha WRITE setAlpha NOTIFY alphaChanged)
+ Q_PROPERTY(float beta READ beta WRITE setBeta NOTIFY betaChanged)
+ Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged)
+
+public:
+ explicit QGoochMaterial(Qt3DCore::QNode *parent = Q_NULLPTR);
+ QColor diffuse() const;
+ QColor specular() const;
+ QColor cool() const;
+ QColor warm() const;
+ float alpha() const;
+ float beta() const;
+ float shininess() const;
+
+public Q_SLOTS:
+ void setDiffuse(const QColor &diffuse);
+ void setSpecular(const QColor &specular);
+ void setCool(const QColor &cool);
+ void setWarm(const QColor &warm);
+ void setAlpha(float alpha);
+ void setBeta(float beta);
+ void setShininess(float shininess);
+
+Q_SIGNALS:
+ void diffuseChanged(const QColor &diffuse);
+ void specularChanged(const QColor &specular);
+ void coolChanged(const QColor &cool);
+ void warmChanged(const QColor &warm);
+ void alphaChanged(float alpha);
+ void betaChanged(float beta);
+ void shininessChanged(float shininess);
+
+protected:
+ QGoochMaterial(QGoochMaterialPrivate &dd, Qt3DCore::QNode *parent = Q_NULLPTR);
+
+private:
+ Q_DECLARE_PRIVATE(QGoochMaterial)
+};
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QGOOCHMATERIAL_H
diff --git a/src/extras/defaults/qgoochmaterial_p.h b/src/extras/defaults/qgoochmaterial_p.h
new file mode 100644
index 000000000..0a6f67aea
--- /dev/null
+++ b/src/extras/defaults/qgoochmaterial_p.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QGOOCHMATERIAL_P_H
+#define QT3DEXTRAS_QGOOCHMATERIAL_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 QRenderPass;
+class QShaderProgram;
+class QTechnique;
+
+class QGoochMaterialPrivate : public QMaterialPrivate
+{
+public:
+ QGoochMaterialPrivate();
+
+ void init();
+
+ void handleDiffuseChanged(const QVariant &var);
+ void handleSpecularChanged(const QVariant &var);
+ void handleCoolChanged(const QVariant &var);
+ void handleWarmChanged(const QVariant &var);
+ void handleAlphaChanged(const QVariant &var);
+ void handleBetaChanged(const QVariant &var);
+ void handleShininessChanged(const QVariant &var);
+
+ QEffect *m_effect;
+ QParameter *m_diffuseParameter;
+ QParameter *m_specularParameter;
+ QParameter *m_coolParameter;
+ QParameter *m_warmParameter;
+ QParameter *m_alphaParameter;
+ QParameter *m_betaParameter;
+ QParameter *m_shininessParameter;
+ QTechnique *m_gl3Technique;
+ QTechnique *m_gl2Technique;
+ QTechnique *m_es2Technique;
+ QRenderPass *m_gl3RenderPass;
+ QRenderPass *m_gl2RenderPass;
+ QRenderPass *m_es2RenderPass;
+ QShaderProgram *m_gl3Shader;
+ QShaderProgram *m_gl2ES2Shader;
+ QFilterKey *m_filterKey;
+
+ Q_DECLARE_PUBLIC(QGoochMaterial)
+};
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QGOOCHMATERIAL_P_H
+
diff --git a/src/extras/defaults/qnormaldiffusemapalphamaterial.cpp b/src/extras/defaults/qnormaldiffusemapalphamaterial.cpp
new file mode 100644
index 000000000..df61eafdf
--- /dev/null
+++ b/src/extras/defaults/qnormaldiffusemapalphamaterial.cpp
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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 "qnormaldiffusemapalphamaterial.h"
+#include "qnormaldiffusemapalphamaterial_p.h"
+
+#include <Qt3DRender/qeffect.h>
+#include <Qt3DRender/qtexture.h>
+#include <Qt3DRender/qtechnique.h>
+#include <Qt3DRender/qparameter.h>
+#include <Qt3DRender/qshaderprogram.h>
+#include <Qt3DRender/qrenderpass.h>
+#include <Qt3DRender/qgraphicsapifilter.h>
+#include <Qt3DRender/qalphacoverage.h>
+#include <Qt3DRender/qdepthtest.h>
+
+#include <QUrl>
+#include <QVector3D>
+#include <QVector4D>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DRender;
+
+namespace Qt3DExtras {
+
+
+QNormalDiffuseMapAlphaMaterialPrivate::QNormalDiffuseMapAlphaMaterialPrivate()
+ : QNormalDiffuseMapMaterialPrivate()
+ , m_alphaCoverage(new QAlphaCoverage())
+ , m_depthTest(new QDepthTest())
+{
+}
+
+void QNormalDiffuseMapAlphaMaterialPrivate::init()
+{
+ m_normalDiffuseGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/normaldiffusemap.vert"))));
+ m_normalDiffuseGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/normaldiffusemapalpha.frag"))));
+ m_normalDiffuseGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/normaldiffusemap.vert"))));
+ m_normalDiffuseGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/normaldiffusemapalpha.frag"))));
+
+ m_normalDiffuseGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_normalDiffuseGL3Technique->graphicsApiFilter()->setMajorVersion(3);
+ m_normalDiffuseGL3Technique->graphicsApiFilter()->setMinorVersion(1);
+ m_normalDiffuseGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
+
+ m_normalDiffuseGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_normalDiffuseGL2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_normalDiffuseGL2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_normalDiffuseGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ m_normalDiffuseES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES);
+ m_normalDiffuseES2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_normalDiffuseES2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_normalDiffuseES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ Q_Q(QNormalDiffuseMapMaterial);
+ m_filterKey->setParent(q);
+ m_filterKey->setName(QStringLiteral("renderingStyle"));
+ m_filterKey->setValue(QStringLiteral("forward"));
+
+ m_normalDiffuseGL3Technique->addFilterKey(m_filterKey);
+ m_normalDiffuseGL2Technique->addFilterKey(m_filterKey);
+ m_normalDiffuseES2Technique->addFilterKey(m_filterKey);
+
+ m_depthTest->setDepthFunction(QDepthTest::Less);
+
+ m_normalDiffuseGL3RenderPass->setShaderProgram(m_normalDiffuseGL3Shader);
+ m_normalDiffuseGL3RenderPass->addRenderState(m_alphaCoverage);
+ m_normalDiffuseGL3RenderPass->addRenderState(m_depthTest);
+
+ m_normalDiffuseGL2RenderPass->setShaderProgram(m_normalDiffuseGL2ES2Shader);
+ m_normalDiffuseGL2RenderPass->addRenderState(m_alphaCoverage);
+ m_normalDiffuseGL2RenderPass->addRenderState(m_depthTest);
+
+ m_normalDiffuseES2RenderPass->setShaderProgram(m_normalDiffuseGL2ES2Shader);
+ m_normalDiffuseES2RenderPass->addRenderState(m_alphaCoverage);
+ m_normalDiffuseES2RenderPass->addRenderState(m_depthTest);
+
+ m_normalDiffuseGL3Technique->addRenderPass(m_normalDiffuseGL3RenderPass);
+ m_normalDiffuseGL2Technique->addRenderPass(m_normalDiffuseGL2RenderPass);
+ m_normalDiffuseES2Technique->addRenderPass(m_normalDiffuseES2RenderPass);
+
+ m_normalDiffuseEffect->addTechnique(m_normalDiffuseGL3Technique);
+ m_normalDiffuseEffect->addTechnique(m_normalDiffuseGL2Technique);
+ m_normalDiffuseEffect->addTechnique(m_normalDiffuseES2Technique);
+
+ m_normalDiffuseEffect->addParameter(m_ambientParameter);
+ m_normalDiffuseEffect->addParameter(m_diffuseParameter);
+ m_normalDiffuseEffect->addParameter(m_normalParameter);
+ m_normalDiffuseEffect->addParameter(m_specularParameter);
+ m_normalDiffuseEffect->addParameter(m_shininessParameter);
+ m_normalDiffuseEffect->addParameter(m_textureScaleParameter);
+
+ q->setEffect(m_normalDiffuseEffect);
+}
+
+
+/*!
+ \class Qt3DRender::QNormalDiffuseMapAlphaMaterial
+ \brief The QNormalDiffuseMapAlphaMaterial provides a default implementation of the phong lighting and bump effect where the diffuse light component
+ is read from a texture map and the normals of the mesh being rendered from a normal texture map. In addition, it defines an alpha to coverage and
+ a depth test to be performed in the rendering pass.
+ \inmodule Qt3DRender
+ \since 5.5
+
+ The specular lighting effect is based on the combination of 3 lighting components ambient, diffuse and specular.
+ The relative strengths of these components is controlled by means of their reflectivity coefficients which are modelled as RGB triplets:
+
+ \list
+ \li Ambient is the color that is emitted by an object without any other light source.
+ \li Diffuse is the color that is emitted for rought surface reflections with the lights.
+ \li Specular is the color emitted for shiny surface reflections with the lights.
+ \li The shininess of a surface is controlled by a float property.
+ \endlist
+
+ This material uses an effect with a single render pass approach and performs per fragment lighting.
+ Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2.
+*/
+/*!
+ Constructs a new Qt3DRender::QNormalDiffuseMapAlphaMaterial instance with parent object \a parent.
+*/
+QNormalDiffuseMapAlphaMaterial::QNormalDiffuseMapAlphaMaterial(QNode *parent)
+ : QNormalDiffuseMapMaterial(*new QNormalDiffuseMapAlphaMaterialPrivate, parent)
+{
+}
+
+/*!
+ Destroys the QNormalDiffuseMapAlphaMaterial instance.
+*/
+QNormalDiffuseMapAlphaMaterial::~QNormalDiffuseMapAlphaMaterial()
+{
+}
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/extras/defaults/qnormaldiffusemapalphamaterial.h b/src/extras/defaults/qnormaldiffusemapalphamaterial.h
new file mode 100644
index 000000000..ad4dd6c53
--- /dev/null
+++ b/src/extras/defaults/qnormaldiffusemapalphamaterial.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QNORMALDIFFUSEMAPALPHAMATERIAL_H
+#define QT3DEXTRAS_QNORMALDIFFUSEMAPALPHAMATERIAL_H
+
+#include <Qt3DExtras/qt3dextras_global.h>
+#include <Qt3DExtras/qnormaldiffusemapmaterial.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DExtras {
+
+class QNormalDiffuseMapAlphaMaterialPrivate;
+
+class QT3DEXTRASSHARED_EXPORT QNormalDiffuseMapAlphaMaterial : public QNormalDiffuseMapMaterial
+{
+ Q_OBJECT
+public:
+ explicit QNormalDiffuseMapAlphaMaterial(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QNormalDiffuseMapAlphaMaterial();
+
+private:
+ Q_DECLARE_PRIVATE(QNormalDiffuseMapAlphaMaterial)
+};
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QNORMALDIFFUSEMAPALPHAMATERIAL_H
diff --git a/src/extras/defaults/qnormaldiffusemapalphamaterial_p.h b/src/extras/defaults/qnormaldiffusemapalphamaterial_p.h
new file mode 100644
index 000000000..91b0961f1
--- /dev/null
+++ b/src/extras/defaults/qnormaldiffusemapalphamaterial_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QNORMALDIFFUSEMAPALPHAMATERIAL_P_H
+#define QT3DEXTRAS_QNORMALDIFFUSEMAPALPHAMATERIAL_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 <qnormaldiffusemapmaterial_p.h>
+
+QT_BEGIN_NAMESPACE
+
+
+namespace Qt3DRender {
+
+class QAlphaCoverage;
+class QDepthTest;
+
+} // namespace Qt3DRender
+
+namespace Qt3DExtras {
+
+class QNormalDiffuseMapAlphaMaterial;
+class QNormalDiffuseMapAlphaMaterialPrivate: public QNormalDiffuseMapMaterialPrivate
+{
+public:
+ QNormalDiffuseMapAlphaMaterialPrivate();
+
+ void init() Q_DECL_OVERRIDE;
+
+ Qt3DRender::QAlphaCoverage *m_alphaCoverage;
+ Qt3DRender::QDepthTest *m_depthTest;
+
+ Q_DECLARE_PUBLIC(QNormalDiffuseMapAlphaMaterial)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QNORMALDIFFUSEMAPALPHAMATERIAL_P_H
+
diff --git a/src/extras/defaults/qnormaldiffusemapmaterial.cpp b/src/extras/defaults/qnormaldiffusemapmaterial.cpp
new file mode 100644
index 000000000..01d67a477
--- /dev/null
+++ b/src/extras/defaults/qnormaldiffusemapmaterial.cpp
@@ -0,0 +1,363 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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 "qnormaldiffusemapmaterial.h"
+#include "qnormaldiffusemapmaterial_p.h"
+#include <Qt3DRender/qfilterkey.h>
+#include <Qt3DRender/qeffect.h>
+#include <Qt3DRender/qtexture.h>
+#include <Qt3DRender/qtechnique.h>
+#include <Qt3DRender/qparameter.h>
+#include <Qt3DRender/qshaderprogram.h>
+#include <Qt3DRender/qrenderpass.h>
+#include <Qt3DRender/qgraphicsapifilter.h>
+
+#include <QUrl>
+#include <QVector3D>
+#include <QVector4D>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DRender;
+
+namespace Qt3DExtras {
+
+QNormalDiffuseMapMaterialPrivate::QNormalDiffuseMapMaterialPrivate()
+ : QMaterialPrivate()
+ , m_normalDiffuseEffect(new QEffect())
+ , m_diffuseTexture(new QTexture2D())
+ , m_normalTexture(new QTexture2D())
+ , m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.1f, 0.1f, 0.1f, 1.0f)))
+ , m_diffuseParameter(new QParameter(QStringLiteral("diffuseTexture"), m_diffuseTexture))
+ , m_normalParameter(new QParameter(QStringLiteral("normalTexture"), m_normalTexture))
+ , m_specularParameter(new QParameter(QStringLiteral("ks"), QColor::fromRgbF(0.01f, 0.01f, 0.01f, 1.0f)))
+ , m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f))
+ , m_textureScaleParameter(new QParameter(QStringLiteral("texCoordScale"), 1.0f))
+ , m_normalDiffuseGL3Technique(new QTechnique())
+ , m_normalDiffuseGL2Technique(new QTechnique())
+ , m_normalDiffuseES2Technique(new QTechnique())
+ , m_normalDiffuseGL3RenderPass(new QRenderPass())
+ , m_normalDiffuseGL2RenderPass(new QRenderPass())
+ , m_normalDiffuseES2RenderPass(new QRenderPass())
+ , m_normalDiffuseGL3Shader(new QShaderProgram())
+ , m_normalDiffuseGL2ES2Shader(new QShaderProgram())
+ , m_filterKey(new QFilterKey)
+{
+ m_diffuseTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_diffuseTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_diffuseTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_diffuseTexture->setGenerateMipMaps(true);
+ m_diffuseTexture->setMaximumAnisotropy(16.0f);
+
+ m_normalTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_normalTexture->setMinificationFilter(QAbstractTexture::Linear);
+ m_normalTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_normalTexture->setMaximumAnisotropy(16.0f);
+}
+
+void QNormalDiffuseMapMaterialPrivate::init()
+{
+ connect(m_ambientParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QNormalDiffuseMapMaterialPrivate::handleAmbientChanged);
+ connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QNormalDiffuseMapMaterialPrivate::handleDiffuseChanged);
+ connect(m_normalParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QNormalDiffuseMapMaterialPrivate::handleNormalChanged);
+ connect(m_specularParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QNormalDiffuseMapMaterialPrivate::handleSpecularChanged);
+ connect(m_shininessParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QNormalDiffuseMapMaterialPrivate::handleShininessChanged);
+ connect(m_textureScaleParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QNormalDiffuseMapMaterialPrivate::handleTextureScaleChanged);
+
+ m_normalDiffuseGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/normaldiffusemap.vert"))));
+ m_normalDiffuseGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/normaldiffusemap.frag"))));
+ m_normalDiffuseGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/normaldiffusemap.vert"))));
+ m_normalDiffuseGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/normaldiffusemap.frag"))));
+
+ m_normalDiffuseGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_normalDiffuseGL3Technique->graphicsApiFilter()->setMajorVersion(3);
+ m_normalDiffuseGL3Technique->graphicsApiFilter()->setMinorVersion(1);
+ m_normalDiffuseGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
+
+ m_normalDiffuseGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_normalDiffuseGL2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_normalDiffuseGL2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_normalDiffuseGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ m_normalDiffuseES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES);
+ m_normalDiffuseES2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_normalDiffuseES2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_normalDiffuseES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ Q_Q(QNormalDiffuseMapMaterial);
+ m_filterKey->setParent(q);
+ m_filterKey->setName(QStringLiteral("renderingStyle"));
+ m_filterKey->setValue(QStringLiteral("forward"));
+
+ m_normalDiffuseGL3Technique->addFilterKey(m_filterKey);
+ m_normalDiffuseGL2Technique->addFilterKey(m_filterKey);
+ m_normalDiffuseES2Technique->addFilterKey(m_filterKey);
+
+ m_normalDiffuseGL3RenderPass->setShaderProgram(m_normalDiffuseGL3Shader);
+ m_normalDiffuseGL2RenderPass->setShaderProgram(m_normalDiffuseGL2ES2Shader);
+ m_normalDiffuseES2RenderPass->setShaderProgram(m_normalDiffuseGL2ES2Shader);
+
+ m_normalDiffuseGL3Technique->addRenderPass(m_normalDiffuseGL3RenderPass);
+ m_normalDiffuseGL2Technique->addRenderPass(m_normalDiffuseGL2RenderPass);
+ m_normalDiffuseES2Technique->addRenderPass(m_normalDiffuseES2RenderPass);
+
+ m_normalDiffuseEffect->addTechnique(m_normalDiffuseGL3Technique);
+ m_normalDiffuseEffect->addTechnique(m_normalDiffuseGL2Technique);
+ m_normalDiffuseEffect->addTechnique(m_normalDiffuseES2Technique);
+
+ m_normalDiffuseEffect->addParameter(m_ambientParameter);
+ m_normalDiffuseEffect->addParameter(m_diffuseParameter);
+ m_normalDiffuseEffect->addParameter(m_normalParameter);
+ m_normalDiffuseEffect->addParameter(m_specularParameter);
+ m_normalDiffuseEffect->addParameter(m_shininessParameter);
+ m_normalDiffuseEffect->addParameter(m_textureScaleParameter);
+
+ q->setEffect(m_normalDiffuseEffect);
+}
+
+void QNormalDiffuseMapMaterialPrivate::handleAmbientChanged(const QVariant &var)
+{
+ Q_Q(QNormalDiffuseMapMaterial);
+ emit q->ambientChanged(var.value<QColor>());
+}
+
+void QNormalDiffuseMapMaterialPrivate::handleDiffuseChanged(const QVariant &var)
+{
+ Q_Q(QNormalDiffuseMapMaterial);
+ emit q->diffuseChanged(var.value<QAbstractTexture *>());
+}
+
+void QNormalDiffuseMapMaterialPrivate::handleNormalChanged(const QVariant &var)
+{
+ Q_Q(QNormalDiffuseMapMaterial);
+ emit q->normalChanged(var.value<QAbstractTexture *>());
+}
+
+void QNormalDiffuseMapMaterialPrivate::handleSpecularChanged(const QVariant &var)
+{
+ Q_Q(QNormalDiffuseMapMaterial);
+ emit q->specularChanged(var.value<QColor>());
+}
+
+void QNormalDiffuseMapMaterialPrivate::handleShininessChanged(const QVariant &var)
+{
+ Q_Q(QNormalDiffuseMapMaterial);
+ emit q->shininessChanged(var.toFloat());
+}
+
+void QNormalDiffuseMapMaterialPrivate::handleTextureScaleChanged(const QVariant &var)
+{
+ Q_Q(QNormalDiffuseMapMaterial);
+ emit q->textureScaleChanged(var.toFloat());
+}
+
+/*!
+ \class Qt3DRender::QNormalDiffuseMapMaterial
+ \brief The QNormalDiffuseMapMaterial provides a default implementation of the phong lighting and bump effect where the diffuse light component
+ is read from a texture map and the normals of the mesh being rendered from a normal texture map.
+ \inmodule Qt3DRender
+ \since 5.5
+
+ The specular lighting effect is based on the combination of 3 lighting components ambient, diffuse and specular.
+ The relative strengths of these components is controlled by means of their reflectivity coefficients which are modelled as RGB triplets:
+
+ \list
+ \li Ambient is the color that is emitted by an object without any other light source.
+ \li Diffuse is the color that is emitted for rought surface reflections with the lights.
+ \li Specular is the color emitted for shiny surface reflections with the lights.
+ \li The shininess of a surface is controlled by a float property.
+ \endlist
+
+ This material uses an effect with a single render pass approach and performs per fragment lighting.
+ Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2.
+*/
+
+/*!
+ Constructs a new Qt3DRender::QNormalDiffuseMapMaterial instance with parent object \a parent.
+*/
+QNormalDiffuseMapMaterial::QNormalDiffuseMapMaterial(QNode *parent)
+ : QMaterial(*new QNormalDiffuseMapMaterialPrivate, parent)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ d->init();
+}
+
+/*! \internal */
+QNormalDiffuseMapMaterial::QNormalDiffuseMapMaterial(QNormalDiffuseMapMaterialPrivate &dd, QNode *parent)
+ : QMaterial(dd, parent)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ d->init();
+}
+
+/*!
+ Destroys the QNormalDiffuseMapMaterial instance.
+*/
+QNormalDiffuseMapMaterial::~QNormalDiffuseMapMaterial()
+{
+}
+
+/*!
+ \property Qt3DRender::QNormalDiffuseMapMaterial::ambient
+
+ Holds the current ambient color.
+*/
+QColor QNormalDiffuseMapMaterial::ambient() const
+{
+ Q_D(const QNormalDiffuseMapMaterial);
+ return d->m_ambientParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QNormalDiffuseMapMaterial::specular
+
+ Holds the current specular color.
+*/
+QColor QNormalDiffuseMapMaterial::specular() const
+{
+ Q_D(const QNormalDiffuseMapMaterial);
+ return d->m_specularParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QNormalDiffuseMapMaterial::diffuse
+
+ Holds the current diffuse map texture.
+
+ By default, the diffuse texture has these properties:
+
+ \list
+ \li Linear minification and magnification filters
+ \li Linear mipmap with mipmapping enabled
+ \li Repeat wrap modeM
+ \li Maximum anisotropy of 16.0
+ \endlist
+*/
+QAbstractTexture *QNormalDiffuseMapMaterial::diffuse() const
+{
+ Q_D(const QNormalDiffuseMapMaterial);
+ return d->m_diffuseParameter->value().value<QAbstractTexture *>();
+}
+
+/*!
+ \property Qt3DRender::QNormalDiffuseMapMaterial::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 *QNormalDiffuseMapMaterial::normal() const
+{
+ Q_D(const QNormalDiffuseMapMaterial);
+ return d->m_normalParameter->value().value<QAbstractTexture *>();
+}
+
+/*!
+ \property Qt3DRender::QNormalDiffuseMapMaterial::shininess
+
+ Holds the current shininess as a float value.
+*/
+float QNormalDiffuseMapMaterial::shininess() const
+{
+ Q_D(const QNormalDiffuseMapMaterial);
+ return d->m_shininessParameter->value().toFloat();
+}
+
+/*!
+ \property Qt3DRender::QNormalDiffuseMapMaterial::textureScale
+
+ Holds the current texture scale as a float value.
+*/
+float QNormalDiffuseMapMaterial::textureScale() const
+{
+ Q_D(const QNormalDiffuseMapMaterial);
+ return d->m_textureScaleParameter->value().toFloat();
+}
+
+void QNormalDiffuseMapMaterial::setAmbient(const QColor &ambient)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ d->m_ambientParameter->setValue(ambient);
+}
+
+void QNormalDiffuseMapMaterial::setSpecular(const QColor &specular)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ d->m_specularParameter->setValue(specular);
+}
+
+void QNormalDiffuseMapMaterial::setDiffuse(QAbstractTexture *diffuse)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ d->m_diffuseParameter->setValue(QVariant::fromValue(diffuse));
+}
+
+void QNormalDiffuseMapMaterial::setNormal(QAbstractTexture *normal)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ d->m_normalParameter->setValue(QVariant::fromValue(normal));
+}
+
+void QNormalDiffuseMapMaterial::setShininess(float shininess)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ d->m_shininessParameter->setValue(shininess);
+}
+
+void QNormalDiffuseMapMaterial::setTextureScale(float textureScale)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ d->m_textureScaleParameter->setValue(textureScale);
+}
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/extras/defaults/qnormaldiffusemapmaterial.h b/src/extras/defaults/qnormaldiffusemapmaterial.h
new file mode 100644
index 000000000..7152d64d5
--- /dev/null
+++ b/src/extras/defaults/qnormaldiffusemapmaterial.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QNORMALDIFFUSEMAPMATERIAL_H
+#define QT3DEXTRAS_QNORMALDIFFUSEMAPMATERIAL_H
+
+#include <Qt3DExtras/qt3dextras_global.h>
+#include <Qt3DRender/qmaterial.h>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QAbstractTexture;
+
+} // namespace Qt3DRender
+
+namespace Qt3DExtras {
+
+class QNormalDiffuseMapMaterialPrivate;
+
+class QT3DEXTRASSHARED_EXPORT QNormalDiffuseMapMaterial : public Qt3DRender::QMaterial
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged)
+ Q_PROPERTY(QColor specular READ specular WRITE setSpecular NOTIFY specularChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTexture *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTexture *normal READ normal WRITE setNormal NOTIFY normalChanged)
+ Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged)
+ Q_PROPERTY(float textureScale READ textureScale WRITE setTextureScale NOTIFY textureScaleChanged)
+
+public:
+ explicit QNormalDiffuseMapMaterial(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QNormalDiffuseMapMaterial();
+
+ QColor ambient() const;
+ QColor specular() const;
+ Qt3DRender::QAbstractTexture *diffuse() const;
+ Qt3DRender::QAbstractTexture *normal() const;
+ float shininess() const;
+ float textureScale() const;
+
+public Q_SLOTS:
+ void setAmbient(const QColor &ambient);
+ void setSpecular(const QColor &specular);
+ void setDiffuse(Qt3DRender::QAbstractTexture *diffuse);
+ void setNormal(Qt3DRender::QAbstractTexture *normal);
+ void setShininess(float shininess);
+ void setTextureScale(float textureScale);
+
+Q_SIGNALS:
+ void ambientChanged(const QColor &ambient);
+ void diffuseChanged(Qt3DRender::QAbstractTexture *diffuse);
+ void normalChanged(Qt3DRender::QAbstractTexture *normal);
+ void specularChanged(const QColor &specular);
+ void shininessChanged(float shininess);
+ void textureScaleChanged(float textureScale);
+
+protected:
+ QNormalDiffuseMapMaterial(QNormalDiffuseMapMaterialPrivate &dd, Qt3DCore::QNode *parent = Q_NULLPTR);
+
+private:
+ Q_DECLARE_PRIVATE(QNormalDiffuseMapMaterial)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QNORMALDIFFUSEMAPMATERIAL_H
diff --git a/src/extras/defaults/qnormaldiffusemapmaterial_p.h b/src/extras/defaults/qnormaldiffusemapmaterial_p.h
new file mode 100644
index 000000000..8dff59218
--- /dev/null
+++ b/src/extras/defaults/qnormaldiffusemapmaterial_p.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QNORMALDIFFUSEMAPMATERIAL_P_H
+#define QT3DEXTRAS_QNORMALDIFFUSEMAPMATERIAL_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 QNormalDiffuseMapMaterial;
+
+class QNormalDiffuseMapMaterialPrivate: public Qt3DRender::QMaterialPrivate
+{
+public:
+ QNormalDiffuseMapMaterialPrivate();
+
+ virtual void init();
+
+ void handleAmbientChanged(const QVariant &var);
+ void handleDiffuseChanged(const QVariant &var);
+ void handleNormalChanged(const QVariant &var);
+ void handleSpecularChanged(const QVariant &var);
+ void handleShininessChanged(const QVariant &var);
+ void handleTextureScaleChanged(const QVariant &var);
+
+ Qt3DRender::QEffect *m_normalDiffuseEffect;
+ Qt3DRender::QAbstractTexture *m_diffuseTexture;
+ Qt3DRender::QAbstractTexture *m_normalTexture;
+ Qt3DRender::QParameter *m_ambientParameter;
+ Qt3DRender::QParameter *m_diffuseParameter;
+ Qt3DRender::QParameter *m_normalParameter;
+ Qt3DRender::QParameter *m_specularParameter;
+ Qt3DRender::QParameter *m_shininessParameter;
+ Qt3DRender::QParameter *m_textureScaleParameter;
+ Qt3DRender::QTechnique *m_normalDiffuseGL3Technique;
+ Qt3DRender::QTechnique *m_normalDiffuseGL2Technique;
+ Qt3DRender::QTechnique *m_normalDiffuseES2Technique;
+ Qt3DRender::QRenderPass *m_normalDiffuseGL3RenderPass;
+ Qt3DRender::QRenderPass *m_normalDiffuseGL2RenderPass;
+ Qt3DRender::QRenderPass *m_normalDiffuseES2RenderPass;
+ Qt3DRender::QShaderProgram *m_normalDiffuseGL3Shader;
+ Qt3DRender::QShaderProgram *m_normalDiffuseGL2ES2Shader;
+ Qt3DRender::QFilterKey *m_filterKey;
+
+ Q_DECLARE_PUBLIC(QNormalDiffuseMapMaterial)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QNORMALDIFFUSEMAPMATERIAL_P_H
+
diff --git a/src/extras/defaults/qnormaldiffusespecularmapmaterial.cpp b/src/extras/defaults/qnormaldiffusespecularmapmaterial.cpp
new file mode 100644
index 000000000..6d54b9535
--- /dev/null
+++ b/src/extras/defaults/qnormaldiffusespecularmapmaterial.cpp
@@ -0,0 +1,379 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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 "qnormaldiffusespecularmapmaterial.h"
+#include "qnormaldiffusespecularmapmaterial_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 {
+
+QNormalDiffuseSpecularMapMaterialPrivate::QNormalDiffuseSpecularMapMaterialPrivate()
+ : QMaterialPrivate()
+ , m_normalDiffuseSpecularEffect(new QEffect())
+ , m_diffuseTexture(new QTexture2D())
+ , m_normalTexture(new QTexture2D())
+ , m_specularTexture(new QTexture2D())
+ , m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f)))
+ , m_diffuseParameter(new QParameter(QStringLiteral("diffuseTexture"), m_diffuseTexture))
+ , m_normalParameter(new QParameter(QStringLiteral("normalTexture"), m_normalTexture))
+ , m_specularParameter(new QParameter(QStringLiteral("specularTexture"), m_specularTexture))
+ , m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f))
+ , m_textureScaleParameter(new QParameter(QStringLiteral("texCoordScale"), 1.0f))
+ , m_normalDiffuseSpecularGL3Technique(new QTechnique())
+ , m_normalDiffuseSpecularGL2Technique(new QTechnique())
+ , m_normalDiffuseSpecularES2Technique(new QTechnique())
+ , m_normalDiffuseSpecularGL3RenderPass(new QRenderPass())
+ , m_normalDiffuseSpecularGL2RenderPass(new QRenderPass())
+ , m_normalDiffuseSpecularES2RenderPass(new QRenderPass())
+ , m_normalDiffuseSpecularGL3Shader(new QShaderProgram())
+ , m_normalDiffuseSpecularGL2ES2Shader(new QShaderProgram())
+ , m_filterKey(new QFilterKey)
+{
+ m_diffuseTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_diffuseTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_diffuseTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_diffuseTexture->setGenerateMipMaps(true);
+ m_diffuseTexture->setMaximumAnisotropy(16.0f);
+
+ m_normalTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_normalTexture->setMinificationFilter(QAbstractTexture::Linear);
+ m_normalTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_normalTexture->setMaximumAnisotropy(16.0f);
+
+ m_specularTexture->setMagnificationFilter(QAbstractTexture::Linear);
+ m_specularTexture->setMinificationFilter(QAbstractTexture::LinearMipMapLinear);
+ m_specularTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_specularTexture->setGenerateMipMaps(true);
+ m_specularTexture->setMaximumAnisotropy(16.0f);
+}
+
+void QNormalDiffuseSpecularMapMaterialPrivate::init()
+{
+ connect(m_ambientParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QNormalDiffuseSpecularMapMaterialPrivate::handleAmbientChanged);
+ connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QNormalDiffuseSpecularMapMaterialPrivate::handleDiffuseChanged);
+ connect(m_normalParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QNormalDiffuseSpecularMapMaterialPrivate::handleNormalChanged);
+ connect(m_specularParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QNormalDiffuseSpecularMapMaterialPrivate::handleSpecularChanged);
+ connect(m_shininessParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QNormalDiffuseSpecularMapMaterialPrivate::handleShininessChanged);
+ connect(m_textureScaleParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QNormalDiffuseSpecularMapMaterialPrivate::handleTextureScaleChanged);
+
+ m_normalDiffuseSpecularGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/normaldiffusemap.vert"))));
+ m_normalDiffuseSpecularGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/normaldiffusespecularmap.frag"))));
+ m_normalDiffuseSpecularGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/normaldiffusemap.vert"))));
+ m_normalDiffuseSpecularGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/normaldiffusespecularmap.frag"))));
+
+ m_normalDiffuseSpecularGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_normalDiffuseSpecularGL3Technique->graphicsApiFilter()->setMajorVersion(3);
+ m_normalDiffuseSpecularGL3Technique->graphicsApiFilter()->setMinorVersion(1);
+ m_normalDiffuseSpecularGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
+
+ m_normalDiffuseSpecularGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_normalDiffuseSpecularGL2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_normalDiffuseSpecularGL2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_normalDiffuseSpecularGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ m_normalDiffuseSpecularES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES);
+ m_normalDiffuseSpecularES2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_normalDiffuseSpecularES2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_normalDiffuseSpecularES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ Q_Q(QNormalDiffuseSpecularMapMaterial);
+ m_filterKey->setParent(q);
+ m_filterKey->setName(QStringLiteral("renderingStyle"));
+ m_filterKey->setValue(QStringLiteral("forward"));
+
+ m_normalDiffuseSpecularGL3Technique->addFilterKey(m_filterKey);
+ m_normalDiffuseSpecularGL2Technique->addFilterKey(m_filterKey);
+ m_normalDiffuseSpecularES2Technique->addFilterKey(m_filterKey);
+
+ m_normalDiffuseSpecularGL3RenderPass->setShaderProgram(m_normalDiffuseSpecularGL3Shader);
+ m_normalDiffuseSpecularGL2RenderPass->setShaderProgram(m_normalDiffuseSpecularGL2ES2Shader);
+ m_normalDiffuseSpecularES2RenderPass->setShaderProgram(m_normalDiffuseSpecularGL2ES2Shader);
+
+ m_normalDiffuseSpecularGL3Technique->addRenderPass(m_normalDiffuseSpecularGL3RenderPass);
+ m_normalDiffuseSpecularGL2Technique->addRenderPass(m_normalDiffuseSpecularGL2RenderPass);
+ m_normalDiffuseSpecularES2Technique->addRenderPass(m_normalDiffuseSpecularES2RenderPass);
+
+ m_normalDiffuseSpecularEffect->addTechnique(m_normalDiffuseSpecularGL3Technique);
+ m_normalDiffuseSpecularEffect->addTechnique(m_normalDiffuseSpecularGL2Technique);
+ m_normalDiffuseSpecularEffect->addTechnique(m_normalDiffuseSpecularES2Technique);
+
+ m_normalDiffuseSpecularEffect->addParameter(m_ambientParameter);
+ m_normalDiffuseSpecularEffect->addParameter(m_diffuseParameter);
+ m_normalDiffuseSpecularEffect->addParameter(m_normalParameter);
+ m_normalDiffuseSpecularEffect->addParameter(m_specularParameter);
+ m_normalDiffuseSpecularEffect->addParameter(m_shininessParameter);
+ m_normalDiffuseSpecularEffect->addParameter(m_textureScaleParameter);
+
+ q->setEffect(m_normalDiffuseSpecularEffect);
+}
+
+void QNormalDiffuseSpecularMapMaterialPrivate::handleAmbientChanged(const QVariant &var)
+{
+ Q_Q(QNormalDiffuseSpecularMapMaterial);
+ emit q->ambientChanged(var.value<QColor>());
+}
+
+void QNormalDiffuseSpecularMapMaterialPrivate::handleDiffuseChanged(const QVariant &var)
+{
+ Q_Q(QNormalDiffuseSpecularMapMaterial);
+ emit q->diffuseChanged(var.value<QAbstractTexture *>());
+}
+
+void QNormalDiffuseSpecularMapMaterialPrivate::handleNormalChanged(const QVariant &var)
+{
+ Q_Q(QNormalDiffuseSpecularMapMaterial);
+ emit q->normalChanged(var.value<QAbstractTexture *>());
+}
+
+void QNormalDiffuseSpecularMapMaterialPrivate::handleSpecularChanged(const QVariant &var)
+{
+ Q_Q(QNormalDiffuseSpecularMapMaterial);
+ emit q->specularChanged(var.value<QAbstractTexture *>());
+}
+
+void QNormalDiffuseSpecularMapMaterialPrivate::handleShininessChanged(const QVariant &var)
+{
+ Q_Q(QNormalDiffuseSpecularMapMaterial);
+ emit q->shininessChanged(var.toFloat());
+}
+
+void QNormalDiffuseSpecularMapMaterialPrivate::handleTextureScaleChanged(const QVariant &var)
+{
+ Q_Q(QNormalDiffuseSpecularMapMaterial);
+ emit q->textureScaleChanged(var.toFloat());
+}
+
+/*!
+ \class Qt3DRender::QNormalDiffuseSpecularMapMaterial
+ \brief The QNormalDiffuseSpecularMapMaterial provides a default implementation of the phong lighting and bump effect where the diffuse and specular light components
+ are read from texture maps and the normals of the mesh being rendered from a normal texture map.
+ \inmodule Qt3DRender
+ \since 5.5
+
+ The specular lighting effect is based on the combination of 3 lighting components ambient, diffuse and specular.
+ The relative strengths of these components is controlled by means of their reflectivity coefficients which are modelled as RGB triplets:
+
+ \list
+ \li Ambient is the color that is emitted by an object without any other light source.
+ \li Diffuse is the color that is emitted for rought surface reflections with the lights.
+ \li Specular is the color emitted for shiny surface reflections with the lights.
+ \li The shininess of a surface is controlled by a float property.
+ \endlist
+
+ This material uses an effect with a single render pass approach and performs per fragment lighting.
+ Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2.
+*/
+
+/*!
+ Constructs a new Qt3DRender::QNormalDiffuseSpecularMapMaterial instance with parent object \a parent.
+*/
+QNormalDiffuseSpecularMapMaterial::QNormalDiffuseSpecularMapMaterial(QNode *parent)
+ : QMaterial(*new QNormalDiffuseSpecularMapMaterialPrivate, parent)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ d->init();
+}
+
+/*! \internal */
+QNormalDiffuseSpecularMapMaterial::QNormalDiffuseSpecularMapMaterial(QNormalDiffuseSpecularMapMaterialPrivate &dd, QNode *parent)
+ : QMaterial(dd, parent)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ d->init();
+}
+
+/*!
+ Destroys the Qt3DRender::QNormalDiffuseSpecularMapMaterial instance.
+*/
+QNormalDiffuseSpecularMapMaterial::~QNormalDiffuseSpecularMapMaterial()
+{
+}
+
+/*!
+ \property Qt3DRender::QNormalDiffuseSpecularMapMaterial::ambient
+
+ Holds the current ambient color.
+*/
+QColor QNormalDiffuseSpecularMapMaterial::ambient() const
+{
+ Q_D(const QNormalDiffuseSpecularMapMaterial);
+ return d->m_ambientParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QNormalDiffuseSpecularMapMaterial::diffuse
+
+ Holds the current diffuse map texture.
+
+ By default, the diffuse 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 *QNormalDiffuseSpecularMapMaterial::diffuse() const
+{
+ Q_D(const QNormalDiffuseSpecularMapMaterial);
+ return d->m_diffuseParameter->value().value<QAbstractTexture *>();
+}
+
+/*!
+ \property Qt3DRender::QNormalDiffuseSpecularMapMaterial::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 *QNormalDiffuseSpecularMapMaterial::normal() const
+{
+ Q_D(const QNormalDiffuseSpecularMapMaterial);
+ return d->m_normalParameter->value().value<QAbstractTexture *>();
+}
+
+/*!
+ \property Qt3DRender::QNormalDiffuseSpecularMapMaterial::specular
+
+ Holds the current specular map texture.
+
+ By default, the specular 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 *QNormalDiffuseSpecularMapMaterial::specular() const
+{
+ Q_D(const QNormalDiffuseSpecularMapMaterial);
+ return d->m_specularParameter->value().value<QAbstractTexture *>();
+}
+
+/*!
+ \property Qt3DRender::QNormalDiffuseSpecularMapMaterial::shininess
+
+ Holds the current shininess as a float value.
+*/
+float QNormalDiffuseSpecularMapMaterial::shininess() const
+{
+ Q_D(const QNormalDiffuseSpecularMapMaterial);
+ return d->m_shininessParameter->value().toFloat();
+}
+
+/*!
+ \property Qt3DRender::QNormalDiffuseSpecularMapMaterial::textureScale
+
+ Holds the current texture scale as a float value.
+*/
+float QNormalDiffuseSpecularMapMaterial::textureScale() const
+{
+ Q_D(const QNormalDiffuseSpecularMapMaterial);
+ return d->m_textureScaleParameter->value().toFloat();
+}
+
+void QNormalDiffuseSpecularMapMaterial::setAmbient(const QColor &ambient)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ d->m_ambientParameter->setValue(ambient);
+}
+
+void QNormalDiffuseSpecularMapMaterial::setDiffuse(QAbstractTexture *diffuse)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ d->m_diffuseParameter->setValue(QVariant::fromValue(diffuse));
+}
+
+void QNormalDiffuseSpecularMapMaterial::setNormal(QAbstractTexture *normal)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ d->m_normalParameter->setValue(QVariant::fromValue(normal));
+}
+
+void QNormalDiffuseSpecularMapMaterial::setSpecular(QAbstractTexture *specular)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ d->m_specularParameter->setValue(QVariant::fromValue(specular));
+}
+
+void QNormalDiffuseSpecularMapMaterial::setShininess(float shininess)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ d->m_shininessParameter->setValue(shininess);
+}
+
+void QNormalDiffuseSpecularMapMaterial::setTextureScale(float textureScale)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ d->m_textureScaleParameter->setValue(textureScale);
+}
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
diff --git a/src/extras/defaults/qnormaldiffusespecularmapmaterial.h b/src/extras/defaults/qnormaldiffusespecularmapmaterial.h
new file mode 100644
index 000000000..a2f32d2ae
--- /dev/null
+++ b/src/extras/defaults/qnormaldiffusespecularmapmaterial.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QNORMALDIFFUSESPECULARMAPMATERIAL_H
+#define QT3DEXTRAS_QNORMALDIFFUSESPECULARMAPMATERIAL_H
+
+#include <Qt3DExtras/qt3dextras_global.h>
+#include <Qt3DRender/qmaterial.h>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DExtras {
+
+class QNormalDiffuseSpecularMapMaterialPrivate;
+
+class QT3DEXTRASSHARED_EXPORT QNormalDiffuseSpecularMapMaterial : public Qt3DRender::QMaterial
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTexture *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTexture *normal READ normal WRITE setNormal NOTIFY normalChanged)
+ Q_PROPERTY(Qt3DRender::QAbstractTexture *specular READ specular WRITE setSpecular NOTIFY specularChanged)
+ Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged)
+ Q_PROPERTY(float textureScale READ textureScale WRITE setTextureScale NOTIFY textureScaleChanged)
+
+public:
+ explicit QNormalDiffuseSpecularMapMaterial(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QNormalDiffuseSpecularMapMaterial();
+
+ QColor ambient() const;
+ Qt3DRender::QAbstractTexture *diffuse() const;
+ Qt3DRender::QAbstractTexture *normal() const;
+ Qt3DRender::QAbstractTexture *specular() const;
+ float shininess() const;
+ float textureScale() const;
+
+public Q_SLOTS:
+ void setAmbient(const QColor &ambient);
+ void setDiffuse(Qt3DRender::QAbstractTexture *diffuse);
+ void setNormal(Qt3DRender::QAbstractTexture *normal);
+ void setSpecular(Qt3DRender::QAbstractTexture *specular);
+ void setShininess(float shininess);
+ void setTextureScale(float textureScale);
+
+Q_SIGNALS:
+ void ambientChanged(const QColor &ambient);
+ void diffuseChanged(Qt3DRender::QAbstractTexture *diffuse);
+ void normalChanged(Qt3DRender::QAbstractTexture *normal);
+ void specularChanged(Qt3DRender::QAbstractTexture *specular);
+ void shininessChanged(float shininess);
+ void textureScaleChanged(float textureScale);
+
+protected:
+ QNormalDiffuseSpecularMapMaterial(QNormalDiffuseSpecularMapMaterialPrivate &dd, Qt3DCore::QNode *parent = Q_NULLPTR);
+
+private:
+ Q_DECLARE_PRIVATE(QNormalDiffuseSpecularMapMaterial)
+};
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QNORMALDIFFUSESPECULARMAPMATERIAL_H
diff --git a/src/extras/defaults/qnormaldiffusespecularmapmaterial_p.h b/src/extras/defaults/qnormaldiffusespecularmapmaterial_p.h
new file mode 100644
index 000000000..3316044ff
--- /dev/null
+++ b/src/extras/defaults/qnormaldiffusespecularmapmaterial_p.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QNORMALDIFFUSESPECULARMAPMATERIAL_P_H
+#define QT3DEXTRAS_QNORMALDIFFUSESPECULARMAPMATERIAL_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 QNormalDiffuseSpecularMapMaterial;
+
+class QNormalDiffuseSpecularMapMaterialPrivate : public Qt3DRender::QMaterialPrivate
+{
+public:
+ QNormalDiffuseSpecularMapMaterialPrivate();
+
+ void init();
+
+ void handleAmbientChanged(const QVariant &var);
+ void handleDiffuseChanged(const QVariant &var);
+ void handleNormalChanged(const QVariant &var);
+ void handleSpecularChanged(const QVariant &var);
+ void handleShininessChanged(const QVariant &var);
+ void handleTextureScaleChanged(const QVariant &var);
+
+ Qt3DRender::QEffect *m_normalDiffuseSpecularEffect;
+ Qt3DRender::QAbstractTexture *m_diffuseTexture;
+ Qt3DRender::QAbstractTexture *m_normalTexture;
+ Qt3DRender::QAbstractTexture *m_specularTexture;
+ Qt3DRender::QParameter *m_ambientParameter;
+ Qt3DRender::QParameter *m_diffuseParameter;
+ Qt3DRender::QParameter *m_normalParameter;
+ Qt3DRender::QParameter *m_specularParameter;
+ Qt3DRender::QParameter *m_shininessParameter;
+ Qt3DRender::QParameter *m_textureScaleParameter;
+ Qt3DRender::QTechnique *m_normalDiffuseSpecularGL3Technique;
+ Qt3DRender::QTechnique *m_normalDiffuseSpecularGL2Technique;
+ Qt3DRender::QTechnique *m_normalDiffuseSpecularES2Technique;
+ Qt3DRender::QRenderPass *m_normalDiffuseSpecularGL3RenderPass;
+ Qt3DRender::QRenderPass *m_normalDiffuseSpecularGL2RenderPass;
+ Qt3DRender::QRenderPass *m_normalDiffuseSpecularES2RenderPass;
+ Qt3DRender::QShaderProgram *m_normalDiffuseSpecularGL3Shader;
+ Qt3DRender::QShaderProgram *m_normalDiffuseSpecularGL2ES2Shader;
+ Qt3DRender::QFilterKey *m_filterKey;
+
+ Q_DECLARE_PUBLIC(QNormalDiffuseSpecularMapMaterial)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QNORMALDIFFUSESPECULARMAPMATERIAL_P_H
+
diff --git a/src/extras/defaults/qpervertexcolormaterial.cpp b/src/extras/defaults/qpervertexcolormaterial.cpp
new file mode 100644
index 000000000..2a301cd3f
--- /dev/null
+++ b/src/extras/defaults/qpervertexcolormaterial.cpp
@@ -0,0 +1,163 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Lorenz Esch (TU Ilmenau).
+** 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 "qpervertexcolormaterial.h"
+#include "qpervertexcolormaterial_p.h"
+#include <Qt3DRender/qfilterkey.h>
+#include <Qt3DRender/qmaterial.h>
+#include <Qt3DRender/qeffect.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 {
+
+QPerVertexColorMaterialPrivate::QPerVertexColorMaterialPrivate()
+ : QMaterialPrivate()
+ , m_vertexEffect(new QEffect())
+ , m_vertexGL3Technique(new QTechnique())
+ , m_vertexGL2Technique(new QTechnique())
+ , m_vertexES2Technique(new QTechnique())
+ , m_vertexGL3RenderPass(new QRenderPass())
+ , m_vertexGL2RenderPass(new QRenderPass())
+ , m_vertexES2RenderPass(new QRenderPass())
+ , m_vertexGL3Shader(new QShaderProgram())
+ , m_vertexGL2ES2Shader(new QShaderProgram())
+ , m_filterKey(new QFilterKey)
+{
+}
+
+/*!
+ \class Qt3DRender::QPerVertexColorMaterial
+ \brief The QPerVertexColorMaterial class provides a default implementation for rendering the color properties set for each vertex.
+ \inmodule Qt3DRender
+ \since 5.5
+
+ This lighting effect is based on the combination of 2 lighting components ambient and diffuse. Ambient is set by the vertex color.
+ Diffuse takes in account the normal distribution of each vertex.
+
+ \list
+ \li Ambient is the color that is emitted by an object without any other light source.
+ \li Diffuse is the color that is emitted for rough surface reflections with the lights
+ \endlist
+
+ This material uses an effect with a single render pass approach and forms fragment lighting.
+ Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2.
+*/
+
+/*!
+ \fn Qt3DRender::QPerVertexColorMaterial::QPerVertexColorMaterial(Qt3DCore::QNode *parent)
+
+ Constructs a new QPerVertexColorMaterial instance with parent object \a parent.
+*/
+QPerVertexColorMaterial::QPerVertexColorMaterial(QNode *parent)
+ : QMaterial(*new QPerVertexColorMaterialPrivate, parent)
+{
+ Q_D(QPerVertexColorMaterial);
+ d->init();
+}
+
+/*!
+ \fn Qt3DRender::QPerVertexColorMaterial::~QPerVertexColorMaterial()
+
+ Destroys the QPerVertexColorMaterial
+*/
+QPerVertexColorMaterial::~QPerVertexColorMaterial()
+{
+}
+
+// TODO: Define how lights are proties are set in the shaders. Ideally using a QShaderData
+void QPerVertexColorMaterialPrivate::init()
+{
+ m_vertexGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/pervertexcolor.vert"))));
+ m_vertexGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/pervertexcolor.frag"))));
+ m_vertexGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/pervertexcolor.vert"))));
+ m_vertexGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/pervertexcolor.frag"))));
+
+ m_vertexGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_vertexGL3Technique->graphicsApiFilter()->setMajorVersion(3);
+ m_vertexGL3Technique->graphicsApiFilter()->setMinorVersion(1);
+ m_vertexGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
+
+ m_vertexGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_vertexGL2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_vertexGL2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_vertexGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ m_vertexES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES);
+ m_vertexES2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_vertexES2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_vertexES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ Q_Q(QPerVertexColorMaterial);
+ m_filterKey->setParent(q);
+ m_filterKey->setName(QStringLiteral("renderingStyle"));
+ m_filterKey->setValue(QStringLiteral("forward"));
+
+ m_vertexGL3Technique->addFilterKey(m_filterKey);
+ m_vertexGL2Technique->addFilterKey(m_filterKey);
+ m_vertexES2Technique->addFilterKey(m_filterKey);
+
+ m_vertexGL3RenderPass->setShaderProgram(m_vertexGL3Shader);
+ m_vertexGL2RenderPass->setShaderProgram(m_vertexGL2ES2Shader);
+ m_vertexES2RenderPass->setShaderProgram(m_vertexGL2ES2Shader);
+
+ m_vertexGL3Technique->addRenderPass(m_vertexGL3RenderPass);
+ m_vertexGL2Technique->addRenderPass(m_vertexGL2RenderPass);
+ m_vertexES2Technique->addRenderPass(m_vertexES2RenderPass);
+
+ m_vertexEffect->addTechnique(m_vertexGL3Technique);
+ m_vertexEffect->addTechnique(m_vertexGL2Technique);
+ m_vertexEffect->addTechnique(m_vertexES2Technique);
+
+ q->setEffect(m_vertexEffect);
+}
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
diff --git a/src/extras/defaults/qpervertexcolormaterial.h b/src/extras/defaults/qpervertexcolormaterial.h
new file mode 100644
index 000000000..86d169715
--- /dev/null
+++ b/src/extras/defaults/qpervertexcolormaterial.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Lorenz Esch (TU Ilmenau).
+** 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_QPERVERTEXCOLORMATERIAL_H
+#define QT3DEXTRAS_QPERVERTEXCOLORMATERIAL_H
+
+#include <Qt3DExtras/qt3dextras_global.h>
+#include <Qt3DRender/qmaterial.h>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DExtras {
+
+class QPerVertexColorMaterialPrivate;
+
+class QT3DEXTRASSHARED_EXPORT QPerVertexColorMaterial : public Qt3DRender::QMaterial
+{
+ Q_OBJECT
+
+public:
+ explicit QPerVertexColorMaterial(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QPerVertexColorMaterial();
+
+private:
+ Q_DECLARE_PRIVATE(QPerVertexColorMaterial)
+};
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QPERVERTEXCOLORMATERIAL_H
diff --git a/src/extras/defaults/qpervertexcolormaterial_p.h b/src/extras/defaults/qpervertexcolormaterial_p.h
new file mode 100644
index 000000000..678353525
--- /dev/null
+++ b/src/extras/defaults/qpervertexcolormaterial_p.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Lorenz Esch (TU Ilmenau).
+** 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_QPERVERTEXCOLORMATERIAL_P_H
+#define QT3DEXTRAS_QPERVERTEXCOLORMATERIAL_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 QTechnique;
+class QParameter;
+class QShaderProgram;
+class QRenderPass;
+
+} // namespace Qt3DRender
+
+namespace Qt3DExtras {
+
+class QPerVertexColorMaterial;
+
+class QPerVertexColorMaterialPrivate : public Qt3DRender::QMaterialPrivate
+{
+public:
+ QPerVertexColorMaterialPrivate();
+
+ void init();
+
+ Qt3DRender::QEffect *m_vertexEffect;
+ Qt3DRender::QTechnique *m_vertexGL3Technique;
+ Qt3DRender::QTechnique *m_vertexGL2Technique;
+ Qt3DRender::QTechnique *m_vertexES2Technique;
+ Qt3DRender::QRenderPass *m_vertexGL3RenderPass;
+ Qt3DRender::QRenderPass *m_vertexGL2RenderPass;
+ Qt3DRender::QRenderPass *m_vertexES2RenderPass;
+ Qt3DRender::QShaderProgram *m_vertexGL3Shader;
+ Qt3DRender::QShaderProgram *m_vertexGL2ES2Shader;
+ Qt3DRender::QFilterKey *m_filterKey;
+
+ Q_DECLARE_PUBLIC(QPerVertexColorMaterial)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QPERVERTEXCOLORMATERIAL_P_H
+
diff --git a/src/extras/defaults/qphongalphamaterial.cpp b/src/extras/defaults/qphongalphamaterial.cpp
new file mode 100644
index 000000000..9d80751c5
--- /dev/null
+++ b/src/extras/defaults/qphongalphamaterial.cpp
@@ -0,0 +1,327 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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 "qphongalphamaterial.h"
+#include "qphongalphamaterial_p.h"
+#include <Qt3DRender/qfilterkey.h>
+#include <Qt3DRender/qmaterial.h>
+#include <Qt3DRender/qeffect.h>
+#include <Qt3DRender/qtechnique.h>
+#include <Qt3DRender/qshaderprogram.h>
+#include <Qt3DRender/qparameter.h>
+#include <Qt3DRender/qrenderpass.h>
+#include <Qt3DRender/qgraphicsapifilter.h>
+#include <Qt3DRender/qblendequation.h>
+#include <Qt3DRender/qblendequationarguments.h>
+#include <Qt3DRender/qnodepthmask.h>
+#include <QUrl>
+#include <QVector3D>
+#include <QVector4D>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DRender;
+
+namespace Qt3DExtras {
+
+QPhongAlphaMaterialPrivate::QPhongAlphaMaterialPrivate()
+ : QMaterialPrivate()
+ , m_phongEffect(new QEffect())
+ , m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f)))
+ , m_diffuseParameter(new QParameter(QStringLiteral("kd"), QColor::fromRgbF(0.7f, 0.7f, 0.7f, 1.0f)))
+ , m_specularParameter(new QParameter(QStringLiteral("ks"), QColor::fromRgbF(0.01f, 0.01f, 0.01f, 1.0f)))
+ , m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f))
+ , m_alphaParameter(new QParameter(QStringLiteral("alpha"), 0.5f))
+ , m_phongAlphaGL3Technique(new QTechnique())
+ , m_phongAlphaGL2Technique(new QTechnique())
+ , m_phongAlphaES2Technique(new QTechnique())
+ , m_phongAlphaGL3RenderPass(new QRenderPass())
+ , m_phongAlphaGL2RenderPass(new QRenderPass())
+ , m_phongAlphaES2RenderPass(new QRenderPass())
+ , m_phongAlphaGL3Shader(new QShaderProgram())
+ , m_phongAlphaGL2ES2Shader(new QShaderProgram())
+ , m_noDepthMask(new QNoDepthMask())
+ , m_blendState(new QBlendEquationArguments())
+ , m_blendEquation(new QBlendEquation())
+ , m_filterKey(new QFilterKey)
+{
+}
+
+// TODO: Define how lights are properties are set in the shaders. Ideally using a QShaderData
+void QPhongAlphaMaterialPrivate::init()
+{
+ connect(m_ambientParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QPhongAlphaMaterialPrivate::handleAmbientChanged);
+ connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QPhongAlphaMaterialPrivate::handleDiffuseChanged);
+ connect(m_specularParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QPhongAlphaMaterialPrivate::handleSpecularChanged);
+ connect(m_shininessParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QPhongAlphaMaterialPrivate::handleShininessChanged);
+ connect(m_alphaParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QPhongAlphaMaterialPrivate::handleAlphaChanged);
+
+ m_phongAlphaGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/phong.vert"))));
+ m_phongAlphaGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/phongalpha.frag"))));
+ m_phongAlphaGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/phong.vert"))));
+ m_phongAlphaGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/phongalpha.frag"))));
+
+ m_phongAlphaGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_phongAlphaGL3Technique->graphicsApiFilter()->setMajorVersion(3);
+ m_phongAlphaGL3Technique->graphicsApiFilter()->setMinorVersion(1);
+ m_phongAlphaGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
+
+ m_phongAlphaGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_phongAlphaGL2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_phongAlphaGL2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_phongAlphaGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ m_phongAlphaES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES);
+ m_phongAlphaES2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_phongAlphaES2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_phongAlphaES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ Q_Q(QPhongAlphaMaterial);
+ m_filterKey->setParent(q);
+ m_filterKey->setName(QStringLiteral("renderingStyle"));
+ m_filterKey->setValue(QStringLiteral("forward"));
+
+ m_phongAlphaGL3Technique->addFilterKey(m_filterKey);
+ m_phongAlphaGL2Technique->addFilterKey(m_filterKey);
+ m_phongAlphaES2Technique->addFilterKey(m_filterKey);
+
+ m_blendState->setSourceRgb(QBlendEquationArguments::SourceAlpha);
+ m_blendState->setDestinationRgb(QBlendEquationArguments::OneMinusSourceAlpha);
+ m_blendEquation->setBlendFunction(QBlendEquation::Add);
+
+ m_phongAlphaGL3RenderPass->setShaderProgram(m_phongAlphaGL3Shader);
+ m_phongAlphaGL2RenderPass->setShaderProgram(m_phongAlphaGL2ES2Shader);
+ m_phongAlphaES2RenderPass->setShaderProgram(m_phongAlphaGL2ES2Shader);
+
+ m_phongAlphaGL3RenderPass->addRenderState(m_noDepthMask);
+ m_phongAlphaGL3RenderPass->addRenderState(m_blendState);
+ m_phongAlphaGL3RenderPass->addRenderState(m_blendEquation);
+
+ m_phongAlphaGL2RenderPass->addRenderState(m_noDepthMask);
+ m_phongAlphaGL2RenderPass->addRenderState(m_blendState);
+ m_phongAlphaGL2RenderPass->addRenderState(m_blendEquation);
+
+ m_phongAlphaES2RenderPass->addRenderState(m_noDepthMask);
+ m_phongAlphaES2RenderPass->addRenderState(m_blendState);
+ m_phongAlphaES2RenderPass->addRenderState(m_blendEquation);
+
+ m_phongAlphaGL3Technique->addRenderPass(m_phongAlphaGL3RenderPass);
+ m_phongAlphaGL2Technique->addRenderPass(m_phongAlphaGL2RenderPass);
+ m_phongAlphaES2Technique->addRenderPass(m_phongAlphaES2RenderPass);
+
+ m_phongEffect->addTechnique(m_phongAlphaGL3Technique);
+ m_phongEffect->addTechnique(m_phongAlphaGL2Technique);
+ m_phongEffect->addTechnique(m_phongAlphaES2Technique);
+
+ m_phongEffect->addParameter(m_ambientParameter);
+ m_phongEffect->addParameter(m_diffuseParameter);
+ m_phongEffect->addParameter(m_specularParameter);
+ m_phongEffect->addParameter(m_shininessParameter);
+ m_phongEffect->addParameter(m_alphaParameter);
+
+ q->setEffect(m_phongEffect);
+}
+
+void QPhongAlphaMaterialPrivate::handleAmbientChanged(const QVariant &var)
+{
+ Q_Q(QPhongAlphaMaterial);
+ emit q->ambientChanged(var.value<QColor>());
+}
+
+void QPhongAlphaMaterialPrivate::handleDiffuseChanged(const QVariant &var)
+{
+ Q_Q(QPhongAlphaMaterial);
+ emit q->diffuseChanged(var.value<QColor>());
+}
+
+void QPhongAlphaMaterialPrivate::handleSpecularChanged(const QVariant &var)
+{
+ Q_Q(QPhongAlphaMaterial);
+ emit q->specularChanged(var.value<QColor>());
+}
+
+void QPhongAlphaMaterialPrivate::handleShininessChanged(const QVariant &var)
+{
+ Q_Q(QPhongAlphaMaterial);
+ emit q->shininessChanged(var.toFloat());
+}
+
+void QPhongAlphaMaterialPrivate::handleAlphaChanged(const QVariant &var)
+{
+ Q_Q(QPhongAlphaMaterial);
+ emit q->alphaChanged(var.toFloat());
+}
+
+/*!
+ \class Qt3DRender::QPhongAlphaMaterial
+
+ \brief The QPhongAlphaMaterial class provides a default implementation of
+ the phong lighting effect with alpha.
+ \inmodule Qt3DRenderer
+ \since 5.5
+
+ The phong lighting effect is based on the combination of 3 lighting components ambient, diffuse and specular.
+ The relative strengths of these components is controlled by means of their reflectivity coefficients which are modelled as RGB triplets:
+
+ \list
+ \li Ambient is the color that is emitted by an object without any other light source.
+ \li Diffuse is the color that is emitted for rought surface reflections with the lights.
+ \li Specular is the color emitted for shiny surface reflections with the lights.
+ \li The shininess of a surface is controlled by a float property.
+ \li Alpha is the transparency of the surface between 0 (fully transparent) and 1 (opaque).
+ \endlist
+
+ This material uses an effect with a single render pass approach and performs per fragment lighting.
+ Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2.
+*/
+
+/*!
+ \fn Qt3DRender::QPhongAlphaMaterial::QPhongAlphaMaterial(Qt3DCore::QNode *parent)
+
+ Constructs a new QPhongAlphaMaterial instance with parent object \a parent.
+*/
+QPhongAlphaMaterial::QPhongAlphaMaterial(QNode *parent)
+ : QMaterial(*new QPhongAlphaMaterialPrivate, parent)
+{
+ Q_D(QPhongAlphaMaterial);
+ d->init();
+}
+
+/*!
+ Destroys the QPhongAlphaMaterial.
+*/
+QPhongAlphaMaterial::~QPhongAlphaMaterial()
+{
+}
+
+/*!
+ \property Qt3DRender::QPhongAlphaMaterial::ambient
+
+ Holds the ambient color.
+*/
+QColor QPhongAlphaMaterial::ambient() const
+{
+ Q_D(const QPhongAlphaMaterial);
+ return d->m_ambientParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QPhongAlphaMaterial::diffuse
+
+ Holds the diffuse color.
+*/
+QColor QPhongAlphaMaterial::diffuse() const
+{
+ Q_D(const QPhongAlphaMaterial);
+ return d->m_diffuseParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QPhongAlphaMaterial::specular
+
+ Holds the specular color.
+*/
+QColor QPhongAlphaMaterial::specular() const
+{
+ Q_D(const QPhongAlphaMaterial);
+ return d->m_specularParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QPhongAlphaMaterial::shininess
+
+ Holds the shininess exponent.
+*/
+float QPhongAlphaMaterial::shininess() const
+{
+ Q_D(const QPhongAlphaMaterial);
+ return d->m_shininessParameter->value().toFloat();
+}
+
+/*!
+ \property Qt3DRender::QPhongAlphaMaterial::alpha
+
+ Holds the alpha component of the object which varies between 0 and 1.
+
+ \note: default value is 0.5f
+*/
+float QPhongAlphaMaterial::alpha() const
+{
+ Q_D(const QPhongAlphaMaterial);
+ return d->m_alphaParameter->value().toFloat();
+}
+
+void QPhongAlphaMaterial::setAmbient(const QColor &ambient)
+{
+ Q_D(QPhongAlphaMaterial);
+ d->m_ambientParameter->setValue(ambient);
+}
+
+void QPhongAlphaMaterial::setDiffuse(const QColor &diffuse)
+{
+ Q_D(QPhongAlphaMaterial);
+ d->m_diffuseParameter->setValue(diffuse);
+}
+
+void QPhongAlphaMaterial::setSpecular(const QColor &specular)
+{
+ Q_D(QPhongAlphaMaterial);
+ d->m_specularParameter->setValue(specular);
+}
+
+void QPhongAlphaMaterial::setShininess(float shininess)
+{
+ Q_D(QPhongAlphaMaterial);
+ d->m_shininessParameter->setValue(shininess);
+}
+
+void QPhongAlphaMaterial::setAlpha(float alpha)
+{
+ Q_D(QPhongAlphaMaterial);
+ d->m_alphaParameter->setValue(alpha);
+}
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
diff --git a/src/extras/defaults/qphongalphamaterial.h b/src/extras/defaults/qphongalphamaterial.h
new file mode 100644
index 000000000..d4d46f756
--- /dev/null
+++ b/src/extras/defaults/qphongalphamaterial.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QPHONGALPHAMATERIAL_H
+#define QT3DEXTRAS_QPHONGALPHAMATERIAL_H
+
+#include <Qt3DExtras/qt3dextras_global.h>
+#include <Qt3DRender/qmaterial.h>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DExtras {
+
+class QPhongAlphaMaterialPrivate;
+
+class QT3DEXTRASSHARED_EXPORT QPhongAlphaMaterial : public Qt3DRender::QMaterial
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged)
+ Q_PROPERTY(QColor diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(QColor specular READ specular WRITE setSpecular NOTIFY specularChanged)
+ Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged)
+ Q_PROPERTY(float alpha READ alpha WRITE setAlpha NOTIFY alphaChanged)
+
+public:
+ explicit QPhongAlphaMaterial(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QPhongAlphaMaterial();
+
+ QColor ambient() const;
+ QColor diffuse() const;
+ QColor specular() const;
+ float shininess() const;
+ float alpha() const;
+
+public Q_SLOTS:
+ void setAmbient(const QColor &ambient);
+ void setDiffuse(const QColor &diffuse);
+ void setSpecular(const QColor &specular);
+ void setShininess(float shininess);
+ void setAlpha(float alpha);
+
+Q_SIGNALS:
+ void ambientChanged(const QColor &ambient);
+ void diffuseChanged(const QColor &diffuse);
+ void specularChanged(const QColor &specular);
+ void shininessChanged(float shininess);
+ void alphaChanged(float alpha);
+
+private:
+ Q_DECLARE_PRIVATE(QPhongAlphaMaterial)
+};
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QPHONGALPHAMATERIAL_H
diff --git a/src/extras/defaults/qphongalphamaterial_p.h b/src/extras/defaults/qphongalphamaterial_p.h
new file mode 100644
index 000000000..623eca0ea
--- /dev/null
+++ b/src/extras/defaults/qphongalphamaterial_p.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QPHONGALPHAMATERIAL_P_H
+#define QT3DEXTRAS_QPHONGALPHAMATERIAL_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 QTechnique;
+class QParameter;
+class QShaderProgram;
+class QRenderPass;
+class QNoDepthMask;
+class QBlendEquationArguments;
+class QBlendEquation;
+
+} // namespace Qt3DRender
+
+namespace Qt3DExtras {
+
+class QPhongAlphaMaterial;
+
+class QPhongAlphaMaterialPrivate : public Qt3DRender::QMaterialPrivate
+{
+public:
+ QPhongAlphaMaterialPrivate();
+
+ void init();
+
+ void handleAmbientChanged(const QVariant &var);
+ void handleDiffuseChanged(const QVariant &var);
+ void handleSpecularChanged(const QVariant &var);
+ void handleShininessChanged(const QVariant &var);
+ void handleAlphaChanged(const QVariant &var);
+
+ Qt3DRender::QEffect *m_phongEffect;
+ Qt3DRender::QParameter *m_ambientParameter;
+ Qt3DRender::QParameter *m_diffuseParameter;
+ Qt3DRender::QParameter *m_specularParameter;
+ Qt3DRender::QParameter *m_shininessParameter;
+ Qt3DRender::QParameter *m_alphaParameter;
+ Qt3DRender::QTechnique *m_phongAlphaGL3Technique;
+ Qt3DRender::QTechnique *m_phongAlphaGL2Technique;
+ Qt3DRender::QTechnique *m_phongAlphaES2Technique;
+ Qt3DRender::QRenderPass *m_phongAlphaGL3RenderPass;
+ Qt3DRender::QRenderPass *m_phongAlphaGL2RenderPass;
+ Qt3DRender::QRenderPass *m_phongAlphaES2RenderPass;
+ Qt3DRender::QShaderProgram *m_phongAlphaGL3Shader;
+ Qt3DRender::QShaderProgram *m_phongAlphaGL2ES2Shader;
+ Qt3DRender::QNoDepthMask *m_noDepthMask;
+ Qt3DRender::QBlendEquationArguments *m_blendState;
+ Qt3DRender::QBlendEquation *m_blendEquation;
+ Qt3DRender::QFilterKey *m_filterKey;
+
+ Q_DECLARE_PUBLIC(QPhongAlphaMaterial)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QPHONGALPHAMATERIAL_P_H
+
diff --git a/src/extras/defaults/qphongmaterial.cpp b/src/extras/defaults/qphongmaterial.cpp
new file mode 100644
index 000000000..f9c51bae8
--- /dev/null
+++ b/src/extras/defaults/qphongmaterial.cpp
@@ -0,0 +1,275 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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 "qphongmaterial.h"
+#include "qphongmaterial_p.h"
+#include <Qt3DRender/qfilterkey.h>
+#include <Qt3DRender/qmaterial.h>
+#include <Qt3DRender/qeffect.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 {
+
+QPhongMaterialPrivate::QPhongMaterialPrivate()
+ : QMaterialPrivate()
+ , m_phongEffect(new QEffect())
+ , m_ambientParameter(new QParameter(QStringLiteral("ka"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f)))
+ , m_diffuseParameter(new QParameter(QStringLiteral("kd"), QColor::fromRgbF(0.7f, 0.7f, 0.7f, 1.0f)))
+ , m_specularParameter(new QParameter(QStringLiteral("ks"), QColor::fromRgbF(0.01f, 0.01f, 0.01f, 1.0f)))
+ , m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f))
+ , m_phongGL3Technique(new QTechnique())
+ , m_phongGL2Technique(new QTechnique())
+ , m_phongES2Technique(new QTechnique())
+ , m_phongGL3RenderPass(new QRenderPass())
+ , m_phongGL2RenderPass(new QRenderPass())
+ , m_phongES2RenderPass(new QRenderPass())
+ , m_phongGL3Shader(new QShaderProgram())
+ , m_phongGL2ES2Shader(new QShaderProgram())
+ , m_filterKey(new QFilterKey)
+{
+}
+
+void QPhongMaterialPrivate::init()
+{
+ connect(m_ambientParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QPhongMaterialPrivate::handleAmbientChanged);
+ connect(m_diffuseParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QPhongMaterialPrivate::handleDiffuseChanged);
+ connect(m_specularParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QPhongMaterialPrivate::handleSpecularChanged);
+ connect(m_shininessParameter, &Qt3DRender::QParameter::valueChanged,
+ this, &QPhongMaterialPrivate::handleShininessChanged);
+
+
+ m_phongGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/phong.vert"))));
+ m_phongGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/phong.frag"))));
+ m_phongGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/phong.vert"))));
+ m_phongGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/phong.frag"))));
+
+ m_phongGL3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_phongGL3Technique->graphicsApiFilter()->setMajorVersion(3);
+ m_phongGL3Technique->graphicsApiFilter()->setMinorVersion(1);
+ m_phongGL3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
+
+ m_phongGL2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_phongGL2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_phongGL2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_phongGL2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ m_phongES2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES);
+ m_phongES2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_phongES2Technique->graphicsApiFilter()->setMinorVersion(0);
+ m_phongES2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ m_phongGL3RenderPass->setShaderProgram(m_phongGL3Shader);
+ m_phongGL2RenderPass->setShaderProgram(m_phongGL2ES2Shader);
+ m_phongES2RenderPass->setShaderProgram(m_phongGL2ES2Shader);
+
+ m_phongGL3Technique->addRenderPass(m_phongGL3RenderPass);
+ m_phongGL2Technique->addRenderPass(m_phongGL2RenderPass);
+ m_phongES2Technique->addRenderPass(m_phongES2RenderPass);
+
+ Q_Q(QPhongMaterial);
+ m_filterKey->setParent(q);
+ m_filterKey->setName(QStringLiteral("renderingStyle"));
+ m_filterKey->setValue(QStringLiteral("forward"));
+
+ m_phongGL3Technique->addFilterKey(m_filterKey);
+ m_phongGL2Technique->addFilterKey(m_filterKey);
+ m_phongES2Technique->addFilterKey(m_filterKey);
+
+ m_phongEffect->addTechnique(m_phongGL3Technique);
+ m_phongEffect->addTechnique(m_phongGL2Technique);
+ m_phongEffect->addTechnique(m_phongES2Technique);
+
+ m_phongEffect->addParameter(m_ambientParameter);
+ m_phongEffect->addParameter(m_diffuseParameter);
+ m_phongEffect->addParameter(m_specularParameter);
+ m_phongEffect->addParameter(m_shininessParameter);
+
+ q->setEffect(m_phongEffect);
+}
+
+void QPhongMaterialPrivate::handleAmbientChanged(const QVariant &var)
+{
+ Q_Q(QPhongMaterial);
+ emit q->ambientChanged(var.value<QColor>());
+}
+
+void QPhongMaterialPrivate::handleDiffuseChanged(const QVariant &var)
+{
+ Q_Q(QPhongMaterial);
+ emit q->diffuseChanged(var.value<QColor>());
+}
+
+void QPhongMaterialPrivate::handleSpecularChanged(const QVariant &var)
+{
+ Q_Q(QPhongMaterial);
+ emit q->specularChanged(var.value<QColor>());
+}
+
+void QPhongMaterialPrivate::handleShininessChanged(const QVariant &var)
+{
+ Q_Q(QPhongMaterial);
+ emit q->shininessChanged(var.toFloat());
+}
+
+/*!
+ \class Qt3DRender::QPhongMaterial
+ \brief The QPhongMaterial class provides a default implementation of the phong lighting effect.
+ \inmodule Qt3DRender
+ \since 5.5
+
+ The phong lighting effect is based on the combination of 3 lighting components ambient, diffuse and specular.
+ The relative strengths of these components is controlled by means of their reflectivity coefficients which are modelled as RGB triplets:
+
+ \list
+ \li Ambient is the color that is emitted by an object without any other light source.
+ \li Diffuse is the color that is emitted for rought surface reflections with the lights.
+ \li Specular is the color emitted for shiny surface reflections with the lights.
+ \li The shininess of a surface is controlled by a float property.
+ \endlist
+
+ This material uses an effect with a single render pass approach and performs per fragment lighting.
+ Techniques are provided for OpenGL 2, OpenGL 3 or above as well as OpenGL ES 2.
+*/
+
+/*!
+ \fn Qt3DRender::QPhongMaterial::QPhongMaterial(Qt3DCore::QNode *parent)
+
+ Constructs a new QPhongMaterial instance with parent object \a parent.
+*/
+QPhongMaterial::QPhongMaterial(QNode *parent)
+ : QMaterial(*new QPhongMaterialPrivate, parent)
+{
+ Q_D(QPhongMaterial);
+ d->init();
+}
+
+/*!
+ \fn Qt3DRender::QPhongMaterial::~QPhongMaterial()
+
+ Destroys the QPhongMaterial.
+*/
+QPhongMaterial::~QPhongMaterial()
+{
+}
+
+/*!
+ \property Qt3DRender::QPhongMaterial::ambient
+
+ Holds the ambient color.
+*/
+QColor QPhongMaterial::ambient() const
+{
+ Q_D(const QPhongMaterial);
+ return d->m_ambientParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QPhongMaterial::diffuse
+
+ Holds the diffuse color.
+*/
+QColor QPhongMaterial::diffuse() const
+{
+ Q_D(const QPhongMaterial);
+ return d->m_diffuseParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QPhongMaterial::specular
+
+ Holds the specular color.
+*/
+QColor QPhongMaterial::specular() const
+{
+ Q_D(const QPhongMaterial);
+ return d->m_specularParameter->value().value<QColor>();
+}
+
+/*!
+ \property Qt3DRender::QPhongMaterial::shininess
+
+ Holds the shininess exponent.
+*/
+float QPhongMaterial::shininess() const
+{
+ Q_D(const QPhongMaterial);
+ return d->m_shininessParameter->value().toFloat();
+}
+
+void QPhongMaterial::setAmbient(const QColor &ambient)
+{
+ Q_D(QPhongMaterial);
+ d->m_ambientParameter->setValue(ambient);
+}
+
+void QPhongMaterial::setDiffuse(const QColor &diffuse)
+{
+ Q_D(QPhongMaterial);
+ d->m_diffuseParameter->setValue(diffuse);
+}
+
+void QPhongMaterial::setSpecular(const QColor &specular)
+{
+ Q_D(QPhongMaterial);
+ d->m_specularParameter->setValue(specular);
+}
+
+void QPhongMaterial::setShininess(float shininess)
+{
+ Q_D(QPhongMaterial);
+ d->m_shininessParameter->setValue(shininess);
+}
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
diff --git a/src/extras/defaults/qphongmaterial.h b/src/extras/defaults/qphongmaterial.h
new file mode 100644
index 000000000..112482dee
--- /dev/null
+++ b/src/extras/defaults/qphongmaterial.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QPHONGMATERIAL_H
+#define QT3DEXTRAS_QPHONGMATERIAL_H
+
+#include <Qt3DExtras/qt3dextras_global.h>
+#include <Qt3DRender/qmaterial.h>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DExtras {
+
+class QPhongMaterialPrivate;
+
+class QT3DEXTRASSHARED_EXPORT QPhongMaterial : public Qt3DRender::QMaterial
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged)
+ Q_PROPERTY(QColor diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(QColor specular READ specular WRITE setSpecular NOTIFY specularChanged)
+ Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged)
+
+public:
+ explicit QPhongMaterial(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QPhongMaterial();
+
+ QColor ambient() const;
+ QColor diffuse() const;
+ QColor specular() const;
+ float shininess() const;
+
+public Q_SLOTS:
+ void setAmbient(const QColor &ambient);
+ void setDiffuse(const QColor &diffuse);
+ void setSpecular(const QColor &specular);
+ void setShininess(float shininess);
+
+Q_SIGNALS:
+ void ambientChanged(const QColor &ambient);
+ void diffuseChanged(const QColor &diffuse);
+ void specularChanged(const QColor &specular);
+ void shininessChanged(float shininess);
+
+private:
+ Q_DECLARE_PRIVATE(QPhongMaterial)
+};
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QPHONGMATERIAL_H
diff --git a/src/extras/defaults/qphongmaterial_p.h b/src/extras/defaults/qphongmaterial_p.h
new file mode 100644
index 000000000..bc6d0ce44
--- /dev/null
+++ b/src/extras/defaults/qphongmaterial_p.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE: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_QPHONGMATERIAL_P_H
+#define QT3DEXTRAS_QPHONGMATERIAL_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 QTechnique;
+class QParameter;
+class QShaderProgram;
+class QRenderPass;
+
+} // namespace Qt3DRender
+
+namespace Qt3DExtras {
+
+class QPhongMaterial;
+
+class QPhongMaterialPrivate : public Qt3DRender::QMaterialPrivate
+{
+public:
+ QPhongMaterialPrivate();
+
+ void init();
+
+ void handleAmbientChanged(const QVariant &var);
+ void handleDiffuseChanged(const QVariant &var);
+ void handleSpecularChanged(const QVariant &var);
+ void handleShininessChanged(const QVariant &var);
+
+ Qt3DRender::QEffect *m_phongEffect;
+ Qt3DRender::QParameter *m_ambientParameter;
+ Qt3DRender::QParameter *m_diffuseParameter;
+ Qt3DRender::QParameter *m_specularParameter;
+ Qt3DRender::QParameter *m_shininessParameter;
+ Qt3DRender::QTechnique *m_phongGL3Technique;
+ Qt3DRender::QTechnique *m_phongGL2Technique;
+ Qt3DRender::QTechnique *m_phongES2Technique;
+ Qt3DRender::QRenderPass *m_phongGL3RenderPass;
+ Qt3DRender::QRenderPass *m_phongGL2RenderPass;
+ Qt3DRender::QRenderPass *m_phongES2RenderPass;
+ Qt3DRender::QShaderProgram *m_phongGL3Shader;
+ Qt3DRender::QShaderProgram *m_phongGL2ES2Shader;
+ Qt3DRender::QFilterKey *m_filterKey;
+
+ Q_DECLARE_PUBLIC(QPhongMaterial)
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QPHONGMATERIAL_P_H
+
diff --git a/src/extras/defaults/qskyboxentity.cpp b/src/extras/defaults/qskyboxentity.cpp
new file mode 100644
index 000000000..973532fff
--- /dev/null
+++ b/src/extras/defaults/qskyboxentity.cpp
@@ -0,0 +1,293 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 "qskyboxentity.h"
+#include "qskyboxentity_p.h"
+
+#include <Qt3DCore/qtransform.h>
+#include <Qt3DRender/qfilterkey.h>
+#include <Qt3DRender/qeffect.h>
+#include <Qt3DRender/qtexture.h>
+#include <Qt3DRender/qmaterial.h>
+#include <Qt3DRender/qcullface.h>
+#include <Qt3DRender/qdepthtest.h>
+#include <Qt3DRender/qparameter.h>
+#include <Qt3DRender/qtechnique.h>
+#include <Qt3DExtras/qcuboidmesh.h>
+#include <Qt3DRender/qrenderpass.h>
+#include <Qt3DRender/qgraphicsapifilter.h>
+#include <Qt3DRender/qshaderprogram.h>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DCore;
+using namespace Qt3DRender;
+
+namespace Qt3DExtras {
+
+QSkyboxEntityPrivate::QSkyboxEntityPrivate()
+ : QEntityPrivate()
+ , m_effect(new QEffect())
+ , m_material(new QMaterial())
+ , m_skyboxTexture(new QTextureCubeMap())
+ , m_gl3Shader(new QShaderProgram())
+ , m_gl2es2Shader(new QShaderProgram())
+ , m_gl2Technique(new QTechnique())
+ , m_es2Technique(new QTechnique())
+ , m_gl3Technique(new QTechnique())
+ , m_filterKey(new QFilterKey)
+ , m_gl2RenderPass(new QRenderPass())
+ , m_es2RenderPass(new QRenderPass())
+ , m_gl3RenderPass(new QRenderPass())
+ , m_mesh(new QCuboidMesh())
+ , m_transform(new Qt3DCore::QTransform())
+ , m_textureParameter(new QParameter(QStringLiteral("skyboxTexture"), m_skyboxTexture))
+ , m_posXImage(new QTextureImage())
+ , m_posYImage(new QTextureImage())
+ , m_posZImage(new QTextureImage())
+ , m_negXImage(new QTextureImage())
+ , m_negYImage(new QTextureImage())
+ , m_negZImage(new QTextureImage())
+ , m_extension(QStringLiteral(".png"))
+{
+}
+
+/*!
+ * \internal
+ */
+void QSkyboxEntityPrivate::init()
+{
+ m_gl3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/skybox.vert"))));
+ m_gl3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/skybox.frag"))));
+ m_gl2es2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/skybox.vert"))));
+ m_gl2es2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/skybox.frag"))));
+
+ m_gl3Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_gl3Technique->graphicsApiFilter()->setMajorVersion(3);
+ m_gl3Technique->graphicsApiFilter()->setMajorVersion(1);
+ m_gl3Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::CoreProfile);
+
+ m_gl2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGL);
+ m_gl2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_gl2Technique->graphicsApiFilter()->setMajorVersion(0);
+ m_gl2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ m_es2Technique->graphicsApiFilter()->setApi(QGraphicsApiFilter::OpenGLES);
+ m_es2Technique->graphicsApiFilter()->setMajorVersion(2);
+ m_es2Technique->graphicsApiFilter()->setMajorVersion(0);
+ m_es2Technique->graphicsApiFilter()->setProfile(QGraphicsApiFilter::NoProfile);
+
+ m_filterKey->setParent(m_effect);
+ m_filterKey->setName(QStringLiteral("renderingStyle"));
+ m_filterKey->setValue(QStringLiteral("forward"));
+
+ m_gl3Technique->addFilterKey(m_filterKey);
+ m_gl2Technique->addFilterKey(m_filterKey);
+ m_es2Technique->addFilterKey(m_filterKey);
+
+ m_gl3RenderPass->setShaderProgram(m_gl3Shader);
+ m_gl2RenderPass->setShaderProgram(m_gl2es2Shader);
+ m_es2RenderPass->setShaderProgram(m_gl2es2Shader);
+
+ QCullFace *cullFront = new QCullFace();
+ cullFront->setMode(QCullFace::Front);
+ QDepthTest *depthTest = new QDepthTest();
+ depthTest->setDepthFunction(QDepthTest::LessOrEqual);
+
+ m_gl3RenderPass->addRenderState(cullFront);
+ m_gl3RenderPass->addRenderState(depthTest);
+ m_gl2RenderPass->addRenderState(cullFront);
+ m_gl2RenderPass->addRenderState(depthTest);
+ m_es2RenderPass->addRenderState(cullFront);
+ m_es2RenderPass->addRenderState(depthTest);
+
+ m_gl3Technique->addRenderPass(m_gl3RenderPass);
+ m_gl2Technique->addRenderPass(m_gl2RenderPass);
+ m_es2Technique->addRenderPass(m_es2RenderPass);
+
+ m_effect->addTechnique(m_gl3Technique);
+ m_effect->addTechnique(m_gl2Technique);
+ m_effect->addTechnique(m_es2Technique);
+
+ m_material->setEffect(m_effect);
+ m_material->addParameter(m_textureParameter);
+
+ m_mesh->setXYMeshResolution(QSize(2, 2));
+ m_mesh->setXZMeshResolution(QSize(2, 2));
+ m_mesh->setYZMeshResolution(QSize(2, 2));
+
+ m_posXImage->setFace(QTextureCubeMap::CubeMapPositiveX);
+ m_posYImage->setFace(QTextureCubeMap::CubeMapPositiveY);
+ m_posZImage->setFace(QTextureCubeMap::CubeMapPositiveZ);
+ m_negXImage->setFace(QTextureCubeMap::CubeMapNegativeX);
+ m_negYImage->setFace(QTextureCubeMap::CubeMapNegativeY);
+ m_negZImage->setFace(QTextureCubeMap::CubeMapNegativeZ);
+
+ m_skyboxTexture->setMagnificationFilter(QTextureCubeMap::Linear);
+ m_skyboxTexture->setMinificationFilter(QTextureCubeMap::Linear);
+ m_skyboxTexture->setGenerateMipMaps(false);
+ m_skyboxTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::ClampToEdge));
+
+ m_skyboxTexture->addTextureImage(m_posXImage);
+ m_skyboxTexture->addTextureImage(m_posYImage);
+ m_skyboxTexture->addTextureImage(m_posZImage);
+ m_skyboxTexture->addTextureImage(m_negXImage);
+ m_skyboxTexture->addTextureImage(m_negYImage);
+ m_skyboxTexture->addTextureImage(m_negZImage);
+
+ q_func()->addComponent(m_mesh);
+ q_func()->addComponent(m_material);
+ q_func()->addComponent(m_transform);
+}
+
+/*!
+ * \internal
+ */
+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));
+}
+
+/*!
+ * \class Qt3DRender::QSkyboxEntity
+ * \inmodule Qt3DRender
+ *
+ * \brief Qt3DRender::QSkyboxEntity is a convenience Qt3DCore::QEntity subclass that can
+ * be used to insert a skybox in a 3D scene.
+ *
+ * By specifying a base name and an extension, Qt3DCore::QSkyboxEntity
+ * will take care of building a TextureCubeMap to be rendered at runtime. The
+ * images in the source directory should match the pattern:
+ * \b base name + * "_posx|_posy|_posz|_negx|_negy|_negz" + extension
+ *
+ * By default the extension defaults to .png.
+ *
+ * \note Please note that you shouldn't try to render skybox with an
+ * orthographic projection.
+ *
+ * \since 5.5
+ */
+
+/*!
+ * Constructs a new Qt3DCore::QSkyboxEntity object with \a parent as parent.
+ */
+QSkyboxEntity::QSkyboxEntity(QNode *parent)
+ : QEntity(*new QSkyboxEntityPrivate, parent)
+{
+ d_func()->init();
+}
+
+QSkyboxEntity::~QSkyboxEntity()
+{
+ QNode::cleanup();
+}
+
+/*!
+ * Sets the base name to \a baseName.
+ */
+void QSkyboxEntity::setBaseName(const QString &baseName)
+{
+ Q_D(QSkyboxEntity);
+ if (baseName != d->m_baseName) {
+ d->m_baseName = baseName;
+ emit sourceDirectoryChanged(baseName);
+ d->reloadTexture();
+ }
+}
+/*!
+ * Returns the base name.
+ */
+QString QSkyboxEntity::baseName() const
+{
+ Q_D(const QSkyboxEntity);
+ return d->m_baseName;
+}
+
+/*!
+ * Sets the extension to \a extension.
+ */
+void QSkyboxEntity::setExtension(const QString &extension)
+{
+ Q_D(QSkyboxEntity);
+ if (extension != d->m_extension) {
+ d->m_extension = extension;
+ emit extensionChanged(extension);
+ d->reloadTexture();
+ }
+}
+
+/*!
+ * Returns the extension
+ */
+QString QSkyboxEntity::extension() const
+{
+ Q_D(const QSkyboxEntity);
+ return d->m_extension;
+}
+
+/*!
+ * Sets the camera position to \a cameraPosition.
+ */
+void QSkyboxEntity::setCameraPosition(const QVector3D &cameraPosition)
+{
+ Q_D(QSkyboxEntity);
+ if (cameraPosition != d->m_position) {
+ d->m_position = cameraPosition;
+ d->m_transform->setTranslation(d->m_position);
+ emit cameraPositionChanged(cameraPosition);
+ }
+}
+
+/*!
+ * Returns the camera position.
+ */
+QVector3D QSkyboxEntity::cameraPosition() const
+{
+ Q_D(const QSkyboxEntity);
+ return d->m_position;
+}
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
diff --git a/src/extras/defaults/qskyboxentity.h b/src/extras/defaults/qskyboxentity.h
new file mode 100644
index 000000000..7112bff4c
--- /dev/null
+++ b/src/extras/defaults/qskyboxentity.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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_QSKYBOXENTITY_H
+#define QT3DEXTRAS_QSKYBOXENTITY_H
+
+#include <Qt3DCore/qentity.h>
+#include <Qt3DExtras/qt3dextras_global.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DExtras {
+
+class QSkyboxEntityPrivate;
+
+class QT3DEXTRASSHARED_EXPORT QSkyboxEntity : public Qt3DCore::QEntity
+{
+ Q_OBJECT
+public:
+ explicit QSkyboxEntity(Qt3DCore::QNode *parent = Q_NULLPTR);
+ ~QSkyboxEntity();
+
+ void setBaseName(const QString &path);
+ QString baseName() const;
+
+ void setExtension(const QString &extension);
+ QString extension() const;
+
+ void setCameraPosition(const QVector3D &cameraPosition);
+ QVector3D cameraPosition() const;
+
+Q_SIGNALS:
+ void sourceDirectoryChanged(const QString &path);
+ void extensionChanged(const QString &extension);
+ void cameraPositionChanged(const QVector3D &cameraPosition);
+
+private:
+ Q_DECLARE_PRIVATE(QSkyboxEntity)
+};
+
+} // namespace Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QSKYBOXENTITY_H
diff --git a/src/extras/defaults/qskyboxentity_p.h b/src/extras/defaults/qskyboxentity_p.h
new file mode 100644
index 000000000..565caa66d
--- /dev/null
+++ b/src/extras/defaults/qskyboxentity_p.h
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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_QSKYBOXENTITY_P_H
+#define QT3DEXTRAS_QSKYBOXENTITY_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 <Qt3DCore/private/qentity_p.h>
+#include <QVector3D>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+class QTransform;
+}
+
+namespace Qt3DRender {
+
+class QFilterKey;
+class QTextureCubeMap;
+class QShaderProgram;
+class QSkyboxEntity;
+class QTextureImage;
+class QRenderPass;
+class QTechnique;
+class QParameter;
+class QMaterial;
+class QEffect;
+
+} // namespace Qt3DRender
+
+namespace Qt3DExtras {
+
+class QCuboidMesh;
+
+class QSkyboxEntityPrivate : public Qt3DCore::QEntityPrivate
+{
+ QSkyboxEntityPrivate();
+
+ void init();
+ void reloadTexture();
+
+ Q_DECLARE_PUBLIC(QSkyboxEntity)
+
+ Qt3DRender::QEffect *m_effect;
+ Qt3DRender::QMaterial *m_material;
+ Qt3DRender::QTextureCubeMap *m_skyboxTexture;
+ Qt3DRender::QShaderProgram *m_gl3Shader;
+ Qt3DRender::QShaderProgram *m_gl2es2Shader;
+ Qt3DRender::QTechnique *m_gl2Technique;
+ Qt3DRender::QTechnique *m_es2Technique;
+ Qt3DRender::QTechnique *m_gl3Technique;
+ Qt3DRender::QFilterKey *m_filterKey;
+ Qt3DRender::QRenderPass *m_gl2RenderPass;
+ Qt3DRender::QRenderPass *m_es2RenderPass;
+ Qt3DRender::QRenderPass *m_gl3RenderPass;
+ QCuboidMesh *m_mesh;
+ Qt3DCore::QTransform *m_transform;
+ Qt3DRender::QParameter *m_textureParameter;
+ Qt3DRender::QTextureImage *m_posXImage;
+ Qt3DRender:: QTextureImage *m_posYImage;
+ Qt3DRender::QTextureImage *m_posZImage;
+ Qt3DRender::QTextureImage *m_negXImage;
+ Qt3DRender::QTextureImage *m_negYImage;
+ Qt3DRender::QTextureImage *m_negZImage;
+ QString m_extension;
+ QString m_baseName;
+ QVector3D m_position;
+};
+
+} // Qt3DExtras
+
+QT_END_NAMESPACE
+
+#endif // QT3DEXTRAS_QSKYBOXENTITY_P_H
+