Refactor arc shader so it uses only matrix uniform

This commit is contained in:
2021-06-10 11:52:39 +02:00
parent 822db37a58
commit e016d3aa9e
4 changed files with 39 additions and 38 deletions
+21 -21
View File
@@ -1,34 +1,34 @@
#version 430 core
in vec4 gColor;
in vec2 cenPosT;
in float gRadIn;
in float gRadOut;
in vec2 angles;
in vec2 dist;
out vec4 fColor;
out float gl_FragDepth;
uniform float rotation;
//uniform float rotation;
void main()
{
vec2 pos = gl_FragCoord.xy;
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 - rotation;
// vec2 pos = gl_FragCoord.xy;
// 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 - rotation;
// 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 , onArcTest);
// 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 , onArcTest);
float d = (dist.x * dist.x) + (dist.y * dist.y);
if (d > 1 || d < gRadIn || dot(sv, dist) < 0 || dot(ev, dist) > 0) {discard;}
fColor = gColor;
}