summaryrefslogtreecommitdiff
path: root/slideshow/opengl/vortexGeometryShader.glsl
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>2016-01-20 21:04:37 +0000
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2016-01-20 22:45:04 +0100
commit29bd6961a23dd44bcf315cacac1189282d87fc9f (patch)
tree19b39ff1574f001d0d62a5aef06e90066e656fc8 /slideshow/opengl/vortexGeometryShader.glsl
parent24b9f873a691f4cfe4b3fa2c2a48f79a41a12417 (diff)
slideshow: Change quads into cubes in the Vortex transition
This makes Vortex require OpenGL 3.2 instead of 2.1. Change-Id: I9438a37c2cf75e58eafc807ad1abaa22acb231b1
Diffstat (limited to 'slideshow/opengl/vortexGeometryShader.glsl')
-rw-r--r--slideshow/opengl/vortexGeometryShader.glsl76
1 files changed, 76 insertions, 0 deletions
diff --git a/slideshow/opengl/vortexGeometryShader.glsl b/slideshow/opengl/vortexGeometryShader.glsl
new file mode 100644
index 000000000000..46999efad55f
--- /dev/null
+++ b/slideshow/opengl/vortexGeometryShader.glsl
@@ -0,0 +1,76 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#version 150
+
+layout(triangles) in;
+layout(triangle_strip, max_vertices=11) out;
+
+in vec2 g_texturePosition[];
+in vec3 g_normal[];
+in mat4 modelViewMatrix[];
+in mat4 transform[];
+in float nTime[];
+in float startTime[];
+in float endTime[];
+
+uniform mat4 u_projectionMatrix;
+
+out vec2 v_texturePosition;
+out vec3 v_normal;
+
+void emitHexagonVertex(int index, vec3 translation, float fdsq)
+{
+ mat4 normalMatrix = transpose(inverse(modelViewMatrix[index]));
+
+ vec4 pos = gl_in[index].gl_Position + vec4(translation, 0.0);
+
+ // Apply our transform operations.
+ pos = transform[index] * pos;
+
+ v_normal = normalize(vec3(normalMatrix * transform[index] * vec4(g_normal[index], 0.0)));
+ v_normal.z *= fdsq;
+
+ gl_Position = u_projectionMatrix * modelViewMatrix[index] * pos;
+ v_texturePosition = g_texturePosition[index];
+ EmitVertex();
+}
+
+void main()
+{
+ const vec4 invalidPosition = vec4(-256.0, -256.0, -256.0, -256.0);
+ const vec3 noTranslation = vec3(0.0, 0.0, 0.0);
+
+ if (gl_in[0].gl_Position == invalidPosition)
+ return;
+
+ // Draw “walls” to the hexagons.
+ if (nTime[0] > startTime[0] && nTime[0] <= endTime[0]) {
+ const vec3 translation = vec3(0.0, 0.0, -0.02);
+
+ emitHexagonVertex(2, noTranslation, 0.3);
+ emitHexagonVertex(2, translation, 0.3);
+
+ for (int i = 0; i < 3; ++i) {
+ emitHexagonVertex(i, noTranslation, 0.3);
+ emitHexagonVertex(i, translation, 0.3);
+ }
+
+ EndPrimitive();
+ }
+
+ // Draw the main quad part.
+ for (int i = 0; i < 3; ++i) {
+ emitHexagonVertex(i, noTranslation, 1.0);
+ }
+
+ EndPrimitive();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */