1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
13 layout(triangle_strip, max_vertices=11) out;
16 uniform mat4 u_projectionMatrix;
17 uniform mat4 orthoProjectionMatrix;
18 uniform mat4 orthoViewMatrix;
20 in vec2 g_texturePosition[];
22 in mat4 modelViewMatrix[];
28 out vec2 v_texturePosition;
30 out vec4 shadowCoordinate;
32 mat4 identityMatrix(void)
34 return mat4(1.0, 0.0, 0.0, 0.0,
40 mat4 scaleMatrix(vec3 axis)
42 mat4 matrix = identityMatrix();
43 matrix[0][0] = axis.x;
44 matrix[1][1] = axis.y;
45 matrix[2][2] = axis.z;
49 mat4 translationMatrix(vec3 axis)
51 mat4 matrix = identityMatrix();
52 matrix[3] = vec4(axis, 1.0);
56 void emitHexagonVertex(int index, vec3 translation, float fdsq)
58 mat4 projectionMatrix;
62 projectionMatrix = u_projectionMatrix;
63 shadowMatrix = orthoProjectionMatrix * orthoViewMatrix;
65 projectionMatrix = orthoProjectionMatrix * orthoViewMatrix;
66 shadowMatrix = mat4(0.0);
69 mat4 normalMatrix = transpose(inverse(modelViewMatrix[index]));
71 vec4 pos = gl_in[index].gl_Position + vec4(translation, 0.0);
73 // Apply our transform operations.
74 pos = transform[index] * pos;
76 v_normal = normalize(vec3(normalMatrix * transform[index] * vec4(g_normal[index], 0.0)));
79 gl_Position = projectionMatrix * modelViewMatrix[index] * pos;
80 shadowCoordinate = translationMatrix(vec3(0.5, 0.5, 0.5)) * scaleMatrix(vec3(0.5, 0.5, 0.5)) * shadowMatrix * modelViewMatrix[index] * pos;
81 v_texturePosition = g_texturePosition[index];
87 const vec4 invalidPosition = vec4(-256.0, -256.0, -256.0, -256.0);
88 const vec3 noTranslation = vec3(0.0, 0.0, 0.0);
90 if (gl_in[0].gl_Position == invalidPosition)
93 // Draw “walls” to the hexagons.
94 if (nTime[0] > startTime[0] && nTime[0] <= endTime[0]) {
95 const vec3 translation = vec3(0.0, 0.0, -0.02);
97 emitHexagonVertex(2, noTranslation, 0.3);
98 emitHexagonVertex(2, translation, 0.3);
100 for (int i = 0; i < 3; ++i) {
101 emitHexagonVertex(i, noTranslation, 0.3);
102 emitHexagonVertex(i, translation, 0.3);
108 // Draw the main quad part.
109 for (int i = 0; i < 3; ++i) {
110 emitHexagonVertex(i, noTranslation, 1.0);
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */