summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/engine/shaders/surfaceTexturedFlat.frag
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@theqtcompany.com>2014-10-29 09:45:41 +0200
committerMiikka Heikkinen <miikka.heikkinen@theqtcompany.com>2014-10-29 09:45:41 +0200
commite3a4f132ca2a42af3d4bb889d6a17948b88d26a2 (patch)
tree554d2b8b3020dc71438301aa696dea1e9a36943a /src/datavisualization/engine/shaders/surfaceTexturedFlat.frag
parentcc50608385cf77a0803431ece1385f341a400b75 (diff)
parentbf716cfdf0afecccdb1f2eabb2e6a172c620fbff (diff)
Merge branch 'develop'
Conflicts: .qmake.conf README src/datavisualization/global/qdatavisualizationglobal.h Change-Id: Ia6941dcf3e6aa17e2e9ebc6f60fac16ef5049f11
Diffstat (limited to 'src/datavisualization/engine/shaders/surfaceTexturedFlat.frag')
-rw-r--r--src/datavisualization/engine/shaders/surfaceTexturedFlat.frag39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/datavisualization/engine/shaders/surfaceTexturedFlat.frag b/src/datavisualization/engine/shaders/surfaceTexturedFlat.frag
new file mode 100644
index 00000000..7c654e0c
--- /dev/null
+++ b/src/datavisualization/engine/shaders/surfaceTexturedFlat.frag
@@ -0,0 +1,39 @@
+#version 120
+
+#extension GL_EXT_gpu_shader4 : require
+
+varying highp vec3 coords_mdl;
+varying highp vec3 position_wrld;
+flat varying highp vec3 normal_cmr;
+varying highp vec3 eyeDirection_cmr;
+varying highp vec3 lightDirection_cmr;
+varying highp vec2 UV;
+
+uniform sampler2D textureSampler;
+uniform highp vec3 lightPosition_wrld;
+uniform highp float lightStrength;
+uniform highp float ambientStrength;
+uniform highp vec4 lightColor;
+
+void main() {
+ highp vec3 materialDiffuseColor = texture2D(textureSampler, UV).xyz;
+ highp vec3 materialAmbientColor = lightColor.rgb * ambientStrength * materialDiffuseColor;
+ highp vec3 materialSpecularColor = lightColor.rgb;
+
+ highp float distance = length(lightPosition_wrld - position_wrld);
+
+ highp vec3 n = normalize(normal_cmr);
+ highp vec3 l = normalize(lightDirection_cmr);
+ highp float cosTheta = clamp(dot(n, l), 0.0, 1.0);
+
+ highp vec3 E = normalize(eyeDirection_cmr);
+ highp vec3 R = reflect(-l, n);
+ highp float cosAlpha = clamp(dot(E, R), 0.0, 1.0);
+
+ gl_FragColor.rgb =
+ materialAmbientColor +
+ materialDiffuseColor * lightStrength * pow(cosTheta, 2) / distance +
+ materialSpecularColor * lightStrength * pow(cosAlpha, 10) / distance;
+ gl_FragColor.a = 1.0;
+}
+