[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - slideshow/opengl

Emmanuel Gil Peyrot emmanuel.peyrot at collabora.com
Thu Jan 21 00:37:20 PST 2016


 slideshow/opengl/honeycombFragmentShader.glsl |   20 ++++++++++++++++----
 slideshow/opengl/honeycombGeometryShader.glsl |   22 ++++++++++++++++++++--
 2 files changed, 36 insertions(+), 6 deletions(-)

New commits:
commit f28347ca6018b8163acf3f358a28f47eecf30641
Author: Emmanuel Gil Peyrot <emmanuel.peyrot at collabora.com>
Date:   Fri Jan 15 21:07:56 2016 +0000

    slideshow: Add some volume to the Honeycomb hexagons, making them look better
    
    Change-Id: Ic0f62f36faccb65ab4fbc7bb5553d096a2658f96
    (cherry picked from commit 7cca8d3b3f5a9eda0060342fd2576d08a874b1c3)
    Reviewed-on: https://gerrit.libreoffice.org/21645
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: David Tardon <dtardon at redhat.com>

diff --git a/slideshow/opengl/honeycombFragmentShader.glsl b/slideshow/opengl/honeycombFragmentShader.glsl
index 25b3e2d..325e393 100644
--- a/slideshow/opengl/honeycombFragmentShader.glsl
+++ b/slideshow/opengl/honeycombFragmentShader.glsl
@@ -12,6 +12,7 @@
 in vec2 texturePosition;
 in float fuzz;
 in vec2 v_center;
+in vec3 normal;
 
 uniform sampler2D slideTexture;
 uniform float selectedTexture;
@@ -25,13 +26,15 @@ bool isBorder(vec2 point)
 
 void main()
 {
-    gl_FragColor = texture2D(slideTexture, texturePosition);
+    vec4 fragment = texture2D(slideTexture, texturePosition);
+    vec3 lightVector = vec3(0.0, 0.0, 1.0);
+    float light = max(dot(lightVector, normal), 0.0);
     if (hexagonSize > 1.0) {
         // The space in-between hexagons.
         if (selectedTexture > 0.5)
-            gl_FragColor.a = 1.0 - time * 8 + gl_FragCoord.x / 1024.;
+            fragment.a = 1.0 - time * 8 + gl_FragCoord.x / 1024.;
         else
-            gl_FragColor.a = time * 8 - 7.7 + gl_FragCoord.x / 1024.;
+            fragment.a = time * 8 - 7.3 + gl_FragCoord.x / 1024.;
     } else {
         // The hexagons themselves.
 
@@ -58,8 +61,17 @@ void main()
             if (time < 0.8)
                 actualTime *= time / 0.8;
         }
-        gl_FragColor.a = actualTime;
+
+        if (selectedTexture > 0.5) {
+            // Leaving texture needs to be transparent to see-through.
+            fragment.a = actualTime;
+        } else {
+            // Entering one though, would look weird with transparency.
+            fragment.rgb *= actualTime;
+        }
     }
+    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/honeycombGeometryShader.glsl b/slideshow/opengl/honeycombGeometryShader.glsl
index bb2b1f3..f1c0c70 100644
--- a/slideshow/opengl/honeycombGeometryShader.glsl
+++ b/slideshow/opengl/honeycombGeometryShader.glsl
@@ -10,7 +10,7 @@
 #version 150
 
 layout(triangles) in;
-layout(triangle_strip, max_vertices=13) out;
+layout(triangle_strip, max_vertices=27) out;
 
 in mat4 modelViewProjectionMatrix[];
 
@@ -20,6 +20,7 @@ uniform sampler2D permTexture;
 out vec2 texturePosition;
 out float fuzz;
 out vec2 v_center;
+out vec3 normal;
 
 const float expandFactor = 0.0318;
 
@@ -51,11 +52,28 @@ void main()
     v_center = (1 + center.xy) / 2;
     fuzz = snoise(center.xy);
 
+    // Draw “walls” to the hexagons.
+    if (hexagonSize < 1.0) {
+        vec3 rearCenter = vec3(center.xy, -0.3);
+        normal = vec3(0.0, 0.0, 0.3);
+        emitHexagonVertex(center, translateVectors[5]);
+        emitHexagonVertex(rearCenter, translateVectors[5]);
+
+        for (int i = 0; i < 6; ++i) {
+            emitHexagonVertex(center, translateVectors[i]);
+            emitHexagonVertex(rearCenter, translateVectors[i]);
+        }
+
+        EndPrimitive();
+    }
+
+    // Draw the main hexagon part.
+    normal = vec3(0.0, 0.0, 1.0);
     emitHexagonVertex(center, translateVectors[5]);
 
     for (int i = 0; i < 6; ++i) {
         emitHexagonVertex(center, translateVectors[i]);
-        emitHexagonVertex(center, vec2(0, 0));
+        emitHexagonVertex(center, vec2(0.0, 0.0));
     }
 
     EndPrimitive();


More information about the Libreoffice-commits mailing list