summaryrefslogtreecommitdiff
path: root/slideshow/opengl
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>2015-12-21 21:25:32 +0000
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2016-01-05 15:05:48 +0100
commit22480b20130d10f4691cdf0a658040be7f36e47b (patch)
tree7fddfb4083b615df81b795b12f14d20ed7846fa4 /slideshow/opengl
parent928fe134ff6ea85f732b36a1ab11336f1d829531 (diff)
slideshow: Fix a few issues in the Glitter transition
Remove an unused variable, add comments, reduce the time a tile stays black, and don’t rely on implicit casts of integers into floats. Change-Id: Ifacf49fe99818a62ad0430d86dc15c3bf51cf326
Diffstat (limited to 'slideshow/opengl')
-rw-r--r--slideshow/opengl/glitterVertexShader.glsl20
1 files changed, 13 insertions, 7 deletions
diff --git a/slideshow/opengl/glitterVertexShader.glsl b/slideshow/opengl/glitterVertexShader.glsl
index 8a65a57c31c4..64bb6debb8ae 100644
--- a/slideshow/opengl/glitterVertexShader.glsl
+++ b/slideshow/opengl/glitterVertexShader.glsl
@@ -57,22 +57,28 @@ mat4 rotationMatrix(vec3 axis, float angle)
void main( void )
{
- // There are 18 vertices in an hexagon
- int instanceID = gl_VertexID / 18;
+ vec2 pos = (center.xy + 1.0) / 2.0;
- vec2 pos = (center.xy + 1) / 2;
+ // 0..1 pseudo-random value used to randomize the tile’s start time.
float fuzz = snoise(pos);
+
float startTime = pos.x * 0.5 + fuzz * 0.25;
float endTime = startTime + 0.25;
- float actualTime = clamp((time - startTime) / (endTime - startTime), 0, 1);
- angle = actualTime * M_PI * 2;
+
+ // Scale the transition time to minimize the time a tile will stay black.
+ float transitionTime = clamp((time - startTime) / (endTime - startTime), 0.0, 1.0);
+ if (transitionTime < 0.5)
+ transitionTime = transitionTime * 0.3 / 0.5;
+ else
+ transitionTime = (transitionTime * 0.3 / 0.5) + 0.4;
+ angle = transitionTime * M_PI * 2.0;
mat4 modelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
- mat4 transformMatrix = translationMatrix(center) * rotationMatrix(vec3(0, 1, 0), angle) * translationMatrix(-center);
+ mat4 transformMatrix = translationMatrix(center) * rotationMatrix(vec3(0.0, 1.0, 0.0), angle) * translationMatrix(-center);
mat3 normalMatrix = mat3(transpose(inverse(transformMatrix)));
gl_Position = u_projectionMatrix * modelViewMatrix * transformMatrix * vec4(a_position, 1.0);
- v_texturePosition = vec2((a_position.x + 1) / 2, (1 - a_position.y) / 2);
+ v_texturePosition = vec2((a_position.x + 1.0) / 2.0, (1.0 - a_position.y) / 2.0);
v_normal = normalize(normalMatrix * a_normal);
}