2023-07-16 14:15:14 +08:00
|
|
|
#version 310 es
|
|
|
|
precision highp float;
|
|
|
|
precision highp int;
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-07-16 14:15:14 +08:00
|
|
|
layout(location = 0) in vec4 v_position;
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2023-07-16 22:10:48 +08:00
|
|
|
layout(std140) uniform fs_ub {
|
2023-07-16 14:15:14 +08:00
|
|
|
vec4 u_startColor;
|
|
|
|
vec4 u_endColor;
|
|
|
|
vec2 u_center;
|
|
|
|
float u_radius;
|
|
|
|
float u_expand;
|
|
|
|
};
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2023-07-16 14:15:14 +08:00
|
|
|
layout(location = 0) out vec4 FragColor;
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
float d = distance(v_position.xy, u_center) / u_radius;
|
|
|
|
if (d <= 1.0)
|
|
|
|
{
|
|
|
|
if (d <= u_expand)
|
|
|
|
{
|
2023-07-16 14:15:14 +08:00
|
|
|
FragColor = u_startColor;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-07-16 14:15:14 +08:00
|
|
|
FragColor = mix(u_startColor, u_endColor, (d - u_expand) / (1.0 - u_expand));
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-07-16 14:15:14 +08:00
|
|
|
FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
}
|