axmol/core/renderer/shaders/layer_radialGradient.frag

36 lines
680 B
GLSL
Raw Normal View History

#version 310 es
2023-08-31 18:59:12 +08:00
precision highp float;
precision highp int;
layout(location = POSITION) in vec4 v_position;
2019-11-23 20:27:39 +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
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)
{
FragColor = u_startColor;
2019-11-23 20:27:39 +08:00
}
else
{
FragColor = mix(u_startColor, u_endColor, (d - u_expand) / (1.0 - u_expand));
2019-11-23 20:27:39 +08:00
}
}
else
{
FragColor = vec4(0.0, 0.0, 0.0, 0.0);
2019-11-23 20:27:39 +08:00
}
}