summaryrefslogtreecommitdiffstats
path: root/src/render/defaults
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire.ecortex@kdab.com>2014-12-29 16:10:48 +0100
committerSean Harmer <sean.harmer@kdab.com>2014-12-31 11:23:49 +0100
commitbee25daf9efaa688a6954a5b31a07c51db49b8ba (patch)
tree5bc3f2982689c8908c9fbe440eff36cd1d15f6a1 /src/render/defaults
parent2be97a74b23c66d385b1dd89df106c9be7be7696 (diff)
Default cpp materials + material-cpp example
QDiffuseMapMaterial QDiffuseSpecularMapMaterial QNormalDiffuseMapMaterial QNormalDiffuseAlphaMapMaterial QNormalDiffuseSpecularMapMaterial material-cpp is mostly inspired from materials (QML) but nicer :). Note: there seems to be an issue with qrc and QUrl. The behavior is different between QML and C++. -In C++ we need to prefix with have qrc:/ and convert that to :/ (passing :/ directly returns "" when QUrl toString is called) -From QML no prefix is needed. -For QImage path, :/ should be used. Change-Id: Ib56fb9546c95c2872686a46ed048a290ab4a5b6f Task-number: QTBUG-41548 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/defaults')
-rw-r--r--src/render/defaults/defaults.pri19
-rw-r--r--src/render/defaults/qdiffusemapmaterial.cpp274
-rw-r--r--src/render/defaults/qdiffusemapmaterial.h95
-rw-r--r--src/render/defaults/qdiffusemapmaterial_p.h91
-rw-r--r--src/render/defaults/qdiffusespecularmapmaterial.cpp285
-rw-r--r--src/render/defaults/qdiffusespecularmapmaterial.h95
-rw-r--r--src/render/defaults/qdiffusespecularmapmaterial_p.h93
-rw-r--r--src/render/defaults/qnormaldiffusemapalphamaterial.cpp161
-rw-r--r--src/render/defaults/qnormaldiffusemapalphamaterial.h68
-rw-r--r--src/render/defaults/qnormaldiffusemapalphamaterial_p.h74
-rw-r--r--src/render/defaults/qnormaldiffusemapmaterial.cpp319
-rw-r--r--src/render/defaults/qnormaldiffusemapmaterial.h102
-rw-r--r--src/render/defaults/qnormaldiffusemapmaterial_p.h94
-rw-r--r--src/render/defaults/qnormaldiffusespecularmapmaterial.cpp330
-rw-r--r--src/render/defaults/qnormaldiffusespecularmapmaterial.h101
-rw-r--r--src/render/defaults/qnormaldiffusespecularmapmaterial_p.h95
-rw-r--r--src/render/defaults/qphongmaterial.cpp31
-rw-r--r--src/render/defaults/qphongmaterial.h2
-rw-r--r--src/render/defaults/qphongmaterial_p.h4
19 files changed, 2304 insertions, 29 deletions
diff --git a/src/render/defaults/defaults.pri b/src/render/defaults/defaults.pri
index c2f77f887..2ec17c3b8 100644
--- a/src/render/defaults/defaults.pri
+++ b/src/render/defaults/defaults.pri
@@ -2,7 +2,22 @@ INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/qphongmaterial.h \
- $$PWD/qphongmaterial_p.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
SOURCES += \
- $$PWD/qphongmaterial.cpp
+ $$PWD/qphongmaterial.cpp \
+ $$PWD/qdiffusemapmaterial.cpp \
+ $$PWD/qnormaldiffusespecularmapmaterial.cpp \
+ $$PWD/qnormaldiffusemapmaterial.cpp \
+ $$PWD/qnormaldiffusemapalphamaterial.cpp \
+ $$PWD/qdiffusespecularmapmaterial.cpp
diff --git a/src/render/defaults/qdiffusemapmaterial.cpp b/src/render/defaults/qdiffusemapmaterial.cpp
new file mode 100644
index 000000000..2cf30e981
--- /dev/null
+++ b/src/render/defaults/qdiffusemapmaterial.cpp
@@ -0,0 +1,274 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdiffusemapmaterial.h"
+#include "qdiffusemapmaterial_p.h"
+#include <Qt3DRenderer/qmaterial.h>
+#include <Qt3DRenderer/qeffect.h>
+#include <Qt3DRenderer/qtexture.h>
+#include <Qt3DRenderer/qtechnique.h>
+#include <Qt3DRenderer/qshaderprogram.h>
+#include <Qt3DRenderer/qparameter.h>
+#include <Qt3DRenderer/qrenderpass.h>
+#include <Qt3DRenderer/qopenglfilter.h>
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+QDiffuseMapMaterialPrivate::QDiffuseMapMaterialPrivate(QDiffuseMapMaterial *qq)
+ : QMaterialPrivate(qq)
+ , m_diffuseMapEffect(new QEffect())
+ , m_diffuseTexture(new QTexture(QTexture::Target2D))
+ , 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.95f, 0.95f, 0.95f, 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_diffuseTexture->setMagnificationFilter(QTexture::Linear);
+ m_diffuseTexture->setMinificationFilter(QTexture::LinearMipMapLinear);
+ m_diffuseTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_diffuseTexture->setGenerateMipMaps(true);
+ m_diffuseTexture->setMaximumAnisotropy(16.0f);
+}
+
+void QDiffuseMapMaterialPrivate::init()
+{
+ 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->openGLFilter()->setApi(QOpenGLFilter::Desktop);
+ m_diffuseMapGL3Technique->openGLFilter()->setMajorVersion(3);
+ m_diffuseMapGL3Technique->openGLFilter()->setMinorVersion(1);
+ m_diffuseMapGL3Technique->openGLFilter()->setProfile(QOpenGLFilter::Core);
+
+ m_diffuseMapGL2Technique->openGLFilter()->setApi(QOpenGLFilter::Desktop);
+ m_diffuseMapGL2Technique->openGLFilter()->setMajorVersion(2);
+ m_diffuseMapGL2Technique->openGLFilter()->setMinorVersion(0);
+ m_diffuseMapGL2Technique->openGLFilter()->setProfile(QOpenGLFilter::None);
+
+ m_diffuseMapES2Technique->openGLFilter()->setApi(QOpenGLFilter::ES);
+ m_diffuseMapES2Technique->openGLFilter()->setMajorVersion(2);
+ m_diffuseMapES2Technique->openGLFilter()->setMinorVersion(0);
+ m_diffuseMapES2Technique->openGLFilter()->setProfile(QOpenGLFilter::None);
+
+ m_diffuseMapGL3RenderPass->setShaderProgram(m_diffuseMapGL3Shader);
+ m_diffuseMapGL2RenderPass->setShaderProgram(m_diffuseMapGL2ES2Shader);
+ m_diffuseMapES2RenderPass->setShaderProgram(m_diffuseMapGL2ES2Shader);
+
+ m_diffuseMapGL3Technique->addPass(m_diffuseMapGL3RenderPass);
+ m_diffuseMapGL2Technique->addPass(m_diffuseMapGL2RenderPass);
+ m_diffuseMapES2Technique->addPass(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);
+
+ static_cast<QMaterial *>(q_ptr)->setEffect(m_diffuseMapEffect);
+}
+
+/*!
+ \class Qt3D::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.
+*/
+
+/*!
+ \fn Qt3D::QDiffuseMapMaterial::QDiffuseMapMaterial()
+ Constructs a new Qt3D::QDiffuseMapMaterial instance with parent object \a parent.
+ */
+
+QDiffuseMapMaterial::QDiffuseMapMaterial(QNode *parent)
+ : QMaterial(*new QDiffuseMapMaterialPrivate(this), parent)
+{
+ Q_D(QDiffuseMapMaterial);
+ QObject::connect(d->m_ambientParameter, SIGNAL(valueChanged()), this, SIGNAL(ambientChanged()));
+ QObject::connect(d->m_diffuseParameter, SIGNAL(valueChanged()), this, SIGNAL(diffuseChanged()));
+ QObject::connect(d->m_specularParameter, SIGNAL(valueChanged()), this, SIGNAL(specularChanged()));
+ QObject::connect(d->m_shininessParameter, SIGNAL(valueChanged()), this, SIGNAL(shininessChanged()));
+ QObject::connect(d->m_textureScaleParameter, SIGNAL(valueChanged()), this, SIGNAL(textureScaleChanged()));
+ d->init();
+}
+
+QDiffuseMapMaterial::~QDiffuseMapMaterial()
+{
+}
+
+/*!
+ \fn Qt3D::QDiffuseMapMaterial::ambient() const
+ \return the current QColor ambient value.
+ */
+QColor QDiffuseMapMaterial::ambient() const
+{
+ Q_D(const QDiffuseMapMaterial);
+ return d->m_ambientParameter->value().value<QColor>();
+}
+
+/*!
+ \fn Qt3D::QDiffuseMapMaterial::specular() const
+ \return the current QColor specular value.
+ */
+QColor QDiffuseMapMaterial::specular() const
+{
+ Q_D(const QDiffuseMapMaterial);
+ return d->m_specularParameter->value().value<QColor>();
+}
+
+/*!
+ \fn Qt3D::QDiffuseMapMaterial::shininess() const
+ \return the current shininess as a float value.
+ */
+float QDiffuseMapMaterial::shininess() const
+{
+ Q_D(const QDiffuseMapMaterial);
+ return d->m_diffuseParameter->value().toFloat();
+}
+
+/*!
+ \fn Qt3D::QDiffuseMapMaterial::diffuse() const
+ \return the current QTexture used as the diffuse map.
+ \b {Note:} By default the diffuse texture has a linear
+ magnification filter, a linear mipmap linear minification filter,
+ the wrap mode is repeat, the maximum anisotropy is set to 16.0
+ and mipmapping is enabled.
+ */
+QTexture *QDiffuseMapMaterial::diffuse() const
+{
+ Q_D(const QDiffuseMapMaterial);
+ return d->m_diffuseParameter->value().value<QTexture *>();
+}
+
+/*!
+ \fn Qt3D::QDiffuseMapMaterial::textureScale() const
+ \return the current texture scale.
+ */
+float QDiffuseMapMaterial::textureScale() const
+{
+ Q_D(const QDiffuseMapMaterial);
+ return d->m_textureScaleParameter->value().toFloat();
+}
+
+/*!
+ \fn Qt3D::QDiffuseMapMaterial::setAmbient(const QColor &ambient)
+ Sets the current ambient color to \a ambient.
+ */
+void QDiffuseMapMaterial::setAmbient(const QColor &ambient)
+{
+ Q_D(const QDiffuseMapMaterial);
+ d->m_ambientParameter->setValue(ambient);
+}
+
+/*!
+ \fn Qt3D::QDiffuseMapMaterial::setSpecular(const QColor &specular)
+ Sets the current specular color to \a specular.
+ */
+void QDiffuseMapMaterial::setSpecular(const QColor &specular)
+{
+ Q_D(QDiffuseMapMaterial);
+ d->m_specularParameter->setValue(specular);
+}
+
+/*!
+ \fn Qt3D::QDiffuseMapMaterial::setShininess(float shininess)
+ Sets the current shininess value to \a shininess.
+ */
+void QDiffuseMapMaterial::setShininess(float shininess)
+{
+ Q_D(QDiffuseMapMaterial);
+ d->m_shininessParameter->setValue(shininess);
+}
+
+/*!
+ \fn Qt3D::QDiffuseMapMaterial::setDiffuse(QTexture *diffuseMap)
+ Sets the current diffuse map to \a diffuseMap.
+ */
+void QDiffuseMapMaterial::setDiffuse(QTexture *diffuseMap)
+{
+ Q_D(QDiffuseMapMaterial);
+ d->m_diffuseParameter->setValue(QVariant::fromValue(diffuseMap));
+}
+
+/*!
+ \fn Qt3D::QDiffuseMapMaterial::setTextureScale(float textureScale)
+ Sets the current texture scale to \a textureScale.
+ */
+void QDiffuseMapMaterial::setTextureScale(float textureScale)
+{
+ Q_D(QDiffuseMapMaterial);
+ d->m_textureScaleParameter->setValue(textureScale);
+}
+
+} // Qt3D
+
+QT_END_NAMESPACE
diff --git a/src/render/defaults/qdiffusemapmaterial.h b/src/render/defaults/qdiffusemapmaterial.h
new file mode 100644
index 000000000..00c1f4f2d
--- /dev/null
+++ b/src/render/defaults/qdiffusemapmaterial.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_RENDER_QDIFFUSEGMAPMATERIAL_H
+#define QT3D_RENDER_QDIFFUSEMAPMATERIAL_H
+
+#include <Qt3DRenderer/qmaterial.h>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QDiffuseMapMaterialPrivate;
+class QTexture;
+
+class QT3DRENDERERSHARED_EXPORT QDiffuseMapMaterial : public 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(QTexture *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(float textureScale READ textureScale WRITE setTextureScale NOTIFY textureScaleChanged)
+
+public:
+ explicit QDiffuseMapMaterial(QNode *parent = 0);
+ ~QDiffuseMapMaterial();
+
+ QColor ambient() const;
+ QColor specular() const;
+ float shininess() const;
+ QTexture *diffuse() const;
+ float textureScale() const;
+
+ void setAmbient(const QColor &color);
+ void setSpecular(const QColor &specular);
+ void setShininess(float shininess);
+ void setDiffuse(QTexture *diffuse);
+ void setTextureScale(float textureScale);
+
+Q_SIGNALS:
+ void ambientChanged();
+ void diffuseChanged();
+ void specularChanged();
+ void shininessChanged();
+ void textureScaleChanged();
+
+private:
+ Q_DECLARE_PRIVATE(QDiffuseMapMaterial)
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_RENDER_QDIFFUSEMAPMATERIAL_H
diff --git a/src/render/defaults/qdiffusemapmaterial_p.h b/src/render/defaults/qdiffusemapmaterial_p.h
new file mode 100644
index 000000000..9fffcfa4b
--- /dev/null
+++ b/src/render/defaults/qdiffusemapmaterial_p.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_RENDER_QDIFFUSEMAPMATERIAL_P_H
+#define QT3D_RENDER_QDIFFUSEMAPMATERIAL_P_H
+
+#include <Qt3DRenderer/private/qmaterial_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QEffect;
+class QTexture;
+class QTechnique;
+class QParameter;
+class QShaderProgram;
+class QRenderPass;
+class QParameterMapping;
+
+class QDiffuseMapMaterial;
+
+class QDiffuseMapMaterialPrivate : public QMaterialPrivate
+{
+ QDiffuseMapMaterialPrivate(QDiffuseMapMaterial *qq);
+
+ void init();
+
+ QEffect *m_diffuseMapEffect;
+ QTexture *m_diffuseTexture;
+ QParameter *m_ambientParameter;
+ QParameter *m_diffuseParameter;
+ QParameter *m_specularParameter;
+ QParameter *m_shininessParameter;
+ QParameter *m_textureScaleParameter;
+ QTechnique *m_diffuseMapGL3Technique;
+ QTechnique *m_diffuseMapGL2Technique;
+ QTechnique *m_diffuseMapES2Technique;
+ QRenderPass *m_diffuseMapGL3RenderPass;
+ QRenderPass *m_diffuseMapGL2RenderPass;
+ QRenderPass *m_diffuseMapES2RenderPass;
+ QShaderProgram *m_diffuseMapGL3Shader;
+ QShaderProgram *m_diffuseMapGL2ES2Shader;
+
+ Q_DECLARE_PUBLIC(QDiffuseMapMaterial)
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_RENDER_QDIFFUSEAPMATERIAL_P_H
+
diff --git a/src/render/defaults/qdiffusespecularmapmaterial.cpp b/src/render/defaults/qdiffusespecularmapmaterial.cpp
new file mode 100644
index 000000000..1784250b4
--- /dev/null
+++ b/src/render/defaults/qdiffusespecularmapmaterial.cpp
@@ -0,0 +1,285 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdiffusespecularmapmaterial.h"
+#include "qdiffusespecularmapmaterial_p.h"
+
+#include <Qt3DRenderer/qmaterial.h>
+#include <Qt3DRenderer/qeffect.h>
+#include <Qt3DRenderer/qtexture.h>
+#include <Qt3DRenderer/qtechnique.h>
+#include <Qt3DRenderer/qshaderprogram.h>
+#include <Qt3DRenderer/qparameter.h>
+#include <Qt3DRenderer/qrenderpass.h>
+#include <Qt3DRenderer/qopenglfilter.h>
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+QDiffuseSpecularMapMaterialPrivate::QDiffuseSpecularMapMaterialPrivate(QDiffuseSpecularMapMaterial *qq)
+ : QMaterialPrivate(qq)
+ , m_diffuseSpecularMapEffect(new QEffect())
+ , m_diffuseTexture(new QTexture(QTexture::Target2D))
+ , m_specularTexture(new QTexture(QTexture::Target2D))
+ , 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_diffuseTexture->setMagnificationFilter(QTexture::Linear);
+ m_diffuseTexture->setMinificationFilter(QTexture::LinearMipMapLinear);
+ m_diffuseTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_diffuseTexture->setGenerateMipMaps(true);
+ m_diffuseTexture->setMaximumAnisotropy(16.0f);
+
+ m_specularTexture->setMagnificationFilter(QTexture::Linear);
+ m_specularTexture->setMinificationFilter(QTexture::LinearMipMapLinear);
+ m_specularTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_specularTexture->setGenerateMipMaps(true);
+ m_specularTexture->setMaximumAnisotropy(16.0f);
+}
+
+void QDiffuseSpecularMapMaterialPrivate::init()
+{
+ m_diffuseSpecularMapGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/diffusespecularmap.vert"))));
+ m_diffuseSpecularMapGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/diffusespecularmap.frag"))));
+ m_diffuseSpecularMapGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/diffusespecularmap.vert"))));
+ m_diffuseSpecularMapGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/diffusespecularmap.frag"))));
+
+ m_diffuseSpecularMapGL3Technique->openGLFilter()->setApi(QOpenGLFilter::Desktop);
+ m_diffuseSpecularMapGL3Technique->openGLFilter()->setMajorVersion(3);
+ m_diffuseSpecularMapGL3Technique->openGLFilter()->setMinorVersion(1);
+ m_diffuseSpecularMapGL3Technique->openGLFilter()->setProfile(QOpenGLFilter::Core);
+
+ m_diffuseSpecularMapGL2Technique->openGLFilter()->setApi(QOpenGLFilter::Desktop);
+ m_diffuseSpecularMapGL2Technique->openGLFilter()->setMajorVersion(2);
+ m_diffuseSpecularMapGL2Technique->openGLFilter()->setMinorVersion(0);
+ m_diffuseSpecularMapGL2Technique->openGLFilter()->setProfile(QOpenGLFilter::None);
+
+ m_diffuseSpecularMapES2Technique->openGLFilter()->setApi(QOpenGLFilter::ES);
+ m_diffuseSpecularMapES2Technique->openGLFilter()->setMajorVersion(2);
+ m_diffuseSpecularMapES2Technique->openGLFilter()->setMinorVersion(0);
+ m_diffuseSpecularMapES2Technique->openGLFilter()->setProfile(QOpenGLFilter::None);
+
+ m_diffuseSpecularMapGL3RenderPass->setShaderProgram(m_diffuseSpecularMapGL3Shader);
+ m_diffuseSpecularMapGL2RenderPass->setShaderProgram(m_diffuseSpecularMapGL2ES2Shader);
+ m_diffuseSpecularMapES2RenderPass->setShaderProgram(m_diffuseSpecularMapGL2ES2Shader);
+
+ m_diffuseSpecularMapGL3Technique->addPass(m_diffuseSpecularMapGL3RenderPass);
+ m_diffuseSpecularMapGL2Technique->addPass(m_diffuseSpecularMapGL2RenderPass);
+ m_diffuseSpecularMapES2Technique->addPass(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);
+
+ static_cast<QMaterial *>(q_ptr)->setEffect(m_diffuseSpecularMapEffect);
+}
+
+/*!
+ \class Qt3D::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.
+*/
+
+/*!
+ \fn Qt3D::QDiffuseSpecularMapMaterial::QDiffuseSpecularMapMaterial()
+ Constructs a new Qt3D::QDiffuseSpecularMapMaterial instance with parent object \a parent.
+*/
+QDiffuseSpecularMapMaterial::QDiffuseSpecularMapMaterial(QNode *parent)
+ : QMaterial(*new QDiffuseSpecularMapMaterialPrivate(this), parent)
+{
+ Q_D(QDiffuseSpecularMapMaterial);
+ QObject::connect(d->m_ambientParameter, SIGNAL(valueChanged()), this, SIGNAL(ambientChanged()));
+ QObject::connect(d->m_diffuseParameter, SIGNAL(valueChanged()), this, SIGNAL(diffuseChanged()));
+ QObject::connect(d->m_specularParameter, SIGNAL(valueChanged()), this, SIGNAL(specularChanged()));
+ QObject::connect(d->m_shininessParameter, SIGNAL(valueChanged()), this, SIGNAL(shininessChanged()));
+ QObject::connect(d->m_textureScaleParameter, SIGNAL(valueChanged()), this, SIGNAL(textureScaleChanged()));
+ d->init();
+}
+
+QDiffuseSpecularMapMaterial::~QDiffuseSpecularMapMaterial()
+{
+}
+
+/*!
+ \fn Qt3D::QDiffuseSpecularMapMaterial::ambient() const
+ \return the current QColor ambient value.
+ */
+QColor QDiffuseSpecularMapMaterial::ambient() const
+{
+ Q_D(const QDiffuseSpecularMapMaterial);
+ return d->m_ambientParameter->value().value<QColor>();
+}
+
+/*!
+ \fn Qt3D::QDiffuseSpecularMapMaterial::diffuse() const
+ \return the current diffuse map texture.
+ \b {Note:} By default the diffuse texture has a linear
+ magnification filter, a linear mipmap linear minification filter,
+ the wrap mode is repeat, the maximum anisotropy is set to 16.0
+ and mipmapping is enabled.
+ */
+QTexture *QDiffuseSpecularMapMaterial::diffuse() const
+{
+ Q_D(const QDiffuseSpecularMapMaterial);
+ return d->m_diffuseParameter->value().value<QTexture *>();
+}
+
+/*!
+ \fn Qt3D::QDiffuseSpecularMapMaterial::specular() const
+ \return the current specular map texture.
+ \b {Note:} By default the specular texture has a linear
+ magnification filter, a linear mipmap linear minification filter,
+ the wrap mode is repeat, the maximum anisotropy is set to 16.0
+ and mipmapping is enabled.
+ */
+QTexture *QDiffuseSpecularMapMaterial::specular() const
+{
+ Q_D(const QDiffuseSpecularMapMaterial);
+ return d->m_specularParameter->value().value<QTexture *>();
+}
+
+/*!
+ \fn Qt3D::QDiffuseSpecularMapMaterial::shininess() const
+ \return the current shininess as a float value.
+ */
+float QDiffuseSpecularMapMaterial::shininess() const
+{
+ Q_D(const QDiffuseSpecularMapMaterial);
+ return d->m_shininessParameter->value().toFloat();
+}
+
+/*!
+ \fn Qt3D::QDiffuseSpecularMapMaterial::textureScale() const
+ \return the current texture scale.
+ */
+float QDiffuseSpecularMapMaterial::textureScale() const
+{
+ Q_D(const QDiffuseSpecularMapMaterial);
+ return d->m_textureScaleParameter->value().toFloat();
+}
+
+/*!
+ \fn Qt3D::QDiffuseSpecularMapMaterial::setAmbient(const QColor &ambient)
+ Sets the current ambient color to \a ambient
+ */
+void QDiffuseSpecularMapMaterial::setAmbient(const QColor &ambient)
+{
+ Q_D(QDiffuseSpecularMapMaterial);
+ d->m_ambientParameter->setValue(ambient);
+}
+
+/*!
+ \fn Qt3D::QDiffuseSpecularMapMaterial::setDiffuse(QTexture *diffuse)
+ Sets the current diffuse map to \a diffuse.
+ */
+void QDiffuseSpecularMapMaterial::setDiffuse(QTexture *diffuse)
+{
+ Q_D(QDiffuseSpecularMapMaterial);
+ d->m_diffuseParameter->setValue(QVariant::fromValue(diffuse));
+}
+
+/*!
+ \fn Qt3D::QDiffuseSpecularMapMaterial::setSpecular(QTexture *specular)
+ Sets the current specular map to \a specular.
+ */
+void QDiffuseSpecularMapMaterial::setSpecular(QTexture *specular)
+{
+ Q_D(QDiffuseSpecularMapMaterial);
+ d->m_specularParameter->setValue(QVariant::fromValue(specular));
+}
+
+/*!
+ \fn Qt3D::QDiffuseSpecularMapMaterial::setShininess(float shininess)
+ Sets the current shininess value to \a shininess.
+ */
+void QDiffuseSpecularMapMaterial::setShininess(float shininess)
+{
+ Q_D(QDiffuseSpecularMapMaterial);
+ d->m_shininessParameter->setValue(shininess);
+}
+
+/*!
+ \fn Qt3D::QDiffuseSpecularMapMaterial::setTextureScale(float textureScale)
+ Sets the current texture scale to \a textureScale.
+ */
+void QDiffuseSpecularMapMaterial::setTextureScale(float textureScale)
+{
+ Q_D(QDiffuseSpecularMapMaterial);
+ d->m_textureScaleParameter->setValue(textureScale);
+}
+
+} // Qt3D
+
+QT_END_NAMESPACE
diff --git a/src/render/defaults/qdiffusespecularmapmaterial.h b/src/render/defaults/qdiffusespecularmapmaterial.h
new file mode 100644
index 000000000..bcaa5b37e
--- /dev/null
+++ b/src/render/defaults/qdiffusespecularmapmaterial.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_RENDER_QDIFFUSESPECULARMAPMATERIAL_H
+#define QT3D_RENDER_QDIFFUSESPECULARMAPMATERIAL_H
+
+#include <Qt3DRenderer/qmaterial.h>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QTexture;
+class QDiffuseSpecularMapMaterialPrivate;
+
+class QT3DRENDERERSHARED_EXPORT QDiffuseSpecularMapMaterial : public 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(QTexture *specular READ specular WRITE setSpecular NOTIFY specularChanged)
+ Q_PROPERTY(QTexture *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(float textureScale READ textureScale WRITE setTextureScale NOTIFY textureScaleChanged)
+
+public:
+ explicit QDiffuseSpecularMapMaterial(QNode *parent = 0);
+ ~QDiffuseSpecularMapMaterial();
+
+ QColor ambient() const;
+ QTexture *diffuse() const;
+ QTexture *specular() const;
+ float shininess() const;
+ float textureScale() const;
+
+ void setAmbient(const QColor &ambient);
+ void setDiffuse(QTexture *diffuse);
+ void setSpecular(QTexture *specular);
+ void setShininess(float shininess);
+ void setTextureScale(float textureScale);
+
+Q_SIGNALS:
+ void ambientChanged();
+ void diffuseChanged();
+ void specularChanged();
+ void shininessChanged();
+ void textureScaleChanged();
+
+private:
+ Q_DECLARE_PRIVATE(QDiffuseSpecularMapMaterial)
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_RENDER_QDIFFUSESPECULARMAPMATERIAL_H
diff --git a/src/render/defaults/qdiffusespecularmapmaterial_p.h b/src/render/defaults/qdiffusespecularmapmaterial_p.h
new file mode 100644
index 000000000..bed6b62ae
--- /dev/null
+++ b/src/render/defaults/qdiffusespecularmapmaterial_p.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_RENDER_QDIFFUSESPECULARMAPMATERIAL_P_H
+#define QT3D_RENDER_QDIFFUSESPECULARMAPMATERIAL_P_H
+
+#include <Qt3DRenderer/private/qmaterial_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QEffect;
+class QTexture;
+class QTechnique;
+class QParameter;
+class QShaderProgram;
+class QRenderPass;
+class QParameterMapping;
+
+class QDiffuseSpecularMapMaterial;
+
+class QDiffuseSpecularMapMaterialPrivate : public QMaterialPrivate
+{
+public:
+ QDiffuseSpecularMapMaterialPrivate(QDiffuseSpecularMapMaterial *qq);
+
+ void init();
+
+ QEffect *m_diffuseSpecularMapEffect;
+ QTexture *m_diffuseTexture;
+ QTexture *m_specularTexture;
+ QParameter *m_ambientParameter;
+ QParameter *m_diffuseParameter;
+ QParameter *m_specularParameter;
+ QParameter *m_shininessParameter;
+ QParameter *m_textureScaleParameter;
+ QTechnique *m_diffuseSpecularMapGL3Technique;
+ QTechnique *m_diffuseSpecularMapGL2Technique;
+ QTechnique *m_diffuseSpecularMapES2Technique;
+ QRenderPass *m_diffuseSpecularMapGL3RenderPass;
+ QRenderPass *m_diffuseSpecularMapGL2RenderPass;
+ QRenderPass *m_diffuseSpecularMapES2RenderPass;
+ QShaderProgram *m_diffuseSpecularMapGL3Shader;
+ QShaderProgram *m_diffuseSpecularMapGL2ES2Shader;
+
+ Q_DECLARE_PUBLIC(QDiffuseSpecularMapMaterial)
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_RENDER_QDIFFUSESPECULARMAPMATERIAL_P_H
+
diff --git a/src/render/defaults/qnormaldiffusemapalphamaterial.cpp b/src/render/defaults/qnormaldiffusemapalphamaterial.cpp
new file mode 100644
index 000000000..fe381b6db
--- /dev/null
+++ b/src/render/defaults/qnormaldiffusemapalphamaterial.cpp
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qnormaldiffusemapalphamaterial.h"
+#include "qnormaldiffusemapalphamaterial_p.h"
+
+#include <Qt3DRenderer/qeffect.h>
+#include <Qt3DRenderer/qtexture.h>
+#include <Qt3DRenderer/qtechnique.h>
+#include <Qt3DRenderer/qparameter.h>
+#include <Qt3DRenderer/qshaderprogram.h>
+#include <Qt3DRenderer/qrenderpass.h>
+#include <Qt3DRenderer/qopenglfilter.h>
+#include <Qt3DRenderer/qalphacoverage.h>
+#include <Qt3DRenderer/qdepthtest.h>
+
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+
+QNormalDiffuseMapAlphaMaterialPrivate::QNormalDiffuseMapAlphaMaterialPrivate(QNormalDiffuseMapAlphaMaterial *qq)
+ : QNormalDiffuseMapMaterialPrivate(qq)
+ , 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->openGLFilter()->setApi(QOpenGLFilter::Desktop);
+ m_normalDiffuseGL3Technique->openGLFilter()->setMajorVersion(3);
+ m_normalDiffuseGL3Technique->openGLFilter()->setMinorVersion(1);
+ m_normalDiffuseGL3Technique->openGLFilter()->setProfile(QOpenGLFilter::Core);
+
+ m_normalDiffuseGL2Technique->openGLFilter()->setApi(QOpenGLFilter::Desktop);
+ m_normalDiffuseGL2Technique->openGLFilter()->setMajorVersion(2);
+ m_normalDiffuseGL2Technique->openGLFilter()->setMinorVersion(0);
+ m_normalDiffuseGL2Technique->openGLFilter()->setProfile(QOpenGLFilter::None);
+
+ m_normalDiffuseES2Technique->openGLFilter()->setApi(QOpenGLFilter::ES);
+ m_normalDiffuseES2Technique->openGLFilter()->setMajorVersion(2);
+ m_normalDiffuseES2Technique->openGLFilter()->setMinorVersion(0);
+ m_normalDiffuseES2Technique->openGLFilter()->setProfile(QOpenGLFilter::None);
+
+ m_depthTest->setFunc(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->addPass(m_normalDiffuseGL3RenderPass);
+ m_normalDiffuseGL2Technique->addPass(m_normalDiffuseGL2RenderPass);
+ m_normalDiffuseES2Technique->addPass(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);
+
+ static_cast<QMaterial *>(q_ptr)->setEffect(m_normalDiffuseEffect);
+}
+
+
+/*!
+ \class Qt3D::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.
+*/
+
+/*!
+ \fn Qt3D::QNormalDiffuseMapAlphaMaterial::QNormalDiffuseMapAlphaMaterial()
+ Constructs a new Qt3D::QNormalDiffuseMapAlphaMaterial instance with parent object \a parent.
+*/
+QNormalDiffuseMapAlphaMaterial::QNormalDiffuseMapAlphaMaterial(QNode *parent)
+ : QNormalDiffuseMapMaterial(*new QNormalDiffuseMapAlphaMaterialPrivate(this), parent)
+{
+}
+
+QNormalDiffuseMapAlphaMaterial::~QNormalDiffuseMapAlphaMaterial()
+{
+}
+
+} // Qt3D
+
+QT_END_NAMESPACE
diff --git a/src/render/defaults/qnormaldiffusemapalphamaterial.h b/src/render/defaults/qnormaldiffusemapalphamaterial.h
new file mode 100644
index 000000000..20682dfa2
--- /dev/null
+++ b/src/render/defaults/qnormaldiffusemapalphamaterial.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_RENDER_QNORMALDIFFUSEMAPALPHAMATERIAL_H
+#define QT3D_RENDER_QNORMALDIFFUSEMAPALPHAMATERIAL_H
+
+#include <Qt3DRenderer/qnormaldiffusemapmaterial.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QNormalDiffuseMapAlphaMaterialPrivate;
+
+class QT3DRENDERERSHARED_EXPORT QNormalDiffuseMapAlphaMaterial : public QNormalDiffuseMapMaterial
+{
+ Q_OBJECT
+public:
+ explicit QNormalDiffuseMapAlphaMaterial(QNode *parent = 0);
+ ~QNormalDiffuseMapAlphaMaterial();
+
+private:
+ Q_DECLARE_PRIVATE(QNormalDiffuseMapAlphaMaterial)
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_RENDER_QNORMALDIFFUSEMAPALPHAMATERIAL_H
diff --git a/src/render/defaults/qnormaldiffusemapalphamaterial_p.h b/src/render/defaults/qnormaldiffusemapalphamaterial_p.h
new file mode 100644
index 000000000..003d97bb1
--- /dev/null
+++ b/src/render/defaults/qnormaldiffusemapalphamaterial_p.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_RENDER_QNORMALDIFFUSEMAPALPHAMATERIAL_P_H
+#define QT3D_RENDER_QNORMALDIFFUSEMAPALPHAMATERIAL_P_H
+
+#include <Qt3DRenderer/private/qnormaldiffusemapmaterial_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QNormalDiffuseMapAlphaMaterial;
+
+class QAlphaCoverage;
+class QDepthTest;
+
+class QNormalDiffuseMapAlphaMaterialPrivate: public QNormalDiffuseMapMaterialPrivate
+{
+public:
+ QNormalDiffuseMapAlphaMaterialPrivate(QNormalDiffuseMapAlphaMaterial *qq);
+
+ void init() Q_DECL_OVERRIDE;
+
+ QAlphaCoverage *m_alphaCoverage;
+ QDepthTest *m_depthTest;
+
+ Q_DECLARE_PUBLIC(QNormalDiffuseMapAlphaMaterial)
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QNORMALDIFFUSEMAPALPHAMATERIAL_P_H
+
diff --git a/src/render/defaults/qnormaldiffusemapmaterial.cpp b/src/render/defaults/qnormaldiffusemapmaterial.cpp
new file mode 100644
index 000000000..5a8458e56
--- /dev/null
+++ b/src/render/defaults/qnormaldiffusemapmaterial.cpp
@@ -0,0 +1,319 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qnormaldiffusemapmaterial.h"
+#include "qnormaldiffusemapmaterial_p.h"
+
+#include <Qt3DRenderer/qeffect.h>
+#include <Qt3DRenderer/qtexture.h>
+#include <Qt3DRenderer/qtechnique.h>
+#include <Qt3DRenderer/qparameter.h>
+#include <Qt3DRenderer/qshaderprogram.h>
+#include <Qt3DRenderer/qrenderpass.h>
+#include <Qt3DRenderer/qopenglfilter.h>
+
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+QNormalDiffuseMapMaterialPrivate::QNormalDiffuseMapMaterialPrivate(QNormalDiffuseMapMaterial *qq)
+ : QMaterialPrivate(qq)
+ , m_normalDiffuseEffect(new QEffect())
+ , m_diffuseTexture(new QTexture(QTexture::Target2D))
+ , m_normalTexture(new QTexture(QTexture::Target2D))
+ , 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.95f, 0.95f, 0.95f, 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_diffuseTexture->setMagnificationFilter(QTexture::Linear);
+ m_diffuseTexture->setMinificationFilter(QTexture::LinearMipMapLinear);
+ m_diffuseTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_diffuseTexture->setGenerateMipMaps(true);
+ m_diffuseTexture->setMaximumAnisotropy(16.0f);
+
+ m_normalTexture->setMagnificationFilter(QTexture::Linear);
+ m_normalTexture->setMinificationFilter(QTexture::Linear);
+ m_normalTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_normalTexture->setMaximumAnisotropy(16.0f);
+}
+
+void QNormalDiffuseMapMaterialPrivate::init()
+{
+ 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->openGLFilter()->setApi(QOpenGLFilter::Desktop);
+ m_normalDiffuseGL3Technique->openGLFilter()->setMajorVersion(3);
+ m_normalDiffuseGL3Technique->openGLFilter()->setMinorVersion(1);
+ m_normalDiffuseGL3Technique->openGLFilter()->setProfile(QOpenGLFilter::Core);
+
+ m_normalDiffuseGL2Technique->openGLFilter()->setApi(QOpenGLFilter::Desktop);
+ m_normalDiffuseGL2Technique->openGLFilter()->setMajorVersion(2);
+ m_normalDiffuseGL2Technique->openGLFilter()->setMinorVersion(0);
+ m_normalDiffuseGL2Technique->openGLFilter()->setProfile(QOpenGLFilter::None);
+
+ m_normalDiffuseES2Technique->openGLFilter()->setApi(QOpenGLFilter::ES);
+ m_normalDiffuseES2Technique->openGLFilter()->setMajorVersion(2);
+ m_normalDiffuseES2Technique->openGLFilter()->setMinorVersion(0);
+ m_normalDiffuseES2Technique->openGLFilter()->setProfile(QOpenGLFilter::None);
+
+ m_normalDiffuseGL3RenderPass->setShaderProgram(m_normalDiffuseGL3Shader);
+ m_normalDiffuseGL2RenderPass->setShaderProgram(m_normalDiffuseGL2ES2Shader);
+ m_normalDiffuseES2RenderPass->setShaderProgram(m_normalDiffuseGL2ES2Shader);
+
+ m_normalDiffuseGL3Technique->addPass(m_normalDiffuseGL3RenderPass);
+ m_normalDiffuseGL2Technique->addPass(m_normalDiffuseGL2RenderPass);
+ m_normalDiffuseES2Technique->addPass(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);
+
+ static_cast<QMaterial *>(q_ptr)->setEffect(m_normalDiffuseEffect);
+}
+
+/*!
+ \class Qt3D::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.
+*/
+
+/*!
+ \fn Qt3D::QNormalDiffuseMapMaterial::QNormalDiffuseMapMaterial()
+ Constructs a new Qt3D::QNormalDiffuseMapMaterial instance with parent object \a parent.
+*/
+QNormalDiffuseMapMaterial::QNormalDiffuseMapMaterial(QNode *parent)
+ : QMaterial(*new QNormalDiffuseMapMaterialPrivate(this), parent)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ QObject::connect(d->m_ambientParameter, SIGNAL(valueChanged()), this, SIGNAL(ambientChanged()));
+ QObject::connect(d->m_diffuseParameter, SIGNAL(valueChanged()), this, SIGNAL(diffuseChanged()));
+ QObject::connect(d->m_normalParameter, SIGNAL(valueChanged()), this, SIGNAL(normalChanged()));
+ QObject::connect(d->m_specularParameter, SIGNAL(valueChanged()), this, SIGNAL(specularChanged()));
+ QObject::connect(d->m_shininessParameter, SIGNAL(valueChanged()), this, SIGNAL(shininessChanged()));
+ QObject::connect(d->m_textureScaleParameter, SIGNAL(valueChanged()), this, SIGNAL(textureScaleChanged()));
+ d->init();
+}
+
+QNormalDiffuseMapMaterial::QNormalDiffuseMapMaterial(QNormalDiffuseMapMaterialPrivate &dd, QNode *parent)
+ : QMaterial(dd, parent)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ QObject::connect(d->m_ambientParameter, SIGNAL(valueChanged()), this, SIGNAL(ambientChanged()));
+ QObject::connect(d->m_diffuseParameter, SIGNAL(valueChanged()), this, SIGNAL(diffuseChanged()));
+ QObject::connect(d->m_normalParameter, SIGNAL(valueChanged()), this, SIGNAL(normalChanged()));
+ QObject::connect(d->m_specularParameter, SIGNAL(valueChanged()), this, SIGNAL(specularChanged()));
+ QObject::connect(d->m_shininessParameter, SIGNAL(valueChanged()), this, SIGNAL(shininessChanged()));
+ QObject::connect(d->m_textureScaleParameter, SIGNAL(valueChanged()), this, SIGNAL(textureScaleChanged()));
+ d->init();
+}
+
+QNormalDiffuseMapMaterial::~QNormalDiffuseMapMaterial()
+{
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseMapMaterial::ambient() const
+ \return the current QColor ambient value.
+ */
+QColor QNormalDiffuseMapMaterial::ambient() const
+{
+ Q_D(const QNormalDiffuseMapMaterial);
+ return d->m_ambientParameter->value().value<QColor>();
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseMapMaterial::specular() const
+ \return the current QColor specular value.
+ */
+QColor QNormalDiffuseMapMaterial::specular() const
+{
+ Q_D(const QNormalDiffuseMapMaterial);
+ return d->m_specularParameter->value().value<QColor>();
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseMapMaterial::diffuse() const
+ \return the current diffuse map texture.
+ \b {Note:} By default the diffuse texture has a linear
+ magnification filter, a linear mipmap linear minification filter,
+ the wrap mode is repeat, the maximum anisotropy is set to 16.0
+ and mipmapping is enabled.
+ */
+QTexture *QNormalDiffuseMapMaterial::diffuse() const
+{
+ Q_D(const QNormalDiffuseMapMaterial);
+ return d->m_diffuseParameter->value().value<QTexture *>();
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseMapMaterial::normal() const
+ \return the current normal map texture.
+ \b {Note:} By default the normal texture has linear minification
+ and magnification filters, the wrap mode is repeat and maximum anisotropy
+ is set to 16.0.
+ */
+QTexture *QNormalDiffuseMapMaterial::normal() const
+{
+ Q_D(const QNormalDiffuseMapMaterial);
+ return d->m_normalParameter->value().value<QTexture *>();
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseMapMaterial::shininess() const
+ \return the current shininess as a float value.
+ */
+float QNormalDiffuseMapMaterial::shininess() const
+{
+ Q_D(const QNormalDiffuseMapMaterial);
+ return d->m_shininessParameter->value().toFloat();
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseMapMaterial::textureScale() const
+ \return the current texture scale.
+ */
+float QNormalDiffuseMapMaterial::textureScale() const
+{
+ Q_D(const QNormalDiffuseMapMaterial);
+ return d->m_textureScaleParameter->value().toFloat();
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseMapMaterial::setAmbient(const QColor &ambient)
+ Sets the current ambient color to \a ambient
+ */
+void QNormalDiffuseMapMaterial::setAmbient(const QColor &ambient)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ d->m_ambientParameter->setValue(ambient);
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseMapMaterial::setSpecular(const QColor &specular)
+ Sets the current specular color to \a specular.
+ */
+void QNormalDiffuseMapMaterial::setSpecular(const QColor &specular)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ d->m_specularParameter->setValue(specular);
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseMapMaterial::setDiffuse(QTexture *diffuse)
+ Sets the current diffuse map to \a diffuse.
+ */
+void QNormalDiffuseMapMaterial::setDiffuse(QTexture *diffuse)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ d->m_diffuseParameter->setValue(QVariant::fromValue(diffuse));
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseMapMaterial::setNormal(QTexture *normal)
+ Sets the current normal map to \a normal.
+ */
+void QNormalDiffuseMapMaterial::setNormal(QTexture *normal)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ d->m_normalParameter->setValue(QVariant::fromValue(normal));
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseMapMaterial::setShininess(float shininess)
+ Sets the current shininess value to \a shininess.
+ */
+void QNormalDiffuseMapMaterial::setShininess(float shininess)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ d->m_shininessParameter->setValue(shininess);
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseMapMaterial::setTextureScale(float textureScale)
+ Sets the current texture scale to \a textureScale.
+ */
+void QNormalDiffuseMapMaterial::setTextureScale(float textureScale)
+{
+ Q_D(QNormalDiffuseMapMaterial);
+ d->m_textureScaleParameter->setValue(textureScale);
+}
+
+} // Qt3D
+
+QT_END_NAMESPACE
diff --git a/src/render/defaults/qnormaldiffusemapmaterial.h b/src/render/defaults/qnormaldiffusemapmaterial.h
new file mode 100644
index 000000000..34c1cf7c3
--- /dev/null
+++ b/src/render/defaults/qnormaldiffusemapmaterial.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_RENDER_QNORMALDIFFUSEMAPMATERIAL_H
+#define QT3D_RENDER_QNORMALDIFFUSEMAPMATERIAL_H
+
+#include <Qt3DRenderer/qmaterial.h>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QTexture;
+class QNormalDiffuseMapMaterialPrivate;
+
+class QT3DRENDERERSHARED_EXPORT QNormalDiffuseMapMaterial : public 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(QTexture *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(QTexture *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(QNode *parent = 0);
+ ~QNormalDiffuseMapMaterial();
+
+ QColor ambient() const;
+ QColor specular() const;
+ QTexture *diffuse() const;
+ QTexture *normal() const;
+ float shininess() const;
+ float textureScale() const;
+
+ void setAmbient(const QColor &ambient);
+ void setSpecular(const QColor &specular);
+ void setDiffuse(QTexture *diffuse);
+ void setNormal(QTexture *normal);
+ void setShininess(float shininess);
+ void setTextureScale(float textureScale);
+
+Q_SIGNALS:
+ void ambientChanged();
+ void diffuseChanged();
+ void normalChanged();
+ void specularChanged();
+ void shininessChanged();
+ void textureScaleChanged();
+
+protected:
+ QNormalDiffuseMapMaterial(QNormalDiffuseMapMaterialPrivate &dd, QNode *parent = 0);
+
+private:
+ Q_DECLARE_PRIVATE(QNormalDiffuseMapMaterial)
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QNORMALDIFFUSEMAPMATERIAL_H
diff --git a/src/render/defaults/qnormaldiffusemapmaterial_p.h b/src/render/defaults/qnormaldiffusemapmaterial_p.h
new file mode 100644
index 000000000..0c11d3214
--- /dev/null
+++ b/src/render/defaults/qnormaldiffusemapmaterial_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_RENDER_QNORMALDIFFUSEMAPMATERIAL_P_H
+#define QT3D_RENDER_QNORMALDIFFUSEMAPMATERIAL_P_H
+
+#include <Qt3DRenderer/private/qmaterial_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QEffect;
+class QTexture;
+class QTechnique;
+class QParameter;
+class QShaderProgram;
+class QRenderPass;
+class QParameterMapping;
+
+class QNormalDiffuseMapMaterial;
+
+class QNormalDiffuseMapMaterialPrivate: public QMaterialPrivate
+{
+public:
+ QNormalDiffuseMapMaterialPrivate(QNormalDiffuseMapMaterial *qq);
+
+ virtual void init();
+
+ QEffect *m_normalDiffuseEffect;
+ QTexture *m_diffuseTexture;
+ QTexture *m_normalTexture;
+ QParameter *m_ambientParameter;
+ QParameter *m_diffuseParameter;
+ QParameter *m_normalParameter;
+ QParameter *m_specularParameter;
+ QParameter *m_shininessParameter;
+ QParameter *m_textureScaleParameter;
+ QTechnique *m_normalDiffuseGL3Technique;
+ QTechnique *m_normalDiffuseGL2Technique;
+ QTechnique *m_normalDiffuseES2Technique;
+ QRenderPass *m_normalDiffuseGL3RenderPass;
+ QRenderPass *m_normalDiffuseGL2RenderPass;
+ QRenderPass *m_normalDiffuseES2RenderPass;
+ QShaderProgram *m_normalDiffuseGL3Shader;
+ QShaderProgram *m_normalDiffuseGL2ES2Shader;
+
+ Q_DECLARE_PUBLIC(QNormalDiffuseMapMaterial)
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_RENDER_QNORMALDIFFUSEMAPMATERIAL_P_H
+
diff --git a/src/render/defaults/qnormaldiffusespecularmapmaterial.cpp b/src/render/defaults/qnormaldiffusespecularmapmaterial.cpp
new file mode 100644
index 000000000..d15d1efae
--- /dev/null
+++ b/src/render/defaults/qnormaldiffusespecularmapmaterial.cpp
@@ -0,0 +1,330 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qnormaldiffusespecularmapmaterial.h"
+#include "qnormaldiffusespecularmapmaterial_p.h"
+#include <Qt3DRenderer/qmaterial.h>
+#include <Qt3DRenderer/qeffect.h>
+#include <Qt3DRenderer/qtexture.h>
+#include <Qt3DRenderer/qtechnique.h>
+#include <Qt3DRenderer/qshaderprogram.h>
+#include <Qt3DRenderer/qparameter.h>
+#include <Qt3DRenderer/qrenderpass.h>
+#include <Qt3DRenderer/qopenglfilter.h>
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+QNormalDiffuseSpecularMapMaterialPrivate::QNormalDiffuseSpecularMapMaterialPrivate(QNormalDiffuseSpecularMapMaterial *qq)
+ : QMaterialPrivate(qq)
+ , m_normalDiffuseSpecularEffect(new QEffect())
+ , m_diffuseTexture(new QTexture(QTexture::Target2D))
+ , m_normalTexture(new QTexture(QTexture::Target2D))
+ , m_specularTexture(new QTexture(QTexture::Target2D))
+ , 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_diffuseTexture->setMagnificationFilter(QTexture::Linear);
+ m_diffuseTexture->setMinificationFilter(QTexture::LinearMipMapLinear);
+ m_diffuseTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_diffuseTexture->setGenerateMipMaps(true);
+ m_diffuseTexture->setMaximumAnisotropy(16.0f);
+
+ m_normalTexture->setMagnificationFilter(QTexture::Linear);
+ m_normalTexture->setMinificationFilter(QTexture::Linear);
+ m_normalTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_normalTexture->setMaximumAnisotropy(16.0f);
+
+ m_specularTexture->setMagnificationFilter(QTexture::Linear);
+ m_specularTexture->setMinificationFilter(QTexture::LinearMipMapLinear);
+ m_specularTexture->setWrapMode(QTextureWrapMode(QTextureWrapMode::Repeat));
+ m_specularTexture->setGenerateMipMaps(true);
+ m_specularTexture->setMaximumAnisotropy(16.0f);
+}
+
+void QNormalDiffuseSpecularMapMaterialPrivate::init()
+{
+ m_normalDiffuseSpecularGL3Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/normaldiffusespecularmap.vert"))));
+ m_normalDiffuseSpecularGL3Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/gl3/normaldiffusespecularmap.frag"))));
+ m_normalDiffuseSpecularGL2ES2Shader->setVertexShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/normaldiffusespecularmap.vert"))));
+ m_normalDiffuseSpecularGL2ES2Shader->setFragmentShaderCode(QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/shaders/es2/normaldiffusespecularmap.frag"))));
+
+ m_normalDiffuseSpecularGL3Technique->openGLFilter()->setApi(QOpenGLFilter::Desktop);
+ m_normalDiffuseSpecularGL3Technique->openGLFilter()->setMajorVersion(3);
+ m_normalDiffuseSpecularGL3Technique->openGLFilter()->setMinorVersion(1);
+ m_normalDiffuseSpecularGL3Technique->openGLFilter()->setProfile(QOpenGLFilter::Core);
+
+ m_normalDiffuseSpecularGL2Technique->openGLFilter()->setApi(QOpenGLFilter::Desktop);
+ m_normalDiffuseSpecularGL2Technique->openGLFilter()->setMajorVersion(2);
+ m_normalDiffuseSpecularGL2Technique->openGLFilter()->setMinorVersion(0);
+ m_normalDiffuseSpecularGL2Technique->openGLFilter()->setProfile(QOpenGLFilter::None);
+
+ m_normalDiffuseSpecularES2Technique->openGLFilter()->setApi(QOpenGLFilter::ES);
+ m_normalDiffuseSpecularES2Technique->openGLFilter()->setMajorVersion(2);
+ m_normalDiffuseSpecularES2Technique->openGLFilter()->setMinorVersion(0);
+ m_normalDiffuseSpecularES2Technique->openGLFilter()->setProfile(QOpenGLFilter::None);
+
+ m_normalDiffuseSpecularGL3RenderPass->setShaderProgram(m_normalDiffuseSpecularGL3Shader);
+ m_normalDiffuseSpecularGL2RenderPass->setShaderProgram(m_normalDiffuseSpecularGL2ES2Shader);
+ m_normalDiffuseSpecularES2RenderPass->setShaderProgram(m_normalDiffuseSpecularGL2ES2Shader);
+
+ m_normalDiffuseSpecularGL3Technique->addPass(m_normalDiffuseSpecularGL3RenderPass);
+ m_normalDiffuseSpecularGL2Technique->addPass(m_normalDiffuseSpecularGL2RenderPass);
+ m_normalDiffuseSpecularES2Technique->addPass(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);
+
+ static_cast<QMaterial *>(q_ptr)->setEffect(m_normalDiffuseSpecularEffect);
+}
+
+/*!
+ \class Qt3D::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.
+*/
+
+/*!
+ \fn Qt3D::QNormalDiffuseSpecularMapMaterial::QNormalDiffuseSpecularMapMaterial()
+ Constructs a new Qt3D::QNormalDiffuseSpecularMapMaterial instance with parent object \a parent.
+*/
+QNormalDiffuseSpecularMapMaterial::QNormalDiffuseSpecularMapMaterial(QNode *parent)
+ : QMaterial(*new QNormalDiffuseSpecularMapMaterialPrivate(this), parent)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ QObject::connect(d->m_ambientParameter, SIGNAL(valueChanged()), this, SIGNAL(ambientChanged()));
+ QObject::connect(d->m_diffuseParameter, SIGNAL(valueChanged()), this, SIGNAL(diffuseChanged()));
+ QObject::connect(d->m_normalParameter, SIGNAL(valueChanged()), this, SIGNAL(normalChanged()));
+ QObject::connect(d->m_specularParameter, SIGNAL(valueChanged()), this, SIGNAL(specularChanged()));
+ QObject::connect(d->m_shininessParameter, SIGNAL(valueChanged()), this, SIGNAL(shininessChanged()));
+ QObject::connect(d->m_textureScaleParameter, SIGNAL(valueChanged()), this, SIGNAL(textureScaleChanged()));
+ d->init();
+}
+
+
+QNormalDiffuseSpecularMapMaterial::QNormalDiffuseSpecularMapMaterial(QNormalDiffuseSpecularMapMaterialPrivate &dd, QNode *parent)
+ : QMaterial(dd, parent)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ QObject::connect(d->m_ambientParameter, SIGNAL(valueChanged()), this, SIGNAL(ambientChanged()));
+ QObject::connect(d->m_diffuseParameter, SIGNAL(valueChanged()), this, SIGNAL(diffuseChanged()));
+ QObject::connect(d->m_normalParameter, SIGNAL(valueChanged()), this, SIGNAL(normalChanged()));
+ QObject::connect(d->m_specularParameter, SIGNAL(valueChanged()), this, SIGNAL(specularChanged()));
+ QObject::connect(d->m_shininessParameter, SIGNAL(valueChanged()), this, SIGNAL(shininessChanged()));
+ QObject::connect(d->m_textureScaleParameter, SIGNAL(valueChanged()), this, SIGNAL(textureScaleChanged()));
+ d->init();
+}
+
+QNormalDiffuseSpecularMapMaterial::~QNormalDiffuseSpecularMapMaterial()
+{
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseSpecularMapMaterial::ambient() const
+ \return the current QColor ambient value.
+ */
+QColor QNormalDiffuseSpecularMapMaterial::ambient() const
+{
+ Q_D(const QNormalDiffuseSpecularMapMaterial);
+ return d->m_ambientParameter->value().value<QColor>();
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseSpecularMapMaterial::diffuse() const
+ \return the current diffuse map texture.
+ \b {Note:} By default the diffuse texture has a linear
+ magnification filter, a linear mipmap linear minification filter,
+ the wrap mode is repeat, the maximum anisotropy is set to 16.0
+ and mipmapping is enabled.
+ */
+QTexture *QNormalDiffuseSpecularMapMaterial::diffuse() const
+{
+ Q_D(const QNormalDiffuseSpecularMapMaterial);
+ return d->m_diffuseParameter->value().value<QTexture *>();
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseSpecularMapMaterial::normal() const
+ \return the current normal map texture.
+ \b {Note:} By default the normal texture has linear minification
+ and magnification filters, the wrap mode is repeat and maximum anisotropy
+ is set to 16.0.
+ */
+QTexture *QNormalDiffuseSpecularMapMaterial::normal() const
+{
+ Q_D(const QNormalDiffuseSpecularMapMaterial);
+ return d->m_normalParameter->value().value<QTexture *>();
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseSpecularMapMaterial::specular() const
+ \return the current specular map texture.
+ \b {Note:} By default the specular texture has a linear
+ magnification filter, a linear mipmap linear minification filter,
+ the wrap mode is repeat, the maximum anisotropy is set to 16.0
+ and mipmapping is enabled.
+ */
+QTexture *QNormalDiffuseSpecularMapMaterial::specular() const
+{
+ Q_D(const QNormalDiffuseSpecularMapMaterial);
+ return d->m_specularParameter->value().value<QTexture *>();
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseSpecularMapMaterial::shininess() const
+ \return the current shininess as a float value.
+ */
+float QNormalDiffuseSpecularMapMaterial::shininess() const
+{
+ Q_D(const QNormalDiffuseSpecularMapMaterial);
+ return d->m_shininessParameter->value().toFloat();
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseSpecularMapMaterial::textureScale() const
+ \return the current texture scale.
+ */
+float QNormalDiffuseSpecularMapMaterial::textureScale() const
+{
+ Q_D(const QNormalDiffuseSpecularMapMaterial);
+ return d->m_textureScaleParameter->value().toFloat();
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseSpecularMapMaterial::setAmbient(const QColor &ambient)
+ Sets the current ambient color to \a ambient
+ */
+void QNormalDiffuseSpecularMapMaterial::setAmbient(const QColor &ambient)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ d->m_ambientParameter->setValue(ambient);
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseSpecularMapMaterial::setDiffuse(QTexture *diffuse)
+ Sets the current diffuse map to \a diffuse.
+ */
+void QNormalDiffuseSpecularMapMaterial::setDiffuse(QTexture *diffuse)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ d->m_diffuseParameter->setValue(QVariant::fromValue(diffuse));
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseSpecularMapMaterial::setNormal(QTexture *normal)
+ Sets the current normal map to \a normal.
+ */
+void QNormalDiffuseSpecularMapMaterial::setNormal(QTexture *normal)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ d->m_normalParameter->setValue(QVariant::fromValue(normal));
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseSpecularMapMaterial::setSpecular(QTexture *specular)
+ Sets the current specular map to \a specular.
+ */
+void QNormalDiffuseSpecularMapMaterial::setSpecular(QTexture *specular)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ d->m_specularParameter->setValue(QVariant::fromValue(specular));
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseSpecularMapMaterial::setShininess(float shininess)
+ Sets the current shininess value to \a shininess.
+ */
+void QNormalDiffuseSpecularMapMaterial::setShininess(float shininess)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ d->m_shininessParameter->setValue(shininess);
+}
+
+/*!
+ \fn Qt3D::QNormalDiffuseSpecularMapMaterial::setTextureScale(float textureScale)
+ Sets the current texture scale to \a textureScale.
+ */
+void QNormalDiffuseSpecularMapMaterial::setTextureScale(float textureScale)
+{
+ Q_D(QNormalDiffuseSpecularMapMaterial);
+ d->m_textureScaleParameter->setValue(textureScale);
+}
+
+} // Qt3D
+
+QT_END_NAMESPACE
diff --git a/src/render/defaults/qnormaldiffusespecularmapmaterial.h b/src/render/defaults/qnormaldiffusespecularmapmaterial.h
new file mode 100644
index 000000000..1694fe290
--- /dev/null
+++ b/src/render/defaults/qnormaldiffusespecularmapmaterial.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_RENDER_QNORMALDIFFUSESPECULARMAPMATERIAL_H
+#define QT3D_RENDER_QNORMALDIFFUSESPECULARMAPMATERIAL_H
+
+#include <Qt3DRenderer/qmaterial.h>
+#include <QColor>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QNormalDiffuseSpecularMapMaterialPrivate;
+
+class QT3DRENDERERSHARED_EXPORT QNormalDiffuseSpecularMapMaterial : public QMaterial
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor ambient READ ambient WRITE setAmbient NOTIFY ambientChanged)
+ Q_PROPERTY(QTexture *diffuse READ diffuse WRITE setDiffuse NOTIFY diffuseChanged)
+ Q_PROPERTY(QTexture *normal READ normal WRITE setNormal NOTIFY normalChanged)
+ Q_PROPERTY(QTexture *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(QNode *parent = 0);
+ ~QNormalDiffuseSpecularMapMaterial();
+
+ QColor ambient() const;
+ QTexture *diffuse() const;
+ QTexture *normal() const;
+ QTexture *specular() const;
+ float shininess() const;
+ float textureScale() const;
+
+ void setAmbient(const QColor &ambient);
+ void setDiffuse(QTexture *diffuse);
+ void setNormal(QTexture *normal);
+ void setSpecular(QTexture *specular);
+ void setShininess(float shininess);
+ void setTextureScale(float textureScale);
+
+Q_SIGNALS:
+ void ambientChanged();
+ void diffuseChanged();
+ void normalChanged();
+ void specularChanged();
+ void shininessChanged();
+ void textureScaleChanged();
+
+protected:
+ QNormalDiffuseSpecularMapMaterial(QNormalDiffuseSpecularMapMaterialPrivate &dd, QNode *parent = 0);
+
+private:
+ Q_DECLARE_PRIVATE(QNormalDiffuseSpecularMapMaterial)
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_RENDER_QNORMALDIFFUSESPECULARMAPMATERIAL_H
diff --git a/src/render/defaults/qnormaldiffusespecularmapmaterial_p.h b/src/render/defaults/qnormaldiffusespecularmapmaterial_p.h
new file mode 100644
index 000000000..5ea89140c
--- /dev/null
+++ b/src/render/defaults/qnormaldiffusespecularmapmaterial_p.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_RENDER_QNORMALDIFFUSESPECULARMAPMATERIAL_P_H
+#define QT3D_RENDER_QNORMALDIFFUSESPECULARMAPMATERIAL_P_H
+
+#include <Qt3DRenderer/private/qmaterial_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QEffect;
+class QTexture;
+class QTechnique;
+class QParameter;
+class QShaderProgram;
+class QRenderPass;
+class QParameterMapping;
+
+class QNormalDiffuseSpecularMapMaterial;
+
+class QNormalDiffuseSpecularMapMaterialPrivate : public QMaterialPrivate
+{
+public:
+ QNormalDiffuseSpecularMapMaterialPrivate(QNormalDiffuseSpecularMapMaterial *qq);
+
+ void init();
+
+ QEffect *m_normalDiffuseSpecularEffect;
+ QTexture *m_diffuseTexture;
+ QTexture *m_normalTexture;
+ QTexture *m_specularTexture;
+ QParameter *m_ambientParameter;
+ QParameter *m_diffuseParameter;
+ QParameter *m_normalParameter;
+ QParameter *m_specularParameter;
+ QParameter *m_shininessParameter;
+ QParameter *m_textureScaleParameter;
+ QTechnique *m_normalDiffuseSpecularGL3Technique;
+ QTechnique *m_normalDiffuseSpecularGL2Technique;
+ QTechnique *m_normalDiffuseSpecularES2Technique;
+ QRenderPass *m_normalDiffuseSpecularGL3RenderPass;
+ QRenderPass *m_normalDiffuseSpecularGL2RenderPass;
+ QRenderPass *m_normalDiffuseSpecularES2RenderPass;
+ QShaderProgram *m_normalDiffuseSpecularGL3Shader;
+ QShaderProgram *m_normalDiffuseSpecularGL2ES2Shader;
+
+ Q_DECLARE_PUBLIC(QNormalDiffuseSpecularMapMaterial)
+};
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_RENDER_QNORMALDIFFUSESPECULARMAPMATERIAL_P_H
+
diff --git a/src/render/defaults/qphongmaterial.cpp b/src/render/defaults/qphongmaterial.cpp
index 87c88ef54..269de6a79 100644
--- a/src/render/defaults/qphongmaterial.cpp
+++ b/src/render/defaults/qphongmaterial.cpp
@@ -48,7 +48,6 @@
#include <Qt3DRenderer/qparameter.h>
#include <Qt3DRenderer/qrenderpass.h>
#include <Qt3DRenderer/qopenglfilter.h>
-#include <Qt3DRenderer/qparametermapping.h>
#include <QUrl>
QT_BEGIN_NAMESPACE
@@ -58,9 +57,9 @@ namespace Qt3D {
QPhongMaterialPrivate::QPhongMaterialPrivate(QPhongMaterial *qq)
: QMaterialPrivate(qq)
, m_phongEffect(new QEffect())
- , m_ambientParameter(new QParameter(QStringLiteral("ambient"), QColor::fromRgbF(0.05f, 0.05f, 0.05f, 1.0f)))
- , m_diffuseParameter(new QParameter(QStringLiteral("diffuse"), QColor::fromRgbF(0.7f, 0.7f, 0.7f, 1.0f)))
- , m_specularParameter(new QParameter(QStringLiteral("specular"), QColor::fromRgbF(0.95f, 0.95f, 0.95f, 1.0f)))
+ , 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.95f, 0.95f, 0.95f, 1.0f)))
, m_shininessParameter(new QParameter(QStringLiteral("shininess"), 150.0f))
, m_phongGL3Technique(new QTechnique())
, m_phongGL2Technique(new QTechnique())
@@ -70,9 +69,6 @@ QPhongMaterialPrivate::QPhongMaterialPrivate(QPhongMaterial *qq)
, m_phongES2RenderPass(new QRenderPass())
, m_phongGL3Shader(new QShaderProgram())
, m_phongGL2ES2Shader(new QShaderProgram())
- , m_ambientParameterMapping(new QParameterMapping(QStringLiteral("ambient"), QStringLiteral("ka"), QParameterMapping::Uniform))
- , m_diffuseParameterMapping(new QParameterMapping(QStringLiteral("diffuse"), QStringLiteral("kd"), QParameterMapping::Uniform))
- , m_specularParameterMapping(new QParameterMapping(QStringLiteral("specular"), QStringLiteral("ks"), QParameterMapping::Uniform))
{
}
@@ -95,7 +91,7 @@ QPhongMaterialPrivate::QPhongMaterialPrivate(QPhongMaterial *qq)
/*!
\fn QPhongMaterial::QPhongMaterial
- Contrusts a new QPhongMaterial instance.
+ Constructs a new QPhongMaterial instance with parent object \a parent.
*/
QPhongMaterial::QPhongMaterial(QNode *parent)
: QMaterial(*new QPhongMaterialPrivate(this), parent)
@@ -154,12 +150,12 @@ float QPhongMaterial::shininess() const
/*!
\fn QPhongMaterial::setAmbient
- Sets the current ambient color to \a color.
+ Sets the current ambient color to \a ambient.
*/
-void QPhongMaterial::setAmbient(const QColor &color)
+void QPhongMaterial::setAmbient(const QColor &ambient)
{
Q_D(QPhongMaterial);
- d->m_shininessParameter->setValue(color);
+ d->m_shininessParameter->setValue(ambient);
}
/*!
@@ -174,7 +170,7 @@ void QPhongMaterial::setDiffuse(const QColor &diffuse)
/*!
\fn QPhongMaterial::setSpecular
- Sets the current specular color to \a color.
+ Sets the current specular color to \a specular.
*/
void QPhongMaterial::setSpecular(const QColor &specular)
{
@@ -217,19 +213,8 @@ void QPhongMaterialPrivate::init()
m_phongES2Technique->openGLFilter()->setProfile(QOpenGLFilter::None);
m_phongGL3RenderPass->setShaderProgram(m_phongGL3Shader);
- m_phongGL3RenderPass->addBinding(m_ambientParameterMapping);
- m_phongGL3RenderPass->addBinding(m_diffuseParameterMapping);
- m_phongGL3RenderPass->addBinding(m_specularParameterMapping);
-
m_phongGL2RenderPass->setShaderProgram(m_phongGL2ES2Shader);
- m_phongGL2RenderPass->addBinding(m_ambientParameterMapping);
- m_phongGL2RenderPass->addBinding(m_diffuseParameterMapping);
- m_phongGL2RenderPass->addBinding(m_specularParameterMapping);
-
m_phongES2RenderPass->setShaderProgram(m_phongGL2ES2Shader);
- m_phongES2RenderPass->addBinding(m_ambientParameterMapping);
- m_phongES2RenderPass->addBinding(m_diffuseParameterMapping);
- m_phongES2RenderPass->addBinding(m_specularParameterMapping);
m_phongGL3Technique->addPass(m_phongGL3RenderPass);
m_phongGL2Technique->addPass(m_phongGL2RenderPass);
diff --git a/src/render/defaults/qphongmaterial.h b/src/render/defaults/qphongmaterial.h
index 49f677567..ce2f4dc07 100644
--- a/src/render/defaults/qphongmaterial.h
+++ b/src/render/defaults/qphongmaterial.h
@@ -60,7 +60,7 @@ class QT3DRENDERERSHARED_EXPORT QPhongMaterial : public QMaterial
Q_PROPERTY(float shininess READ shininess WRITE setShininess NOTIFY shininessChanged)
public:
- QPhongMaterial(QNode *parent = 0);
+ explicit QPhongMaterial(QNode *parent = 0);
~QPhongMaterial();
QColor ambient() const;
diff --git a/src/render/defaults/qphongmaterial_p.h b/src/render/defaults/qphongmaterial_p.h
index 421a4c475..ab1a83a3b 100644
--- a/src/render/defaults/qphongmaterial_p.h
+++ b/src/render/defaults/qphongmaterial_p.h
@@ -59,6 +59,7 @@ class QPhongMaterial;
class QPhongMaterialPrivate : public QMaterialPrivate
{
+public:
QPhongMaterialPrivate(QPhongMaterial *qq);
void init();
@@ -76,9 +77,6 @@ class QPhongMaterialPrivate : public QMaterialPrivate
QRenderPass *m_phongES2RenderPass;
QShaderProgram *m_phongGL3Shader;
QShaderProgram *m_phongGL2ES2Shader;
- QParameterMapping *m_ambientParameterMapping;
- QParameterMapping *m_diffuseParameterMapping;
- QParameterMapping *m_specularParameterMapping;
Q_DECLARE_PUBLIC(QPhongMaterial)
};