summaryrefslogtreecommitdiff
path: root/slideshow/opengl
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>2015-11-23 21:53:22 +0000
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2015-11-23 23:06:39 +0100
commit6bc132f8bf85516b4a89386c371fdd3e9937b4bf (patch)
treefb20dff8d0ffccbb6cdeb8c9a04d4d8ae3f89e5c /slideshow/opengl
parentb8eff3afb4a4b313c9be668951ae2cb458cd6a4a (diff)
slideshow: Add back lighting in the SimpleTransition shaders
Change-Id: Iec854a8369a7a9f845f261233e46aea8097db109
Diffstat (limited to 'slideshow/opengl')
-rw-r--r--slideshow/opengl/basicFragmentShader.glsl8
-rw-r--r--slideshow/opengl/basicVertexShader.glsl2
-rw-r--r--slideshow/opengl/reflectionFragmentShader.glsl6
-rw-r--r--slideshow/opengl/reflectionVertexShader.glsl4
4 files changed, 17 insertions, 3 deletions
diff --git a/slideshow/opengl/basicFragmentShader.glsl b/slideshow/opengl/basicFragmentShader.glsl
index 7744432f0bcf..01d72a260ca0 100644
--- a/slideshow/opengl/basicFragmentShader.glsl
+++ b/slideshow/opengl/basicFragmentShader.glsl
@@ -30,10 +30,14 @@
uniform sampler2D slideTexture;
varying vec2 v_texturePosition;
+varying vec3 v_normal;
void main() {
- // TODO: handle lighting.
- gl_FragColor = texture2D(slideTexture, v_texturePosition);
+ vec3 lightVector = vec3(0.0, 0.0, 1.0);
+ float light = max(dot(lightVector, v_normal), 0.0);
+ vec4 fragment = texture2D(slideTexture, v_texturePosition);
+ vec4 black = vec4(0.0, 0.0, 0.0, fragment.a);
+ gl_FragColor = mix(black, fragment, light);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/slideshow/opengl/basicVertexShader.glsl b/slideshow/opengl/basicVertexShader.glsl
index bd26c1b52115..020616fff872 100644
--- a/slideshow/opengl/basicVertexShader.glsl
+++ b/slideshow/opengl/basicVertexShader.glsl
@@ -29,11 +29,13 @@
#version 120
varying vec2 v_texturePosition;
+varying vec3 v_normal;
void main( void )
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
v_texturePosition = gl_MultiTexCoord0.xy;
+ v_normal = normalize(gl_NormalMatrix * gl_Normal);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/slideshow/opengl/reflectionFragmentShader.glsl b/slideshow/opengl/reflectionFragmentShader.glsl
index 9bf8ecb70c3d..b415279f2784 100644
--- a/slideshow/opengl/reflectionFragmentShader.glsl
+++ b/slideshow/opengl/reflectionFragmentShader.glsl
@@ -31,9 +31,15 @@
uniform sampler2D slideTexture;
varying float v_isShadow;
varying vec2 v_texturePosition;
+varying vec3 v_normal;
void main() {
+ vec3 lightVector = vec3(0.0, 0.0, 1.0);
+ float light = max(dot(lightVector, v_normal), 0.0);
vec4 fragment = texture2D(slideTexture, v_texturePosition);
+ vec4 black = vec4(0.0, 0.0, 0.0, fragment.a);
+ fragment = mix(black, fragment, light);
+
if (v_isShadow > 0.5) {
if (v_texturePosition.y > 1.0 - 0.3)
gl_FragColor = mix(fragment, vec4(0.0, 0.0, 0.0, 0.0), (1.0 - v_texturePosition.y) / 0.3);
diff --git a/slideshow/opengl/reflectionVertexShader.glsl b/slideshow/opengl/reflectionVertexShader.glsl
index b08d0cc82f59..5087b98c57b0 100644
--- a/slideshow/opengl/reflectionVertexShader.glsl
+++ b/slideshow/opengl/reflectionVertexShader.glsl
@@ -28,13 +28,15 @@
#version 130
-varying float v_isShadow;
varying vec2 v_texturePosition;
+varying vec3 v_normal;
+varying float v_isShadow;
void main( void )
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
v_texturePosition = gl_MultiTexCoord0.xy;
+ v_normal = normalize(gl_NormalMatrix * gl_Normal);
v_isShadow = float(gl_VertexID >= 6);
}