diff --git a/drape/shaders/line_fragment_shader.fsh b/drape/shaders/line_fragment_shader.fsh index 49be8f77af..f92749062f 100644 --- a/drape/shaders/line_fragment_shader.fsh +++ b/drape/shaders/line_fragment_shader.fsh @@ -17,29 +17,23 @@ varying vec3 v_mask; void main(void) { - float r = v_radius.y; - float dist = abs(v_radius.x); + float squareDist = v_radius.x * v_radius.x; + float squareRadius = v_radius.y * v_radius.y; + + float capY = (v_dx + 1.0 * sign(v_dx)) * v_radius.z / 2.0; + float joinY = (v_dx + 1.0) * v_radius.y / 2.0; if (v_type.x < -0.5) { - float y = (v_dx + 1.0) * v_radius.y / 2.0; + float y = joinY; if (v_type.y < 0.5) - y = v_radius.y - (v_dx + 1.0) * v_radius.y / 2.0; + y = v_radius.y - joinY; - float sq = dist * dist + y * y; - if (sq >= v_radius.y * v_radius.y) + if (squareDist + y * y > squareRadius) discard; } - else - { - if (v_type.y > 0.1 && abs(v_dx) >= 1.0) - { - float y = (v_dx + 1.0 * sign(v_dx)) * v_radius.z / 2.0; - float gip2 = dist * dist + y * y; - if(gip2 > v_radius.y * v_radius.y) - discard; - } - } + else if (v_type.y > 0.1 && abs(v_dx) >= 1.0 && (squareDist + capY > squareRadius)) + discard; vec4 color = getTexel(int(v_color.z), v_color.xy); color.a = getTexel(int(v_mask.z), v_mask.xy).a;