aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/shaders/outlinedtext_core.frag
blob: f3273cbdb697c61643db8abb4f23167c44d0563c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#version 150 core

in vec2 sampleCoord;
in vec2 sCoordUp;
in vec2 sCoordDown;
in vec2 sCoordLeft;
in vec2 sCoordRight;

out vec4 fragColor;

uniform sampler2D _qt_texture;
uniform vec4 color;
uniform vec4 styleColor;

void main()
{
    float glyph = texture(_qt_texture, sampleCoord).r;
    float outline = clamp(clamp(texture(_qt_texture, sCoordUp).r +
                                texture(_qt_texture, sCoordDown).r +
                                texture(_qt_texture, sCoordLeft).r +
                                texture(_qt_texture, sCoordRight).r,
                                0.0, 1.0) - glyph,
                          0.0, 1.0);
    fragColor = outline * styleColor + step(1.0 -  glyph, 1.0) * glyph * color;
}