lok: avoid ILibreOfficeKitNotifier null ptr de-reference on shutdown.
[LibreOffice.git] / slideshow / opengl / vortexGeometryShader.glsl
blob5d64a1249c900cef00ac2e20cb36caa9e9dcadfb
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  */
10 #version 150
12 layout(triangles) in;
13 layout(triangle_strip, max_vertices=11) out;
15 uniform float shadow;
16 uniform mat4 u_projectionMatrix;
17 uniform mat4 orthoProjectionMatrix;
18 uniform mat4 orthoViewMatrix;
20 in vec2 g_texturePosition[];
21 in vec3 g_normal[];
22 in mat4 modelViewMatrix[];
23 in mat4 transform[];
24 in float nTime[];
25 in float startTime[];
26 in float endTime[];
28 out vec2 v_texturePosition;
29 out vec3 v_normal;
30 out vec4 shadowCoordinate;
32 mat4 identityMatrix(void)
34     return mat4(1.0, 0.0, 0.0, 0.0,
35                 0.0, 1.0, 0.0, 0.0,
36                 0.0, 0.0, 1.0, 0.0,
37                 0.0, 0.0, 0.0, 1.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;
46     return matrix;
49 mat4 translationMatrix(vec3 axis)
51     mat4 matrix = identityMatrix();
52     matrix[3] = vec4(axis, 1.0);
53     return matrix;
56 void emitHexagonVertex(int index, vec3 translation, float fdsq)
58     mat4 projectionMatrix;
59     mat4 shadowMatrix;
61     if (shadow < 0.5) {
62         projectionMatrix = u_projectionMatrix;
63         shadowMatrix = orthoProjectionMatrix * orthoViewMatrix;
64     } else {
65         projectionMatrix = orthoProjectionMatrix * orthoViewMatrix;
66         shadowMatrix = mat4(0.0);
67     }
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)));
77     v_normal.z *= fdsq;
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];
82     EmitVertex();
85 void main()
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)
91         return;
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);
103         }
105         EndPrimitive();
106     }
108     // Draw the main quad part.
109     for (int i = 0; i < 3; ++i) {
110         emitHexagonVertex(i, noTranslation, 1.0);
111     }
113     EndPrimitive();
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */