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/.
12 #define M_PI 3.1415926535897932384626433832795
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;
23 uniform float selectedTexture;
25 uniform mat4 orthoProjectionMatrix;
26 uniform mat4 orthoViewMatrix;
28 // Workaround for Intel's Windows driver, to prevent optimisation breakage.
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,
43 mat4 translationMatrix(vec3 axis)
45 return mat4(1.0, 0.0, 0.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,
59 mat4 rotationMatrix(vec3 axis, float angle)
61 axis = normalize(axis);
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,
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) {
85 transformMatrix = invertSlideScaleMatrix * transformMatrix;
87 transformMatrix = rotationMatrix(vec3(0.0, 0.0, 1.0), -pow(time, 3) * M_PI) * transformMatrix;
89 transformMatrix = slideScaleMatrix * transformMatrix;
91 transformMatrix = scaleMatrix(vec3(1 + pow(2 * time, 2.1), 1 + pow(2 * time, 2.1), 0)) * transformMatrix;
93 transformMatrix = translationMatrix(vec3(0, 0, 6 * time)) * transformMatrix;
97 transformMatrix = invertSlideScaleMatrix * transformMatrix;
99 transformMatrix = rotationMatrix(vec3(0.0, 0.0, 1.0), pow(0.8 * (time - 1.0), 2.0) * M_PI) * transformMatrix;
101 transformMatrix = slideScaleMatrix * transformMatrix;
103 transformMatrix = translationMatrix(vec3(0, 0, 28 * (sqrt(time) - 1))) * transformMatrix;
107 projectionMatrix = u_projectionMatrix;
108 shadowMatrix = orthoProjectionMatrix * orthoViewMatrix;
110 projectionMatrix = orthoProjectionMatrix * orthoViewMatrix;
111 shadowMatrix = mat4(0.0);
114 modelViewMatrix = nmodelViewMatrix * transformMatrix;
115 gl_Position = vec4(a_position, 1.0);
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */