[Libreoffice-commits] core.git: slideshow/opengl

Tor Lillqvist tml at collabora.com
Sun Nov 8 23:12:22 PST 2015


 slideshow/opengl/vortexVertexShader.glsl |   48 +++++++++----------------------
 1 file changed, 14 insertions(+), 34 deletions(-)

New commits:
commit 6bb8194341cae5599f61cd613cf234ad2cbd2efc
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Nov 9 09:04:41 2015 +0200

    Simplify and improve (?) the Vortex transition
    
    Change-Id: I0602be9567961ca3bb5d41febd35ad65d8d7fb2a

diff --git a/slideshow/opengl/vortexVertexShader.glsl b/slideshow/opengl/vortexVertexShader.glsl
index 1dffbbd..fb40e0f 100755
--- a/slideshow/opengl/vortexVertexShader.glsl
+++ b/slideshow/opengl/vortexVertexShader.glsl
@@ -40,16 +40,18 @@ void main( void )
 {
     vec4 v = gl_Vertex;
 
-    // Of course this is nothing like what it will eventually be; just
+    // Not sure it this is like what it should eventually be; just
     // experimenting to get at least something.
 
-    // Move the tile on a semicircular path so that it will end up at the correct place
-    // Move half the tiles one way, half the other.
+    // Move the tile on a semicircular path so that it will end up at
+    // the correct place. All tiles move the same direction around the
+    // vertical centre axis.
 
     // Each tile moves during only half of the transition. The letmost
-    // tiles start moving immediately and arrive at their end position
-    // at time=0.5, when the tiles there (the rightmost ones) start
-    // moving.
+    // tiles start moving at the start and arrive at their end
+    // position around time=0.5, when the tiles there (the rightmost
+    // ones) start moving. (The exact time each tile is moving is
+    // fuzzed a bit to make a more random appearance.)
 
     // In GLSL 1.20 we don't have any bitwise operators, sigh
 
@@ -57,10 +59,11 @@ void main( void )
     int tileYIndex = int(mod(int(tileInfo) / 256, 256));
     int vertexIndexInTile = int(mod(int(tileInfo) / (256*256), 256));
 
-    float startTime = float(tileXIndex)/(numTiles.x-1) * 0.5;
-    float endTime = startTime + 0.5;
+    // A semi-random number 0..1, different for neighbouring tiles.
+    float fuzz = snoise(vec2(float(tileXIndex)/(numTiles.x-1), float(tileYIndex)/(numTiles.y-1)));
 
-    vec2 tileCenter = vec2(-1 + 1.5 * tileXIndex * (2.0/numTiles.x), -1 + 1.5 * tileYIndex * (2.0/numTiles.y));
+    float startTime = float(tileXIndex)/(numTiles.x-1) * 0.5 + fuzz*0.2;
+    float endTime = min(startTime + 0.5, 1.0);
 
     if (time <= startTime)
     {
@@ -70,40 +73,17 @@ void main( void )
     else if (time > startTime && time <= endTime)
     {
         // Moving
-        float moveTime = (time - startTime) * 2;
-
-        // First: Rotate the tile around its Y axis,
-        // It rotates 180 degrees during the transition.
-        // Translate to origin, rotate.
-
-        v -= vec4(tileCenter, 0, 0);
-
-        // A semi-random number 0..1, different for neighbouring tiles
-        float fuzz = snoise(256*vec2(float(tileXIndex)/(numTiles.x-1), float(tileYIndex)/(numTiles.y-1)));
-
-        float rotation = moveTime;
-
-        // experiment: perturb rotation a bit randomly
-        // rotation = moveTime - fuzz*(0.5-abs(time - 0.5));
+        float rotation = (time - startTime) / (endTime - startTime);
 
         v = rotationMatrix(vec3(0, 1, 0), rotation*M_PI) * v;
 
-        v.x += tileCenter.x * cos(moveTime*M_PI);
-        v.y += tileCenter.y;
-        v.z += (fuzz < 0.5 ? -1 : 1) * tileCenter.x * sin(moveTime*M_PI);
-
-        // Perturb z a bit randomly
-        v.z += (fuzz - 0.5) * 5 * (1 - abs(time-0.5)*2);
-
-        v_textureSelect = float(rotation > 0.5);
+        v_textureSelect = float(rotation > 0.5 || rotation < -0.5);
     }
     else
     {
         // At end location. Tile is 180 degrees rotated
 
-        v -= vec4(tileCenter, 0, 0);
         v = rotationMatrix(vec3(0, 1, 0), M_PI) * v;
-        v += vec4(-tileCenter.x, tileCenter.y, 0, 0);
 
         v_textureSelect = 1;
     }


More information about the Libreoffice-commits mailing list