summaryrefslogtreecommitdiff
path: root/slideshow/opengl
diff options
context:
space:
mode:
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);
}