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 float fade_factor; // 0->1 fade factor used for AA
15 uniform float line_width;
16 uniform float feather;
20 float start = (line_width / 2.0) - feather; // where we start to apply alpha
21 float end = (line_width / 2.0) + feather; // where we end to apply alpha
23 // Calculate the multiplier so we can transform the 0->1 fade factor
24 // to take feather and line width into account.
25 float multiplied = 1.0 / (1.0 - (start / end));
27 float dist = (1.0 - abs(fade_factor)) * multiplied;
29 float alpha = clamp(dist, 0.0, 1.0);
31 // modify the alpha channel only
32 vec4 result_color = color;
33 result_color.a = result_color.a * alpha;
35 gl_FragColor = result_color;
38 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */