diff options
author | Tor Lillqvist <tml@collabora.com> | 2015-11-10 10:48:24 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2015-11-10 10:51:39 +0200 |
commit | 3042270bc54aee2dd4ea14d5996e2ee2960577ce (patch) | |
tree | 909e5d0b75514577f4e9c5a0243dba5f96b0553e /slideshow/opengl | |
parent | c044e51b9983d373cf3ea74aec0ffd37752f07a0 (diff) |
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
Diffstat (limited to 'slideshow/opengl')
-rwxr-xr-x | slideshow/opengl/vortexVertexShader.glsl | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/slideshow/opengl/vortexVertexShader.glsl b/slideshow/opengl/vortexVertexShader.glsl index fb40e0f48ade..07a00f2aa534 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; } |