Implement arc rendering, works for increasing angle difference < 2pi

This commit is contained in:
2021-02-20 08:16:24 +01:00
parent 2866535b52
commit 9ff7810a2d
9 changed files with 101 additions and 104 deletions
+23 -8
View File
@@ -1,18 +1,33 @@
#version 430 core
in vec4 gColor;
in vec2 cenPosT;
in float gRad;
in float gWdth;
in float gRadIn;
in float gRadOut;
in vec2 angles;
out vec4 fColor;
out float gl_FragDepth;
void main()
{
vec2 pos = gl_FragCoord.xy;
// fColor = vec4( gColor.xyz , 0 );
// fColor = vec4( gColor.xyz , 1 - step(distance(pos,cenPos.xy),gRad) );
// fColor = vec4( gColor.xyz , distance(pos,cenPos.xy)/gRad );
fColor = vec4( gColor.rgb, gColor.a * (1-step(gRad/2,distance(pos,cenPosT))) );
gl_FragDepth = max(gl_FragCoord.z , step(gRad/2,distance(pos,cenPosT)));
//fColor = vec4( 0.5,0,0 , 1 );
float d = distance(pos,cenPosT);
float dTest = max ( step(gRadOut/2,d)
, 1 - step(gRadIn/2,d)
);
vec2 posDiff = pos - cenPosT;
float sa = angles.x;
vec2 sv = vec2 (-sin(sa), cos(sa));
float saTest = dot(sv,posDiff) >= 0 ? 0 : 1;
float ea = angles.y;
vec2 ev = vec2 (-sin(ea), cos(ea));
float eaTest = dot(ev,posDiff) <= 0 ? 0 : 1;
float aTest = ea - sa < radians(180) ? max (saTest,eaTest)
: min (saTest,eaTest);
float onArcTest = max(dTest,aTest);
//gl_FragDepth = max(gl_FragCoord.z , step(gRadOut/2,distance(pos,cenPosT)));
gl_FragDepth = max(gl_FragCoord.z , onArcTest);
fColor = gColor;
}