1 INPUT mediump vec2 vPosition;
3 uniform lowp vec4 uColor;
4 uniform lowp vec3 mixColor;
5 uniform mediump float thickness;
6 uniform mediump float radius;
7 uniform mediump float startAngle;
8 uniform mediump float sweepAngle;
10 const mediump float M_PI_OVER_2 = 1.57079632679;
11 const mediump float M_PI = 3.14159265359;
12 const mediump float M_PI_2 = 6.28318530718;
14 mediump float GetOpacity()
16 mediump float start = radians( mod( startAngle, 360.0 ) );
17 mediump float angle = mod( atan( vPosition.y, vPosition.x ) + M_PI_OVER_2 - start, M_PI_2 );
18 mediump float dist = length( vPosition );
19 if( angle <= radians( sweepAngle ) )
21 return smoothstep( -1.0, 1.0, thickness / 2.0 - ( abs( dist - radius ) ) );
23 mediump float end = radians( mod( startAngle + sweepAngle, 360.0 ) );
24 mediump vec2 q0 = vec2( dist * cos( start - M_PI_OVER_2 ), dist * sin( start - M_PI_OVER_2 ) );
25 mediump vec2 q1 = vec2( dist * cos( end - M_PI_OVER_2 ), dist * sin( end - M_PI_OVER_2 ) );
26 mediump float opacity = 1.0 - smoothstep( 0.0, 2.0, min( length( vPosition - q0 ), length( vPosition - q1 ) ) );
27 opacity *= step( 0.0, thickness / 2.0 - abs( dist - radius ) );
33 OUT_COLOR = vec4( mixColor, 1.0 ) * uColor;
34 OUT_COLOR.a *= GetOpacity();