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
26
27
28
29
30
31
32
33
34
35
36
37
38
|
in vec4 uvcoordsvar;
out vec4 FragColor;
uniform sampler2D outlineColor;
uniform sampler2D outlineDepth;
uniform float alpha;
uniform bool doExpand;
void main()
{
ivec2 uv = ivec2(gl_FragCoord.xy);
FragColor = texelFetch(outlineColor, uv, 0).rgba;
float depth = texelFetch(outlineDepth, uv, 0).r;
vec4 color[4];
color[0] = texelFetchOffset(outlineColor, uv, 0, ivec2( 1, 0)).rgba;
color[1] = texelFetchOffset(outlineColor, uv, 0, ivec2( 0, 1)).rgba;
color[2] = texelFetchOffset(outlineColor, uv, 0, ivec2(-1, 0)).rgba;
color[3] = texelFetchOffset(outlineColor, uv, 0, ivec2( 0, -1)).rgba;
vec4 values = vec4(color[0].a, color[1].a, color[2].a, color[3].a);
bool is_blank_pixel = !(FragColor.a != 0.0 || (depth == 1.0 && !doExpand));
vec4 tests = vec4(is_blank_pixel);
tests *= step(vec4(1e-6), values); /* (color.a != 0.0) */
tests *= (doExpand) ? vec4(1.0) : step(values, vec4(0.999)); /* (doExpand || color.a != 1.0) */
bvec4 btests = equal(tests, vec4(1.0));
FragColor = (btests.x) ? color[0] : FragColor;
FragColor = (btests.y) ? color[1] : FragColor;
FragColor = (btests.z) ? color[2] : FragColor;
FragColor = (btests.w) ? color[3] : FragColor;
FragColor *= (is_blank_pixel) ? alpha : 1.0;
}
|