summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/engine/shaders
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2013-11-05 13:57:18 +0200
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2013-11-07 09:43:46 +0200
commita61c6ee6533dca6723320c3955773cc5ccbfe2fa (patch)
treee459aa85f88da5f2a0e23c34266baecd2db5d1b8 /src/datavisualization/engine/shaders
parent9266f124979fa8a4fe7d8b2fb2db496b26aeeda9 (diff)
Gradient support Part 1
TODO: - Finish scatter - QML (maybe left until data set is sorted, though) Change-Id: I87a8117cb29f147080e0662c55b1098cb2e71689 Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualization/engine/shaders')
-rw-r--r--src/datavisualization/engine/shaders/colorOnY.frag8
-rw-r--r--src/datavisualization/engine/shaders/colorOnY_ES2.frag8
-rw-r--r--src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag8
3 files changed, 15 insertions, 9 deletions
diff --git a/src/datavisualization/engine/shaders/colorOnY.frag b/src/datavisualization/engine/shaders/colorOnY.frag
index 80e54a61..caea959b 100644
--- a/src/datavisualization/engine/shaders/colorOnY.frag
+++ b/src/datavisualization/engine/shaders/colorOnY.frag
@@ -1,9 +1,11 @@
#version 120
uniform highp vec3 lightPosition_wrld;
-uniform highp vec3 color_mdl;
uniform highp float lightStrength;
uniform highp float ambientStrength;
+uniform sampler2D textureSampler;
+uniform highp float gradMin;
+uniform highp float gradHeight;
varying highp vec3 position_wrld;
varying highp vec3 normal_cmr;
@@ -12,8 +14,8 @@ varying highp vec3 lightDirection_cmr;
varying highp vec2 coords_mdl;
void main() {
- highp float heightMod = (coords_mdl.y * 0.3) + 0.7; // Add 30% black to the bottom
- highp vec3 materialDiffuseColor = heightMod * color_mdl;
+ 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);
diff --git a/src/datavisualization/engine/shaders/colorOnY_ES2.frag b/src/datavisualization/engine/shaders/colorOnY_ES2.frag
index aba52cfe..bb6e28c7 100644
--- a/src/datavisualization/engine/shaders/colorOnY_ES2.frag
+++ b/src/datavisualization/engine/shaders/colorOnY_ES2.frag
@@ -1,7 +1,9 @@
uniform highp vec3 lightPosition_wrld;
-uniform highp vec3 color_mdl;
uniform highp float lightStrength;
uniform highp float ambientStrength;
+uniform sampler2D textureSampler;
+uniform highp float gradMin;
+uniform highp float gradHeight;
varying highp vec3 position_wrld;
varying highp vec3 normal_cmr;
@@ -10,8 +12,8 @@ varying highp vec3 lightDirection_cmr;
varying highp vec2 coords_mdl;
void main() {
- highp float heightMod = (coords_mdl.y * 0.3) + 0.7; // Add 30% black to the bottom
- highp vec3 materialDiffuseColor = heightMod * color_mdl;
+ 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);
diff --git a/src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag b/src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag
index 68ba2368..9882cd92 100644
--- a/src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag
+++ b/src/datavisualization/engine/shaders/shadowNoTexColorOnY.frag
@@ -3,8 +3,10 @@
uniform highp float lightStrength;
uniform highp float ambientStrength;
uniform highp float shadowQuality;
-uniform highp vec3 color_mdl;
uniform highp sampler2DShadow shadowMap;
+uniform sampler2D textureSampler;
+uniform highp float gradMin;
+uniform highp float gradHeight;
varying highp vec4 shadowCoord;
varying highp vec3 position_wrld;
@@ -37,8 +39,8 @@ highp vec2 poissonDisk[16] = vec2[16](vec2(-0.94201624, -0.39906216),
}*/
void main() {
- highp float heightMod = (coords_mdl.y * 0.3) + 0.7; // Add 30% black to the bottom
- highp vec3 materialDiffuseColor = heightMod * color_mdl;
+ 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);