tdf#124990: DnD operation can be set to fail in dropComplete
[LibreOffice.git] / slideshow / opengl / honeycombVertexShader.glsl
blobc3484d39ad846552e39e6b5c2ea595f7c7ca1563
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 #define M_PI 3.1415926535897932384626433832795
14 in vec3 a_position;
16 uniform mat4 u_projectionMatrix;
17 uniform mat4 u_modelViewMatrix;
18 uniform mat4 u_sceneTransformMatrix;
19 uniform mat4 u_primitiveTransformMatrix;
20 uniform mat4 u_operationsTransformMatrix;
22 uniform float time;
23 uniform float selectedTexture;
24 uniform float shadow;
25 uniform mat4 orthoProjectionMatrix;
26 uniform mat4 orthoViewMatrix;
28 // Workaround for Intel's Windows driver, to prevent optimisation breakage.
29 uniform float zero;
31 out mat4 projectionMatrix;
32 out mat4 modelViewMatrix;
33 out mat4 shadowMatrix;
35 mat4 identityMatrix(void)
37     return mat4(1.0, 0.0, 0.0, 0.0,
38                 0.0, 1.0, 0.0, 0.0,
39                 0.0, 0.0, 1.0, 0.0,
40                 0.0, 0.0, 0.0, 1.0);
43 mat4 translationMatrix(vec3 axis)
45     return mat4(1.0,    0.0,    0.0,    0.0,
46                 0.0,    1.0,    0.0,    0.0,
47                 0.0,    0.0,    1.0,    0.0,
48                 axis.x, axis.y, axis.z, 1.0);
51 mat4 scaleMatrix(vec3 axis)
53     return mat4(axis.x, 0.0,    0.0,    0.0,
54                 0.0,    axis.y, 0.0,    0.0,
55                 0.0,    0.0,    axis.z, 0.0,
56                 0.0,    0.0,    0.0,    1.0);
59 mat4 rotationMatrix(vec3 axis, float angle)
61     axis = normalize(axis);
62     float s = sin(angle);
63     float c = cos(angle);
64     float oc = 1.0 - c;
66     return mat4(oc * axis.x * axis.x + c,           oc * axis.x * axis.y - axis.z * s,  oc * axis.z * axis.x + axis.y * s,  0.0,
67                 oc * axis.x * axis.y + axis.z * s,  oc * axis.y * axis.y + c,           oc * axis.y * axis.z - axis.x * s,  0.0,
68                 oc * axis.z * axis.x - axis.y * s,  oc * axis.y * axis.z + axis.x * s,  oc * axis.z * axis.z + c,           0.0,
69                 0.0,                                0.0,                                0.0,                                1.0);
72 void main( void )
74     mat4 nmodelViewMatrix = u_modelViewMatrix * u_operationsTransformMatrix * u_sceneTransformMatrix * u_primitiveTransformMatrix;
75     mat4 transformMatrix = identityMatrix();
77     // TODO: use the aspect ratio of the slide instead.
78     mat4 slideScaleMatrix = scaleMatrix(vec3(0.75, 1, 1));
79     mat4 invertSlideScaleMatrix = scaleMatrix(1.0 / vec3(0.75, 1, 1));
81     // These ugly zero comparisons are a workaround for Intel's Windows driver optimisation bug.
82     if (selectedTexture > 0.5) {
83         // Leaving texture
84         if (zero < 1.0)
85             transformMatrix = invertSlideScaleMatrix * transformMatrix;
86         if (zero < 2.0)
87             transformMatrix = rotationMatrix(vec3(0.0, 0.0, 1.0), -pow(time, 3) * M_PI) * transformMatrix;
88         if (zero < 3.0)
89             transformMatrix = slideScaleMatrix * transformMatrix;
90         if (zero < 4.0)
91             transformMatrix = scaleMatrix(vec3(1 + pow(2 * time, 2.1), 1 + pow(2 * time, 2.1), 0)) * transformMatrix;
92         if (zero < 5.0)
93             transformMatrix = translationMatrix(vec3(0, 0, 6 * time)) * transformMatrix;
94     } else {
95         // Entering texture
96         if (zero < 1.0)
97             transformMatrix = invertSlideScaleMatrix * transformMatrix;
98         if (zero < 2.0)
99             transformMatrix = rotationMatrix(vec3(0.0, 0.0, 1.0), pow(0.8 * (time - 1.0), 2.0) * M_PI) * transformMatrix;
100         if (zero < 3.0)
101             transformMatrix = slideScaleMatrix * transformMatrix;
102         if (zero < 4.0)
103             transformMatrix = translationMatrix(vec3(0, 0, 28 * (sqrt(time) - 1))) * transformMatrix;
104     }
106     if (shadow < 0.5) {
107         projectionMatrix = u_projectionMatrix;
108         shadowMatrix = orthoProjectionMatrix * orthoViewMatrix;
109     } else {
110         projectionMatrix = orthoProjectionMatrix * orthoViewMatrix;
111         shadowMatrix = mat4(0.0);
112     }
114     modelViewMatrix = nmodelViewMatrix * transformMatrix;
115     gl_Position = vec4(a_position, 1.0);
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */