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

Tor Lillqvist tml at collabora.com
Tue Nov 10 00:53:32 PST 2015


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

New commits:
commit 3042270bc54aee2dd4ea14d5996e2ee2960577ce
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Nov 10 10:48:24 2015 +0200

    Improve the Vortex transition
    
    Let about half the tiles move around in one direction (in front of the
    slide plane), and the rest the other direction (behind the slide
    plane).
    
    Make sure tiles that rotate into each other's location go the same way
    around, so that they don't pass through each others, which looks ugly.
    
    Avoid z-fighting by not letting the tile end up exactly on top of the
    one it is replacing, in case that one has not started moving yet.
    
    Change-Id: I232b0f815412d5d575b0dde4df2d337288e645bb

diff --git a/slideshow/opengl/vortexVertexShader.glsl b/slideshow/opengl/vortexVertexShader.glsl
index fb40e0f..07a00f2 100755
--- a/slideshow/opengl/vortexVertexShader.glsl
+++ b/slideshow/opengl/vortexVertexShader.glsl
@@ -62,9 +62,15 @@ void main( void )
     // A semi-random number 0..1, different for neighbouring tiles.
     float fuzz = snoise(vec2(float(tileXIndex)/(numTiles.x-1), float(tileYIndex)/(numTiles.y-1)));
 
+    // Semi-random rotation direction, identical for tiles that rotate into each other's location
+    // so that they don't pass through each others in flight, which looks ugly.
+    float direction = (snoise(vec2(floor(abs(float(numTiles.x-1)/2-tileXIndex))/(float(numTiles.x-1)/2), float(tileYIndex)/(numTiles.y-1))) < 0.5 ? -1 : 1);
+
     float startTime = float(tileXIndex)/(numTiles.x-1) * 0.5 + fuzz*0.2;
     float endTime = min(startTime + 0.5, 1.0);
 
+    const float ALMOST_ONE = 0.999;
+
     if (time <= startTime)
     {
         // Still at start location, nothing needed
@@ -73,9 +79,10 @@ void main( void )
     else if (time > startTime && time <= endTime)
     {
         // Moving
-        float rotation = (time - startTime) / (endTime - startTime);
+        float rotation = direction * (time - startTime) / (endTime - startTime);
 
-        v = rotationMatrix(vec3(0, 1, 0), rotation*M_PI) * v;
+        // Avoid z fighting
+        v = rotationMatrix(vec3(0, 1, 0), max(min(rotation, ALMOST_ONE), -ALMOST_ONE)*M_PI) * v;
 
         v_textureSelect = float(rotation > 0.5 || rotation < -0.5);
     }
@@ -83,7 +90,8 @@ void main( void )
     {
         // At end location. Tile is 180 degrees rotated
 
-        v = rotationMatrix(vec3(0, 1, 0), M_PI) * v;
+        // Avoid z fighting
+        v = rotationMatrix(vec3(0, 1, 0), direction*ALMOST_ONE*M_PI) * v;
 
         v_textureSelect = 1;
     }


More information about the Libreoffice-commits mailing list