Continue changes to quadratic bezier rendering
This commit is contained in:
@@ -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); }
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -122,7 +122,7 @@ worldPictures w
|
||||
|
||||
testPic :: World -> [Picture]
|
||||
testPic w = --[blank]
|
||||
[setLayer 1 $ onLayerL [99] $ bezierQuad white red 20 20 (00,00) (200,200) (200,000) ]
|
||||
[setLayer 1 $ onLayerL [99] $ bezierQuad white red 20 20 (00,00) (150,90) (200,200) ]
|
||||
-- $ uncurry translate (mouseWorldPos w)
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -84,8 +84,8 @@ bezierQuad cola colc ra rc a b c = BezierQuad 0 [(aX, cola, aX +.+ aRadVec , fra
|
||||
| otherwise = c -.- b
|
||||
cRadVec = rc *.* (normalizeV $ vNormal b2c)
|
||||
cX = c -.- 0.5 *.* cRadVec
|
||||
bX = (b -.- (0.5 * ra *.* aRadVec) )
|
||||
-.- (0.5 * rc *.* cRadVec)
|
||||
bX = (b -.- (0.5 *.* aRadVec) )
|
||||
-.- (0.5 *.* cRadVec)
|
||||
fracRadA = ra / magV (aX -.- cX)
|
||||
fracRadC = rc / magV (aX -.- cX)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user