summaryrefslogtreecommitdiff
path: root/slideshow/opengl
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2015-11-07 00:37:21 +0200
committerTor Lillqvist <tml@collabora.com>2015-11-07 01:45:48 +0200
commitef04c666591612bb222672de29a15be4515da040 (patch)
tree350f377ca75ba77514895089a3998ea364b058f0 /slideshow/opengl
parentd1c91627d9c7d117ee2e680f5c24844f7c4d8515 (diff)
Improve transition shader portability
Use #version 120 explicitly, and adapt the shader shader code accordingly, to use strictly only GLSL 1.20 constructs. Also, use less vertex attribute data in the Vortex vertex shader: We can pack the per-vertex tile x and y index and in-tile vertex index information into one float. Also, the shader can calculate the center of the tile a vertex belongs to based on the knowledge of which tile it is. Now the shader transitions work on OS X, too. Change-Id: I93e8b5069a6d06d2e412ffee322b1eb32805e606
Diffstat (limited to 'slideshow/opengl')
-rw-r--r--slideshow/opengl/basicVertexShader.glsl2
-rw-r--r--slideshow/opengl/dissolveFragmentShader.glsl2
-rw-r--r--slideshow/opengl/rippleFragmentShader.glsl2
-rw-r--r--slideshow/opengl/staticFragmentShader.glsl2
-rwxr-xr-xslideshow/opengl/vortexFragmentShader.glsl2
-rwxr-xr-xslideshow/opengl/vortexVertexShader.glsl17
6 files changed, 22 insertions, 5 deletions
diff --git a/slideshow/opengl/basicVertexShader.glsl b/slideshow/opengl/basicVertexShader.glsl
index 4ca615a57689..da8355465f9d 100644
--- a/slideshow/opengl/basicVertexShader.glsl
+++ b/slideshow/opengl/basicVertexShader.glsl
@@ -26,6 +26,8 @@
*
************************************************************************/
+#version 120
+
varying vec2 v_texturePosition;
void main( void )
diff --git a/slideshow/opengl/dissolveFragmentShader.glsl b/slideshow/opengl/dissolveFragmentShader.glsl
index c6e80e2a6931..6ce3d539d114 100644
--- a/slideshow/opengl/dissolveFragmentShader.glsl
+++ b/slideshow/opengl/dissolveFragmentShader.glsl
@@ -26,6 +26,8 @@
*
************************************************************************/
+#version 120
+
uniform sampler2D leavingSlideTexture;
uniform sampler2D enteringSlideTexture;
uniform sampler2D permTexture;
diff --git a/slideshow/opengl/rippleFragmentShader.glsl b/slideshow/opengl/rippleFragmentShader.glsl
index 83677e4d6390..ac6b8ac37099 100644
--- a/slideshow/opengl/rippleFragmentShader.glsl
+++ b/slideshow/opengl/rippleFragmentShader.glsl
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#version 120
+
#define M_PI 3.1415926535897932384626433832795
uniform sampler2D leavingSlideTexture;
diff --git a/slideshow/opengl/staticFragmentShader.glsl b/slideshow/opengl/staticFragmentShader.glsl
index cd47c5ad6fd7..ab4913de766c 100644
--- a/slideshow/opengl/staticFragmentShader.glsl
+++ b/slideshow/opengl/staticFragmentShader.glsl
@@ -26,6 +26,8 @@
*
************************************************************************/
+#version 120
+
uniform sampler2D leavingSlideTexture;
uniform sampler2D enteringSlideTexture;
uniform sampler2D permTexture;
diff --git a/slideshow/opengl/vortexFragmentShader.glsl b/slideshow/opengl/vortexFragmentShader.glsl
index a8a976731034..9b7741acb100 100755
--- a/slideshow/opengl/vortexFragmentShader.glsl
+++ b/slideshow/opengl/vortexFragmentShader.glsl
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#version 120
+
uniform sampler2D leavingSlideTexture;
uniform sampler2D enteringSlideTexture;
uniform float time;
diff --git a/slideshow/opengl/vortexVertexShader.glsl b/slideshow/opengl/vortexVertexShader.glsl
index 532260d748a9..1dffbbd187df 100755
--- a/slideshow/opengl/vortexVertexShader.glsl
+++ b/slideshow/opengl/vortexVertexShader.glsl
@@ -7,15 +7,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#version 120
+
#define M_PI 3.1415926535897932384626433832795
uniform float time;
uniform ivec2 numTiles;
uniform sampler2D permTexture;
-attribute vec2 tileCenter;
-attribute int tileXIndex;
-attribute int tileYIndex;
-attribute int vertexIndexInTile;
+attribute float tileInfo;
varying vec2 v_texturePosition;
varying float v_textureSelect;
@@ -52,9 +51,17 @@ void main( void )
// at time=0.5, when the tiles there (the rightmost ones) start
// moving.
+ // In GLSL 1.20 we don't have any bitwise operators, sigh
+
+ int tileXIndex = int(mod(int(tileInfo), 256));
+ 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;
+ vec2 tileCenter = vec2(-1 + 1.5 * tileXIndex * (2.0/numTiles.x), -1 + 1.5 * tileYIndex * (2.0/numTiles.y));
+
if (time <= startTime)
{
// Still at start location, nothing needed
@@ -86,7 +93,7 @@ void main( void )
v.z += (fuzz < 0.5 ? -1 : 1) * tileCenter.x * sin(moveTime*M_PI);
// Perturb z a bit randomly
- v.z += ((((tileXIndex << 3) ^ tileYIndex) % 10) - 5) * (1 - abs(time-0.5)*2);
+ v.z += (fuzz - 0.5) * 5 * (1 - abs(time-0.5)*2);
v_textureSelect = float(rotation > 0.5);
}