Continue changes to quadratic bezier rendering

This commit is contained in:
jgk
2021-03-13 23:14:37 +01:00
parent 152d017e39
commit 3aefb8319d
4 changed files with 36 additions and 4 deletions
+7 -1
View File
@@ -1,8 +1,12 @@
#version 430 core
in vec4 gColor;
in vec3 gBoundingBox;
in vec2 box2;
in float wStart;
in float wEnd;
// the width is calculated along the line a-c
// this should instead be along the lines a-b (for start width)
// and b-c (for end width)
out vec4 fColor;
@@ -19,8 +23,10 @@ void main()
{
//float d = x - y - 1 + 2* sqrt(y);
float d = sqrt(x) + sqrt(y) - 1;
float e = sqrt(f(x,wStart)) + sqrt(f(y,wEnd)) - 1.0;
// float e = sqrt(f(x,wStart)) + sqrt(f(y,wEnd)) - 1.0;
float e = sqrt(box2.x) + sqrt(box2.y) - 1.0;
// if ( d < 0 || e > 0) { discard; }
fColor = gColor;
// if ( d < 0 || e > 0) { fColor = vec4(0,0,1,1); }
if ( d < 0 || e > 0) { fColor = vec4(0,0,1,1); }
}
+26
View File
@@ -9,6 +9,8 @@ out float wStart;
out float wEnd;
out vec3 gBoundingBox;
out vec2 box2 ;
vec2 normV2 (vec2 v)
{ return vec2(-v.y,v.x) ;
}
@@ -16,6 +18,19 @@ float lhs (vec2 da, vec2 db)
{ return sign(dot(da, normV2(db))) ;
}
float extrapolate (vec2 inOne, vec2 inZeroA, vec2 inZeroB, vec2 xy)
{
float det = inOne.x * (inZeroA.y - inZeroB.y)
+ inZeroA.x * (inZeroB.y - inOne.y)
+ inZeroB.x * (inOne.y - inZeroA.y)
;
float r = (inZeroA.y - inZeroB.y) ;
float s = (inZeroB.x - inZeroA.x) ;
float t = (inZeroA.x * inZeroB.y - inZeroB.x * inZeroA.y) ;
return r * xy.x + s * xy.y + t
/ det ;
}
void main()
{
vec3 pa = gl_in[0].gl_Position.xyz;
@@ -25,22 +40,33 @@ void main()
wStart = vRadMag [0];
wEnd = vRadMag [2];
box2 = vec2 (1,0);
gBoundingBox = vec3 (0.9,0.1,0);
gColor = vColor[0];
gl_Position = vec4 (vPosOff[0] , pa.z , 1);
EmitVertex();
box2 = vec2 (0,1);
gBoundingBox = vec3 (0.1,0.9,0);
gColor = vColor[2];
gl_Position = vec4 (vPosOff[2] , pc.z , 1);
EmitVertex();
box2 = vec2( extrapolate(vPosOff[0],vPosOff[2],pb.xy,pa.xy)
, extrapolate(vPosOff[2],vPosOff[0],pb.xy,pa.xy)
) ;
box2 = vec2(0.2,0);
gBoundingBox = vec3 (1,0,1);
gColor = vColor[0];
gl_Position = vec4 (pa, 1);
EmitVertex();
box2 = vec2( extrapolate(vPosOff[0],vPosOff[2],pb.xy,pc.xy)
, extrapolate(vPosOff[2],vPosOff[0],pb.xy,pc.xy)
) ;
box2 = vec2(0,0.2);
gBoundingBox = vec3 (0,1,1);
gColor = vColor[2];
gl_Position = vec4 (pc, 1);
EmitVertex();
box2 = vec2( 0,0 ) ;
gBoundingBox = vec3 (0,0,0);
gColor = vColor[1];
gl_Position = vec4 (pb, 1);