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 uniform sampler2D slideTexture;
13 uniform sampler2D leavingShadowTexture;
14 uniform sampler2D enteringShadowTexture;
16 in vec2 v_texturePosition;
18 in vec4 shadowCoordinate;
21 const vec2 samplingPoints[9] = vec2[](
33 // Compute the shadow...
34 float visibility = 1.0;
35 const float epsilon = 0.0001;
37 // for the leaving slide,
39 float depthShadow = texture(leavingShadowTexture, shadowCoordinate.xy).r;
40 float shadowRadius = (1.0 / (shadowCoordinate.z - depthShadow)) * 1000.0;
41 for (int i = 0; i < 9; ++i) {
42 vec2 coordinate = shadowCoordinate.xy + samplingPoints[i] / shadowRadius;
43 if (texture(leavingShadowTexture, coordinate).r < shadowCoordinate.z - epsilon) {
49 // and for entering slide.
51 float depthShadow = texture(enteringShadowTexture, shadowCoordinate.xy).r;
52 float shadowRadius = (1.0 / (shadowCoordinate.z - depthShadow)) * 1000.0;
53 for (int i = 0; i < 9; ++i) {
54 vec2 coordinate = shadowCoordinate.xy + samplingPoints[i] / shadowRadius;
55 if (texture(enteringShadowTexture, coordinate).r < shadowCoordinate.z - epsilon) {
61 vec3 lightVector = vec3(0.0, 0.0, 1.0);
62 float light = max(dot(lightVector, v_normal), 0.0);
63 vec4 fragment = texture(slideTexture, v_texturePosition);
64 vec4 black = vec4(0.0, 0.0, 0.0, fragment.a);
65 gl_FragColor = mix(black, fragment, visibility * light);
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */