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 varying vec2 tex_coord;
13 varying vec2 alpha_coord;
14 varying vec2 mask_coord;
15 #ifdef USE_VERTEX_COLORS
16 varying vec4 vertex_color;
19 uniform sampler2D texture;
20 uniform sampler2D mask;
21 uniform sampler2D alpha;
31 #define TYPE_MASKED_COLOR 4
35 vec4 texelTexture = texture2D(texture, tex_coord);
37 if (type == TYPE_NORMAL)
39 gl_FragColor = texelTexture;
41 else if (type == TYPE_BLEND)
43 vec4 texelMask = texture2D(mask, mask_coord);
44 vec4 texelAlpha = texture2D(alpha, alpha_coord);
45 gl_FragColor = texelTexture;
46 gl_FragColor.a = 1.0 - (1.0 - floor(texelAlpha.r)) * texelMask.r;
48 else if (type == TYPE_MASKED)
50 vec4 texelMask = texture2D(mask, mask_coord);
51 gl_FragColor = texelTexture;
52 gl_FragColor.a = 1.0 - texelMask.r;
54 else if (type == TYPE_DIFF)
56 vec4 texelMask = texture2D(mask, mask_coord);
57 float alpha = 1.0 - abs(texelTexture.r - texelMask.r);
59 gl_FragColor = texelMask / alpha;
60 gl_FragColor.a = alpha;
62 else if (type == TYPE_MASKED_COLOR)
64 #ifdef USE_VERTEX_COLORS
65 gl_FragColor = vertex_color;
69 gl_FragColor.a = 1.0 - texelTexture.r;
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */