2023-08-13 23:56:58 +08:00
|
|
|
#version 310 es
|
2023-08-13 23:58:18 +08:00
|
|
|
precision highp float;
|
2023-08-13 23:56:58 +08:00
|
|
|
precision highp int;
|
|
|
|
|
|
|
|
layout(location = POSITION) in vec4 v_position;
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2023-08-13 23:56:58 +08:00
|
|
|
layout(std140) uniform fs_ub {
|
|
|
|
vec4 u_startColor;
|
|
|
|
vec4 u_endColor;
|
|
|
|
vec2 u_center;
|
|
|
|
float u_radius;
|
|
|
|
float u_expand;
|
|
|
|
};
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2023-08-13 23:56:58 +08:00
|
|
|
layout(location = SV_Target0) 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-08-13 23:56:58 +08:00
|
|
|
FragColor = u_startColor;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-13 23:56:58 +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-08-13 23:56:58 +08:00
|
|
|
FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
}
|