Allow for interpolating colors from center to edge of ellipses

This commit is contained in:
jgk
2021-03-10 12:12:59 +01:00
parent 5a16086743
commit d3c8504d21
8 changed files with 128 additions and 78 deletions
+15
View File
@@ -0,0 +1,15 @@
#version 430 core
in vec4 gColorC;
in vec4 gColorE;
in vec2 gBoundingBox;
out vec4 fColor;
//out float gl_FragDepth;
void main()
{
float d = dot(gBoundingBox,gBoundingBox);
if ( d > 1) { discard; }
fColor = mix (gColorE , gColorC, d);
}
//note it is the fragdepth that stops this from being square
+36
View File
@@ -0,0 +1,36 @@
#version 430 core
layout (triangles) in;
layout (triangle_strip, max_vertices = 4) out;
in vec4 vCol[];
out vec4 gColorC;
out vec4 gColorE;
out vec2 gBoundingBox;
uniform vec2 winSize;
uniform float zoom;
void main()
{
vec3 pa = gl_in[0].gl_Position.xyz;
vec3 pb = gl_in[1].gl_Position.xyz;
vec3 pc = gl_in[2].gl_Position.xyz;
gColorC = vCol[0];
gColorE = vCol[1];
gBoundingBox = vec2 (-1,1);
gl_Position = vec4 (pb, 1);
//gl_Position = vec4 (0.5,0,0, 1);
EmitVertex();
gBoundingBox = vec2 (1,1);
gl_Position = vec4 (pa, 1);
EmitVertex();
gBoundingBox = vec2 (-1,-1);
gl_Position = vec4 (pc, 1);
// gl_Position = vec4 (0.5,0.5,0, 1);
EmitVertex();
gBoundingBox = vec2 (1,-1);
gl_Position = vec4 (pa + pc - pb, 1);
EmitVertex();
EndPrimitive();
}
+16
View File
@@ -0,0 +1,16 @@
#version 430 core
layout (location = 0) in vec3 position;
layout (location = 1) in vec4 col;
out vec4 vCol;
uniform vec2 winSize;
uniform float zoom;
uniform vec2 translation;
uniform float rotation;
uniform mat4 worldMat;
void main()
{
gl_Position = worldMat * vec4(position,1);
vCol = col;
}