summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2014-01-20 09:43:57 +0200
committerTomi Korpipää <tomi.korpipaa@digia.com>2014-01-20 09:49:03 +0200
commit51deca1429e1097be3108a5dc28a4897944fed1a (patch)
tree2c6f5240c2a01d6e793aa03249c17d0cbaa9b455 /src
parent631b1913f4115fc163a21fc8aba85b87b10a666a (diff)
References to alpha and TP removed
+ implemented the rest of lightColor Task-number: QTRD-2405 Change-Id: I38402b45cc4a567a79d07b23983567551d06b4fe Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/datavisualization/doc/src/qtdatavisualization-index.qdoc3
-rw-r--r--src/datavisualization/engine/bars3drenderer.cpp17
-rw-r--r--src/datavisualization/engine/scatter3drenderer.cpp19
-rw-r--r--src/datavisualization/engine/selectionpointer.cpp5
-rw-r--r--src/datavisualization/engine/shaders/colorOnY.frag5
-rw-r--r--src/datavisualization/engine/shaders/colorOnY_ES2.frag5
-rw-r--r--src/datavisualization/engine/shaders/default.frag5
-rw-r--r--src/datavisualization/engine/shaders/default_ES2.frag5
-rw-r--r--src/datavisualization/engine/shaders/shadow.frag5
-rw-r--r--src/datavisualization/engine/shaders/shadowNoTex.frag5
-rw-r--r--src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag5
-rw-r--r--src/datavisualization/engine/shaders/surface.frag5
-rw-r--r--src/datavisualization/engine/shaders/surfaceFlat.frag5
-rw-r--r--src/datavisualization/engine/shaders/surfaceShadowFlat.frag5
-rw-r--r--src/datavisualization/engine/shaders/surfaceShadowNoTex.frag5
-rw-r--r--src/datavisualization/engine/shaders/surface_ES2.frag5
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp30
-rw-r--r--src/datavisualization/theme/q3dtheme.cpp7
-rw-r--r--src/datavisualization/theme/q3dtheme.h3
-rw-r--r--src/datavisualization/utils/shaderhelper.cpp8
-rw-r--r--src/datavisualization/utils/shaderhelper_p.h2
21 files changed, 106 insertions, 48 deletions
diff --git a/src/datavisualization/doc/src/qtdatavisualization-index.qdoc b/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
index c37d98a4..e7bcc3d2 100644
--- a/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
+++ b/src/datavisualization/doc/src/qtdatavisualization-index.qdoc
@@ -33,8 +33,7 @@
\li QML2 support
\li Customizable axes for data - control viewable data window with axis ranges
\li Customizable input handling
- \li Customizable scene handling - full control of viewports
- (upcoming feature - not fully supported in alpha)
+ \li Customizable scene handling
\li Customizable themes
\endlist
diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp
index 133ecea2..e7fcf57e 100644
--- a/src/datavisualization/engine/bars3drenderer.cpp
+++ b/src/datavisualization/engine/bars3drenderer.cpp
@@ -275,6 +275,7 @@ void Bars3DRenderer::drawSlicedScene()
{
GLfloat barPosX = 0;
QVector3D lightPos;
+ QVector3D lightColor = Utils::vectorFromColor(m_cachedTheme->lightColor());
// Specify viewport
glViewport(m_secondarySubViewport.x(),
@@ -330,6 +331,7 @@ void Bars3DRenderer::drawSlicedScene()
lineShader->setUniformValue(lineShader->ambientS(),
m_cachedTheme->ambientLightStrength() * 2.3f);
lineShader->setUniformValue(lineShader->lightS(), 0.0f);
+ lineShader->setUniformValue(lineShader->lightColor(), lightColor);
if (rowMode)
scaleFactor = (1.1f * m_rowWidth) / m_scaleFactor;
@@ -441,6 +443,7 @@ void Bars3DRenderer::drawSlicedScene()
m_barShader->setUniformValue(m_barShader->lightS(), 0.15f);
m_barShader->setUniformValue(m_barShader->ambientS(),
m_cachedTheme->ambientLightStrength() * 2.3f);
+ m_barShader->setUniformValue(m_barShader->lightColor(), lightColor);
m_barGradientShader->bind();
m_barGradientShader->setUniformValue(m_barGradientShader->lightP(), lightPos);
m_barGradientShader->setUniformValue(m_barGradientShader->view(), viewMatrix);
@@ -448,6 +451,7 @@ void Bars3DRenderer::drawSlicedScene()
m_barGradientShader->setUniformValue(m_barGradientShader->ambientS(),
m_cachedTheme->ambientLightStrength() * 2.3f);
m_barGradientShader->setUniformValue(m_barGradientShader->gradientMin(), 0.0f);
+ m_barGradientShader->setUniformValue(m_barGradientShader->lightColor(), lightColor);
// Default to uniform shader
ShaderHelper *barShader = m_barShader;
@@ -711,6 +715,8 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
GLfloat colPos = 0;
GLfloat rowPos = 0;
+ QVector3D lightColor = Utils::vectorFromColor(m_cachedTheme->lightColor());
+
int seriesCount = m_visibleSeriesList.size();
const Q3DCamera *activeCamera = m_cachedScene->activeCamera();
@@ -722,7 +728,8 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
// Set up projection matrix
QMatrix4x4 projectionMatrix;
- GLfloat viewPortRatio = (GLfloat)m_primarySubViewport.width() / (GLfloat)m_primarySubViewport.height();
+ GLfloat viewPortRatio = (GLfloat)m_primarySubViewport.width()
+ / (GLfloat)m_primarySubViewport.height();
projectionMatrix.perspective(45.0f, viewPortRatio, 0.1f, 100.0f);
// Get the view matrix
@@ -1026,6 +1033,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
m_barGradientShader->setUniformValue(m_barGradientShader->ambientS(),
m_cachedTheme->ambientLightStrength());
m_barGradientShader->setUniformValue(m_barGradientShader->gradientMin(), 0.0f);
+ m_barGradientShader->setUniformValue(m_barGradientShader->lightColor(), lightColor);
}
if (haveUniformColorSeries) {
@@ -1034,6 +1042,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
m_barShader->setUniformValue(m_barShader->view(), viewMatrix);
m_barShader->setUniformValue(m_barShader->ambientS(),
m_cachedTheme->ambientLightStrength());
+ m_barShader->setUniformValue(m_barShader->lightColor(), lightColor);
barShader = m_barShader;
} else {
barShader = m_barGradientShader;
@@ -1264,6 +1273,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
barShader->setUniformValue(barShader->shadowQ(), m_shadowQualityToShader);
barShader->setUniformValue(barShader->depth(), depthMVPMatrix);
barShader->setUniformValue(barShader->lightS(), shadowLightStrength);
+ barShader->setUniformValue(barShader->lightColor(), lightColor);
// Draw the object
m_drawer->drawObject(barShader, barObj, gradientTexture, m_depthTexture);
@@ -1326,6 +1336,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
m_backgroundShader->setUniformValue(m_backgroundShader->color(), backgroundColor);
m_backgroundShader->setUniformValue(m_backgroundShader->ambientS(),
m_cachedTheme->ambientLightStrength() * 2.0f);
+ m_backgroundShader->setUniformValue(m_backgroundShader->lightColor(), lightColor);
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
@@ -1408,6 +1419,7 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
lineShader->setUniformValue(lineShader->view(), viewMatrix);
lineShader->setUniformValue(lineShader->color(), barColor);
lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme->ambientLightStrength());
+ lineShader->setUniformValue(lineShader->lightColor(), lightColor);
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
// Set shadowed shader bindings
@@ -1821,7 +1833,8 @@ void Bars3DRenderer::drawScene(GLuint defaultFboHandle)
labelText.replace(valueLabelTag, valueLabelText);
}
- labelText.replace(seriesNameTag, m_visibleSeriesList[m_visualSelectedBarSeriesIndex].name());
+ labelText.replace(seriesNameTag,
+ m_visibleSeriesList[m_visualSelectedBarSeriesIndex].name());
selectedBar->setSelectionLabel(labelText);
m_selectionLabelDirty = false;
diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp
index ce9560c8..22910756 100644
--- a/src/datavisualization/engine/scatter3drenderer.cpp
+++ b/src/datavisualization/engine/scatter3drenderer.cpp
@@ -258,6 +258,8 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
const Q3DCamera *activeCamera = m_cachedScene->activeCamera();
+ QVector3D lightColor = Utils::vectorFromColor(m_cachedTheme->lightColor());
+
// Specify viewport
glViewport(m_primarySubViewport.x(),
m_primarySubViewport.y(),
@@ -266,7 +268,8 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
// Set up projection matrix
QMatrix4x4 projectionMatrix;
- GLfloat viewPortRatio = (GLfloat)m_primarySubViewport.width() / (GLfloat)m_primarySubViewport.height();
+ GLfloat viewPortRatio = (GLfloat)m_primarySubViewport.width()
+ / (GLfloat)m_primarySubViewport.height();
projectionMatrix.perspective(45.0f, viewPortRatio, 0.1f, 100.0f);
// Calculate view matrix
@@ -608,6 +611,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
m_dotGradientShader->setUniformValue(m_dotGradientShader->view(), viewMatrix);
m_dotGradientShader->setUniformValue(m_dotGradientShader->ambientS(),
m_cachedTheme->ambientLightStrength());
+ m_dotGradientShader->setUniformValue(m_dotGradientShader->lightColor(), lightColor);
}
if (haveUniformColorMeshSeries) {
m_dotShader->bind();
@@ -615,6 +619,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
m_dotShader->setUniformValue(m_dotShader->view(), viewMatrix);
m_dotShader->setUniformValue(m_dotShader->ambientS(),
m_cachedTheme->ambientLightStrength());
+ m_dotShader->setUniformValue(m_dotShader->lightColor(), lightColor);
dotShader = m_dotShader;
} else {
dotShader = m_dotGradientShader;
@@ -829,6 +834,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
m_backgroundShader->setUniformValue(m_backgroundShader->color(), backgroundColor);
m_backgroundShader->setUniformValue(m_backgroundShader->ambientS(),
m_cachedTheme->ambientLightStrength() * 2.0f);
+ m_backgroundShader->setUniformValue(m_backgroundShader->lightColor(), lightColor);
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
@@ -878,6 +884,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
lineShader->setUniformValue(lineShader->view(), viewMatrix);
lineShader->setUniformValue(lineShader->color(), lineColor);
lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme->ambientLightStrength());
+ lineShader->setUniformValue(lineShader->lightColor(), lightColor);
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
// Set shadowed shader bindings
@@ -888,7 +895,8 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle)
#endif
{
// Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme->lightStrength() / 2.5f);
+ lineShader->setUniformValue(lineShader->lightS(),
+ m_cachedTheme->lightStrength() / 2.5f);
}
QQuaternion lineYRotation = QQuaternion();
@@ -1692,7 +1700,8 @@ void Scatter3DRenderer::initShaders(const QString &vertexShader, const QString &
m_dotShader->initialize();
}
-void Scatter3DRenderer::initGradientShaders(const QString &vertexShader, const QString &fragmentShader)
+void Scatter3DRenderer::initGradientShaders(const QString &vertexShader,
+ const QString &fragmentShader)
{
if (m_dotGradientShader)
delete m_dotGradientShader;
@@ -1789,7 +1798,9 @@ QVector3D Scatter3DRenderer::indexToSelectionColor(GLint index)
return QVector3D(dotIdxRed, dotIdxGreen, dotIdxBlue);
}
-void Scatter3DRenderer::selectionColorToSeriesAndIndex(const QVector3D &color, int &index, QAbstract3DSeries *&series)
+void Scatter3DRenderer::selectionColorToSeriesAndIndex(const QVector3D &color,
+ int &index,
+ QAbstract3DSeries *&series)
{
if (color != selectionSkipColor) {
index = int(color.x())
diff --git a/src/datavisualization/engine/selectionpointer.cpp b/src/datavisualization/engine/selectionpointer.cpp
index 7a47c43f..9cc13224 100644
--- a/src/datavisualization/engine/selectionpointer.cpp
+++ b/src/datavisualization/engine/selectionpointer.cpp
@@ -134,8 +134,11 @@ void SelectionPointer::render(GLuint defaultFboHandle)
m_pointShader->setUniformValue(m_pointShader->nModel(), itModelMatrix.inverted().transposed());
m_pointShader->setUniformValue(m_pointShader->color(), m_highlightColor);
m_pointShader->setUniformValue(m_pointShader->MVP(), MVPMatrix);
- m_pointShader->setUniformValue(m_pointShader->ambientS(), m_cachedTheme->ambientLightStrength());
+ m_pointShader->setUniformValue(m_pointShader->ambientS(),
+ m_cachedTheme->ambientLightStrength());
m_pointShader->setUniformValue(m_pointShader->lightS(), m_cachedTheme->lightStrength() * 2.0f);
+ m_pointShader->setUniformValue(m_pointShader->lightColor(),
+ Utils::vectorFromColor(m_cachedTheme->lightColor()));
m_drawer->drawObject(m_pointShader, m_pointObj);
diff --git a/src/datavisualization/engine/shaders/colorOnY.frag b/src/datavisualization/engine/shaders/colorOnY.frag
index caea959b..8c610cd7 100644
--- a/src/datavisualization/engine/shaders/colorOnY.frag
+++ b/src/datavisualization/engine/shaders/colorOnY.frag
@@ -6,6 +6,7 @@ uniform highp float ambientStrength;
uniform sampler2D textureSampler;
uniform highp float gradMin;
uniform highp float gradHeight;
+uniform highp vec3 lightColor;
varying highp vec3 position_wrld;
varying highp vec3 normal_cmr;
@@ -16,8 +17,8 @@ varying highp vec2 coords_mdl;
void main() {
highp vec2 gradientUV = vec2(0.0, gradMin + ((coords_mdl.y + 1.0) * gradHeight));
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp float distance = length(lightPosition_wrld - position_wrld);
highp vec3 n = normalize(normal_cmr);
diff --git a/src/datavisualization/engine/shaders/colorOnY_ES2.frag b/src/datavisualization/engine/shaders/colorOnY_ES2.frag
index bb6e28c7..5b553562 100644
--- a/src/datavisualization/engine/shaders/colorOnY_ES2.frag
+++ b/src/datavisualization/engine/shaders/colorOnY_ES2.frag
@@ -4,6 +4,7 @@ uniform highp float ambientStrength;
uniform sampler2D textureSampler;
uniform highp float gradMin;
uniform highp float gradHeight;
+uniform highp vec3 lightColor;
varying highp vec3 position_wrld;
varying highp vec3 normal_cmr;
@@ -14,8 +15,8 @@ varying highp vec2 coords_mdl;
void main() {
highp vec2 gradientUV = vec2(0.0, gradMin + ((coords_mdl.y + 1.0) * gradHeight));
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp float distance = length(lightPosition_wrld - position_wrld);
highp vec3 n = normalize(normal_cmr);
diff --git a/src/datavisualization/engine/shaders/default.frag b/src/datavisualization/engine/shaders/default.frag
index fba1ce4a..ca6fefb9 100644
--- a/src/datavisualization/engine/shaders/default.frag
+++ b/src/datavisualization/engine/shaders/default.frag
@@ -11,11 +11,12 @@ uniform highp vec3 lightPosition_wrld;
uniform highp vec3 color_mdl;
uniform highp float lightStrength;
uniform highp float ambientStrength;
+uniform highp vec3 lightColor;
void main() {
highp vec3 materialDiffuseColor = color_mdl.rgb;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp float distance = length(lightPosition_wrld - position_wrld);
diff --git a/src/datavisualization/engine/shaders/default_ES2.frag b/src/datavisualization/engine/shaders/default_ES2.frag
index 7d6214b2..bc5c18b6 100644
--- a/src/datavisualization/engine/shaders/default_ES2.frag
+++ b/src/datavisualization/engine/shaders/default_ES2.frag
@@ -9,11 +9,12 @@ uniform highp vec3 lightPosition_wrld;
uniform highp vec3 color_mdl;
uniform highp float lightStrength;
uniform highp float ambientStrength;
+uniform highp vec3 lightColor;
void main() {
highp vec3 materialDiffuseColor = color_mdl.rgb;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp float distance = length(lightPosition_wrld - position_wrld);
diff --git a/src/datavisualization/engine/shaders/shadow.frag b/src/datavisualization/engine/shaders/shadow.frag
index 5309b5bb..6d212c08 100644
--- a/src/datavisualization/engine/shaders/shadow.frag
+++ b/src/datavisualization/engine/shaders/shadow.frag
@@ -5,6 +5,7 @@ uniform highp float ambientStrength;
uniform highp float shadowQuality;
uniform highp sampler2D textureSampler;
uniform highp sampler2DShadow shadowMap;
+uniform highp vec3 lightColor;
varying highp vec4 shadowCoord;
varying highp vec2 UV;
@@ -38,8 +39,8 @@ highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
void main() {
highp vec3 materialDiffuseColor = texture2D(textureSampler, UV).rgb;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(0.2, 0.2, 0.2);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor * 0.2;
highp vec3 n = normalize(normal_cmr);
highp vec3 l = normalize(lightDirection_cmr);
diff --git a/src/datavisualization/engine/shaders/shadowNoTex.frag b/src/datavisualization/engine/shaders/shadowNoTex.frag
index 0252ba49..12e86cb3 100644
--- a/src/datavisualization/engine/shaders/shadowNoTex.frag
+++ b/src/datavisualization/engine/shaders/shadowNoTex.frag
@@ -5,6 +5,7 @@ uniform highp float ambientStrength;
uniform highp float shadowQuality;
uniform highp vec3 color_mdl;
uniform highp sampler2DShadow shadowMap;
+uniform highp vec3 lightColor;
varying highp vec4 shadowCoord;
varying highp vec3 position_wrld;
@@ -54,8 +55,8 @@ highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
void main() {
highp vec3 materialDiffuseColor = color_mdl.rgb;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp vec3 n = normalize(normal_cmr);
highp vec3 l = normalize(lightDirection_cmr);
diff --git a/src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag b/src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag
index 9882cd92..5da1afc1 100644
--- a/src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag
+++ b/src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag
@@ -7,6 +7,7 @@ uniform highp sampler2DShadow shadowMap;
uniform sampler2D textureSampler;
uniform highp float gradMin;
uniform highp float gradHeight;
+uniform highp vec3 lightColor;
varying highp vec4 shadowCoord;
varying highp vec3 position_wrld;
@@ -41,8 +42,8 @@ highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
void main() {
highp vec2 gradientUV = vec2(0.0, gradMin + ((coords_mdl.y + 1.0) * gradHeight));
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp vec3 n = normalize(normal_cmr);
highp vec3 l = normalize(lightDirection_cmr);
diff --git a/src/datavisualization/engine/shaders/surface.frag b/src/datavisualization/engine/shaders/surface.frag
index 576cc51f..b5205d2d 100644
--- a/src/datavisualization/engine/shaders/surface.frag
+++ b/src/datavisualization/engine/shaders/surface.frag
@@ -10,12 +10,13 @@ uniform sampler2D textureSampler;
uniform highp vec3 lightPosition_wrld;
uniform highp float lightStrength;
uniform highp float ambientStrength;
+uniform highp vec3 lightColor;
void main() {
highp vec2 gradientUV = vec2(0.0, (coords_mdl.y + 1.0) / 2.0);
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp float distance = length(lightPosition_wrld - position_wrld);
diff --git a/src/datavisualization/engine/shaders/surfaceFlat.frag b/src/datavisualization/engine/shaders/surfaceFlat.frag
index fd42a289..7eaa917f 100644
--- a/src/datavisualization/engine/shaders/surfaceFlat.frag
+++ b/src/datavisualization/engine/shaders/surfaceFlat.frag
@@ -12,12 +12,13 @@ uniform sampler2D textureSampler;
uniform highp vec3 lightPosition_wrld;
uniform highp float lightStrength;
uniform highp float ambientStrength;
+uniform highp vec3 lightColor;
void main() {
highp vec2 gradientUV = vec2(0.0, (coords_mdl.y + 1.0) / 2.0);
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp float distance = length(lightPosition_wrld - position_wrld);
diff --git a/src/datavisualization/engine/shaders/surfaceShadowFlat.frag b/src/datavisualization/engine/shaders/surfaceShadowFlat.frag
index 6341136e..b2f2af74 100644
--- a/src/datavisualization/engine/shaders/surfaceShadowFlat.frag
+++ b/src/datavisualization/engine/shaders/surfaceShadowFlat.frag
@@ -15,6 +15,7 @@ uniform highp vec3 lightPosition_wrld;
uniform highp float lightStrength;
uniform highp float ambientStrength;
uniform highp float shadowQuality;
+uniform highp vec3 lightColor;
highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
vec2(0.94558609, -0.76890725),
@@ -36,8 +37,8 @@ highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
void main() {
highp vec2 gradientUV = vec2(0.0, (coords_mdl.y + 1.0) / 2.0);
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp vec3 n = normalize(normal_cmr);
highp vec3 l = normalize(lightDirection_cmr);
diff --git a/src/datavisualization/engine/shaders/surfaceShadowNoTex.frag b/src/datavisualization/engine/shaders/surfaceShadowNoTex.frag
index 755be3f1..004208bf 100644
--- a/src/datavisualization/engine/shaders/surfaceShadowNoTex.frag
+++ b/src/datavisualization/engine/shaders/surfaceShadowNoTex.frag
@@ -13,6 +13,7 @@ uniform highp vec3 lightPosition_wrld;
uniform highp float lightStrength;
uniform highp float ambientStrength;
uniform highp float shadowQuality;
+uniform highp vec3 lightColor;
highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
vec2(0.94558609, -0.76890725),
@@ -34,8 +35,8 @@ highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
void main() {
highp vec2 gradientUV = vec2(0.0, (coords_mdl.y + 1.0) / 2.0);
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp vec3 n = normalize(normal_cmr);
highp vec3 l = normalize(lightDirection_cmr);
diff --git a/src/datavisualization/engine/shaders/surface_ES2.frag b/src/datavisualization/engine/shaders/surface_ES2.frag
index c7e75594..0e17cacd 100644
--- a/src/datavisualization/engine/shaders/surface_ES2.frag
+++ b/src/datavisualization/engine/shaders/surface_ES2.frag
@@ -9,12 +9,13 @@ uniform sampler2D textureSampler;
uniform highp vec3 lightPosition_wrld;
uniform highp float lightStrength;
uniform highp float ambientStrength;
+uniform highp vec3 lightColor;
void main() {
highp vec2 gradientUV = vec2(0.0, (coords_mdl.y + 1.0) / 2.0);
highp vec3 materialDiffuseColor = texture2D(textureSampler, gradientUV).xyz;
- highp vec3 materialAmbientColor = vec3(ambientStrength, ambientStrength, ambientStrength) * materialDiffuseColor;
- highp vec3 materialSpecularColor = vec3(1.0, 1.0, 1.0);
+ highp vec3 materialAmbientColor = lightColor * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor;
highp float distance = length(lightPosition_wrld - position_wrld);
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index 45eb3391..b65cea83 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.cpp
@@ -567,6 +567,8 @@ void Surface3DRenderer::drawSlicedScene()
{
QVector3D lightPos;
+ QVector3D lightColor = Utils::vectorFromColor(m_cachedTheme->lightColor());
+
// Specify viewport
glViewport(m_secondarySubViewport.x(),
m_secondarySubViewport.y(),
@@ -642,6 +644,7 @@ void Surface3DRenderer::drawSlicedScene()
surfaceShader->setUniformValue(surfaceShader->lightS(), 0.15f);
surfaceShader->setUniformValue(surfaceShader->ambientS(),
m_cachedTheme->ambientLightStrength() * 2.3f);
+ surfaceShader->setUniformValue(surfaceShader->lightColor(), lightColor);
m_drawer->drawObject(surfaceShader, m_sliceSurfaceObj, baseGradientTexture);
}
@@ -674,6 +677,7 @@ void Surface3DRenderer::drawSlicedScene()
lineShader->setUniformValue(lineShader->color(), lineColor);
lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme->ambientLightStrength() * 2.3f);
lineShader->setUniformValue(lineShader->lightS(), 0.0f);
+ lineShader->setUniformValue(lineShader->lightColor(), lightColor);
// Horizontal lines
if (m_axisCacheY.segmentCount() > 0) {
@@ -832,6 +836,8 @@ void Surface3DRenderer::drawSlicedScene()
void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
{
GLfloat backgroundRotation = 0;
+ QVector3D lightColor = Utils::vectorFromColor(m_cachedTheme->lightColor());
+
glViewport(m_primarySubViewport.x(),
m_primarySubViewport.y(),
m_primarySubViewport.width(),
@@ -881,13 +887,15 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
// Draw depth buffer
#if !defined(QT_OPENGL_ES_2)
GLfloat adjustedLightStrength = m_cachedTheme->lightStrength() / 10.0f;
- if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone && m_surfaceObj && m_cachedSurfaceVisible) {
+ if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone && m_surfaceObj
+ && m_cachedSurfaceVisible) {
// Render scene into a depth texture for using with shadow mapping
// Enable drawing to depth framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, m_depthFrameBuffer);
// Attach texture to depth attachment
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthTexture, 0);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D,
+ m_depthTexture, 0);
glClear(GL_DEPTH_BUFFER_BIT);
// Bind depth shader
@@ -948,7 +956,8 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthModelTexture, 0);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D,
+ m_depthModelTexture, 0);
glClear(GL_DEPTH_BUFFER_BIT);
// Draw the triangles
@@ -1083,6 +1092,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
m_surfaceShader->setUniformValue(m_surfaceShader->MVP(), MVPMatrix);
m_surfaceShader->setUniformValue(m_surfaceShader->ambientS(),
m_cachedTheme->ambientLightStrength());
+ m_surfaceShader->setUniformValue(m_surfaceShader->lightColor(), lightColor);
// TODO: Do properly when multiseries support implemented QTRD-2657
GLuint gradientTexture;
@@ -1095,12 +1105,14 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
// Set shadow shader bindings
QMatrix4x4 depthMVPMatrix = depthProjectionViewMatrix * modelMatrix;
- m_surfaceShader->setUniformValue(m_surfaceShader->shadowQ(), m_shadowQualityToShader);
+ m_surfaceShader->setUniformValue(m_surfaceShader->shadowQ(),
+ m_shadowQualityToShader);
m_surfaceShader->setUniformValue(m_surfaceShader->depth(), depthMVPMatrix);
m_surfaceShader->setUniformValue(m_surfaceShader->lightS(), adjustedLightStrength);
// Draw the object
- m_drawer->drawObject(m_surfaceShader, m_surfaceObj, gradientTexture, m_depthModelTexture);
+ m_drawer->drawObject(m_surfaceShader, m_surfaceObj, gradientTexture,
+ m_depthModelTexture);
} else
#endif
{
@@ -1167,6 +1179,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
m_backgroundShader->setUniformValue(m_backgroundShader->color(), backgroundColor);
m_backgroundShader->setUniformValue(m_backgroundShader->ambientS(),
m_cachedTheme->ambientLightStrength() * 2.0f);
+ m_backgroundShader->setUniformValue(m_backgroundShader->lightColor(), lightColor);
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
@@ -1209,6 +1222,7 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
lineShader->setUniformValue(lineShader->view(), viewMatrix);
lineShader->setUniformValue(lineShader->color(), lineColor);
lineShader->setUniformValue(lineShader->ambientS(), m_cachedTheme->ambientLightStrength());
+ lineShader->setUniformValue(lineShader->lightColor(), lightColor);
#if !defined(QT_OPENGL_ES_2)
if (m_cachedShadowQuality > QAbstract3DGraph::ShadowQualityNone) {
// Set shadowed shader bindings
@@ -1219,7 +1233,8 @@ void Surface3DRenderer::drawScene(GLuint defaultFboHandle)
#endif
{
// Set shadowless shader bindings
- lineShader->setUniformValue(lineShader->lightS(), m_cachedTheme->lightStrength() / 2.5f);
+ lineShader->setUniformValue(lineShader->lightS(),
+ m_cachedTheme->lightStrength() / 2.5f);
}
QQuaternion lineYRotation = QQuaternion();
@@ -2173,7 +2188,8 @@ void Surface3DRenderer::updateDepthBuffer()
m_depthTexture = m_textureHelper->createDepthTextureFrameBuffer(m_primarySubViewport.size(),
m_depthFrameBuffer,
m_shadowQualityMultiplier);
- m_textureHelper->fillDepthTexture(m_depthTexture, m_primarySubViewport.size(), m_shadowQualityMultiplier, 1.0f);
+ m_textureHelper->fillDepthTexture(m_depthTexture, m_primarySubViewport.size(),
+ m_shadowQualityMultiplier, 1.0f);
m_depthModelTexture = m_textureHelper->createDepthTexture(m_primarySubViewport.size(),
m_shadowQualityMultiplier);
if (!m_depthTexture || !m_depthModelTexture)
diff --git a/src/datavisualization/theme/q3dtheme.cpp b/src/datavisualization/theme/q3dtheme.cpp
index 1d331efc..34c86108 100644
--- a/src/datavisualization/theme/q3dtheme.cpp
+++ b/src/datavisualization/theme/q3dtheme.cpp
@@ -111,8 +111,7 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
* \li Qt::white
* \row
* \li lightColor
- * \li The color of the specular light. Doesn't affect ambient light. \note Not yet supported
- * in alpha release.
+ * \li The color of the light. Affects both ambient and specular light.
* \li Qt::white
* \row
* \li lightStrength
@@ -295,8 +294,6 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
* \qmlproperty Color Theme3D::lightColor
*
* Color for the specular light defined in Scene3D.
- *
- * \warning Not supported in alpha release.
*/
/*!
@@ -596,8 +593,6 @@ QColor Q3DTheme::multiHighlightColor() const
* \property Q3DTheme::lightColor
*
* Color for the specular light defined in Q3DScene.
- *
- * \warning Not supported in alpha release.
*/
void Q3DTheme::setLightColor(const QColor &color)
{
diff --git a/src/datavisualization/theme/q3dtheme.h b/src/datavisualization/theme/q3dtheme.h
index 9baec05d..e023c76e 100644
--- a/src/datavisualization/theme/q3dtheme.h
+++ b/src/datavisualization/theme/q3dtheme.h
@@ -43,7 +43,7 @@ class QT_DATAVISUALIZATION_EXPORT Q3DTheme : public QObject
Q_PROPERTY(QColor gridLineColor READ gridLineColor WRITE setGridLineColor NOTIFY gridLineColorChanged)
Q_PROPERTY(QColor singleHighlightColor READ singleHighlightColor WRITE setSingleHighlightColor NOTIFY singleHighlightColorChanged)
Q_PROPERTY(QColor multiHighlightColor READ multiHighlightColor WRITE setMultiHighlightColor NOTIFY multiHighlightColorChanged)
- Q_PROPERTY(QColor lightColor READ lightColor WRITE setLightColor NOTIFY lightColorChanged) // TODO: Not used yet
+ Q_PROPERTY(QColor lightColor READ lightColor WRITE setLightColor NOTIFY lightColorChanged)
Q_PROPERTY(QList<QLinearGradient> baseGradients READ baseGradients WRITE setBaseGradients NOTIFY baseGradientsChanged)
Q_PROPERTY(QLinearGradient singleHighlightGradient READ singleHighlightGradient WRITE setSingleHighlightGradient NOTIFY singleHighlightGradientChanged)
Q_PROPERTY(QLinearGradient multiHighlightGradient READ multiHighlightGradient WRITE setMultiHighlightGradient NOTIFY multiHighlightGradientChanged)
@@ -56,7 +56,6 @@ class QT_DATAVISUALIZATION_EXPORT Q3DTheme : public QObject
Q_PROPERTY(bool gridEnabled READ isGridEnabled WRITE setGridEnabled NOTIFY gridEnabledChanged)
Q_PROPERTY(bool labelBackgroundEnabled READ isLabelBackgroundEnabled WRITE setLabelBackgroundEnabled NOTIFY labelBackgroundEnabledChanged)
Q_PROPERTY(ColorStyle colorStyle READ colorStyle WRITE setColorStyle NOTIFY colorStyleChanged)
- // TODO: Add everything we need (specularIntensity, lightDegradation, shaders?)
public:
enum ColorStyle {
diff --git a/src/datavisualization/utils/shaderhelper.cpp b/src/datavisualization/utils/shaderhelper.cpp
index adc24e8d..37027e6f 100644
--- a/src/datavisualization/utils/shaderhelper.cpp
+++ b/src/datavisualization/utils/shaderhelper.cpp
@@ -92,6 +92,7 @@ void ShaderHelper::initialize()
m_shadowUniform = m_program->uniformLocation("shadowMap");
m_gradientMinUniform = m_program->uniformLocation("gradMin");
m_gradientHeightUniform = m_program->uniformLocation("gradHeight");
+ m_lightColorUniform = m_program->uniformLocation("lightColor");
m_initialized = true;
}
@@ -247,6 +248,13 @@ GLuint ShaderHelper::gradientHeight()
return m_gradientHeightUniform;
}
+GLuint ShaderHelper::lightColor()
+{
+ if (!m_initialized)
+ qFatal("Shader not initialized");
+ return m_lightColorUniform;
+}
+
GLuint ShaderHelper::posAtt()
{
if (!m_initialized)
diff --git a/src/datavisualization/utils/shaderhelper_p.h b/src/datavisualization/utils/shaderhelper_p.h
index b4c71ca2..2984f7d6 100644
--- a/src/datavisualization/utils/shaderhelper_p.h
+++ b/src/datavisualization/utils/shaderhelper_p.h
@@ -73,6 +73,7 @@ class ShaderHelper
GLuint shadow();
GLuint gradientMin();
GLuint gradientHeight();
+ GLuint lightColor();
GLuint posAtt();
GLuint uvAtt();
@@ -106,6 +107,7 @@ class ShaderHelper
GLuint m_shadowUniform;
GLuint m_gradientMinUniform;
GLuint m_gradientHeightUniform;
+ GLuint m_lightColorUniform;
GLboolean m_initialized;
};