blob: 06197f636587a527a21a77c24ae1f6314b6e7dc0 (
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
26
|
in vec4 finalColor;
layout(location = 0) out vec4 fragColor;
layout(location = 1) out vec4 lineOutput;
void main()
{
vec2 uv = gl_PointCoord - vec2(0.5);
float dist = length(uv);
if (dist > 0.5) {
discard;
}
/* Nice sphere falloff. */
float intensity = sqrt(1.0 - dist * 2.0) * 0.5 + 0.5;
fragColor = finalColor * vec4(intensity, intensity, intensity, 1.0);
/* The default value of GL_POINT_SPRITE_COORD_ORIGIN is GL_UPPER_LEFT. Need to reverse the Y. */
uv.y = -uv.y;
/* Subtract distance to outer edge of the circle. (0.75 is manually tweaked to look better) */
vec2 edge_pos = gl_FragCoord.xy - uv * (0.75 / (dist + 1e-9));
vec2 edge_start = edge_pos + vec2(-uv.y, uv.x);
lineOutput = pack_line_data(gl_FragCoord.xy, edge_start, edge_pos);
}
|