summaryrefslogtreecommitdiffstats
path: root/src/render/defaults/qphongmaterial.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-02-02 14:03:09 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-02-02 15:33:35 +0000
commit43bb067fc3ec8217ba1064169d9ffdc7e21af7d5 (patch)
treeaae78d3fc5845b3e0220c3a2f3e04dd8d3476e16 /src/render/defaults/qphongmaterial.cpp
parent75832ffd01c64e30d43e5ff4d13a879750e00cbb (diff)
Remove default uniform values for lightPosition and intensity
The ES2 variants of the shaders have a default uniform value of 0. To be compatible with the other versions, start specifying the values for lightPosition and Intensity from C++, just like we already do from QML. This way the default values are coming from one single unified place regardless of the shader version in use, and examples like simple-cpp will work identically to simple-qml, even on ES2. Change-Id: If60185d0d3039e4354da8cc6e6b21a0db0bae963 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/defaults/qphongmaterial.cpp')
-rw-r--r--src/render/defaults/qphongmaterial.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/render/defaults/qphongmaterial.cpp b/src/render/defaults/qphongmaterial.cpp
index 8b0d8f7a6..03b9dcb3a 100644
--- a/src/render/defaults/qphongmaterial.cpp
+++ b/src/render/defaults/qphongmaterial.cpp
@@ -49,6 +49,8 @@
#include <Qt3DRenderer/qrenderpass.h>
#include <Qt3DRenderer/qopenglfilter.h>
#include <QUrl>
+#include <QVector3D>
+#include <QVector4D>
QT_BEGIN_NAMESPACE
@@ -61,6 +63,8 @@ QPhongMaterialPrivate::QPhongMaterialPrivate(QPhongMaterial *qq)
, 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_lightPositionParameter(new QParameter(QStringLiteral("lightPosition"), QVector4D(1.0f, 1.0f, 0.0f, 1.0f)))
+ , m_lightIntensityParameter(new QParameter(QStringLiteral("lightIntensity"), QVector3D(1.0f, 1.0f, 1.0f)))
, m_phongGL3Technique(new QTechnique())
, m_phongGL2Technique(new QTechnique())
, m_phongES2Technique(new QTechnique())
@@ -244,6 +248,8 @@ void QPhongMaterialPrivate::init()
m_phongEffect->addParameter(m_diffuseParameter);
m_phongEffect->addParameter(m_specularParameter);
m_phongEffect->addParameter(m_shininessParameter);
+ m_phongEffect->addParameter(m_lightPositionParameter);
+ m_phongEffect->addParameter(m_lightIntensityParameter);
static_cast<QMaterial *>(q_ptr)->setEffect(m_phongEffect);
}