Implement color for quadratic bezier curves

This commit is contained in:
2021-03-12 19:10:14 +01:00
parent 4ed72e263b
commit 918f7d23b8
8 changed files with 38 additions and 14 deletions
+5 -3
View File
@@ -1,6 +1,8 @@
#version 430 core
in vec4 gColor;
in vec3 gBoundingBox;
in float gRadStart;
in float gRadEnd;
out vec4 fColor;
@@ -8,7 +10,8 @@ float x = gBoundingBox.x;
float y = gBoundingBox.y;
float z = gBoundingBox.z;
float w = 0.1;
float w = gRadEnd;
float w2 = gRadStart;
float f (float a, float b)
{
@@ -17,10 +20,9 @@ float f (float a, float b)
}
void main()
{
//float d = x - y - 1 + 2* sqrt(y);
float d = sqrt(x) + sqrt(y) - 1;
float e = sqrt(f(x,w)) + sqrt(f(y,w)) - 1;
float e = sqrt(f(x,w)) + sqrt(f(y,w2)) - 1.0;
if ( d < 0 || e > 0) { discard; }
fColor = gColor;
// if ( d < 0) { fColor = vec4 (0,1,0,1); }
+5
View File
@@ -2,7 +2,10 @@
layout (triangles) in;
layout (triangle_strip, max_vertices = 3) out;
in vec4 vColor[];
in float vRad[];
out vec4 gColor;
out float gRadStart;
out float gRadEnd;
out vec3 gBoundingBox;
void main()
@@ -11,6 +14,8 @@ void main()
vec3 pb = gl_in[1].gl_Position.xyz;
vec3 pc = gl_in[2].gl_Position.xyz;
gRadStart = vRad[0];
gRadEnd = vRad[2];
// vec3 pa = vec3(paa.xy + 0.1 * (paa.xy - pca.xy), paa.z);
// vec3 pc = vec3(pca.xy + 0.1 * (pca.xy - paa.xy), pca.z);
+3
View File
@@ -1,7 +1,9 @@
#version 430 core
layout (location = 0) in vec3 position;
layout (location = 1) in vec4 color;
layout (location = 2) in float rad;
out vec4 vColor;
out float vRad;
uniform vec2 winSize;
uniform float zoom;
@@ -13,4 +15,5 @@ void main()
{
gl_Position = worldMat * vec4(position.xyz,1);
vColor = color;
vRad = rad;
}