Add completed circle shader, add incomplete arc shader

This commit is contained in:
jgk
2021-02-19 13:54:40 +01:00
parent f6efe98181
commit defc8da088
9 changed files with 184 additions and 27 deletions
+19
View File
@@ -0,0 +1,19 @@
#version 430 core
in vec4 gColor;
in vec2 cenPosT;
in float gRad;
out vec4 fColor;
out float gl_FragDepth;
uniform vec2 winSize;
void main()
{
vec2 pos = gl_FragCoord.xy;
// fColor = vec4( gColor.xyz , 0 );
// fColor = vec4( gColor.xyz , 1 - step(distance(pos,cenPos.xy),gRad) );
// fColor = vec4( gColor.xyz , distance(pos,cenPos.xy)/gRad );
fColor = vec4( gColor.rgb, gColor.a * (1-step(gRad/2,distance(pos,cenPosT))) );
gl_FragDepth = max(gl_FragCoord.z , step(gRad/2,distance(pos,cenPosT)));
//fColor = vec4( 0.5,0,0 , 1 );
}
+34
View File
@@ -0,0 +1,34 @@
#version 430 core
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
in vec4 vColor [];
in float vRad [];
out vec4 gColor;
out float gRad;
out vec2 cenPosT;
uniform vec2 winSize;
uniform float zoom;
void main()
{
vec3 cenPos = gl_in[0].gl_Position.xyz;
//cenPos = vec3 (0.5,0,0);
gColor = vColor[0];
gRad = vRad[0] * zoom * 2;
// gRad = 0.2;
cenPosT = vec2 ( (cenPos.x + 1) * 0.5 * winSize.x , (cenPos.y + 1) * 0.5 * winSize.y);
gl_Position = vec4 (cenPos.x + gRad/winSize.x, cenPos.y + gRad/winSize.y, cenPos.z , 1);
//gl_Position = vec4 (cenPos.x + gRad/winSize.x, cenPos.y + gRad/winSize.y, cenPos.z , 1);
EmitVertex();
gl_Position = vec4 (cenPos.x - gRad/winSize.x, cenPos.y + gRad/winSize.y, cenPos.z , 1);
EmitVertex();
gl_Position = vec4 (cenPos.x + gRad/winSize.x, cenPos.y - gRad/winSize.y, cenPos.z , 1);
EmitVertex();
gl_Position = vec4 (cenPos.x - gRad/winSize.x, cenPos.y - gRad/winSize.y, cenPos.z , 1);
EmitVertex();
EndPrimitive();
}
+13
View File
@@ -0,0 +1,13 @@
#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;
void main()
{
gl_Position = vec4(position,1);
//gl_Position = vec4(0,0,0,1);
vColor = color;
vRad = rad;
}
+19
View File
@@ -0,0 +1,19 @@
#version 430 core
in vec4 gColor;
in vec2 cenPosT;
in float gRad;
out vec4 fColor;
out float gl_FragDepth;
uniform vec2 winSize;
void main()
{
vec2 pos = gl_FragCoord.xy;
// fColor = vec4( gColor.xyz , 0 );
// fColor = vec4( gColor.xyz , 1 - step(distance(pos,cenPos.xy),gRad) );
// fColor = vec4( gColor.xyz , distance(pos,cenPos.xy)/gRad );
fColor = vec4( gColor.rgb, gColor.a * (1-step(gRad/2,distance(pos,cenPosT))) );
gl_FragDepth = max(gl_FragCoord.z , step(gRad/2,distance(pos,cenPosT)));
//fColor = vec4( 0.5,0,0 , 1 );
}
+34
View File
@@ -0,0 +1,34 @@
#version 430 core
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
in vec4 vColor [];
in float vRad [];
out vec4 gColor;
out float gRad;
out vec2 cenPosT;
uniform vec2 winSize;
uniform float zoom;
void main()
{
vec3 cenPos = gl_in[0].gl_Position.xyz;
//cenPos = vec3 (0.5,0,0);
gColor = vColor[0];
gRad = vRad[0] * zoom * 2;
// gRad = 0.2;
cenPosT = vec2 ( (cenPos.x + 1) * 0.5 * winSize.x , (cenPos.y + 1) * 0.5 * winSize.y);
gl_Position = vec4 (cenPos.x + gRad/winSize.x, cenPos.y + gRad/winSize.y, cenPos.z , 1);
//gl_Position = vec4 (cenPos.x + gRad/winSize.x, cenPos.y + gRad/winSize.y, cenPos.z , 1);
EmitVertex();
gl_Position = vec4 (cenPos.x - gRad/winSize.x, cenPos.y + gRad/winSize.y, cenPos.z , 1);
EmitVertex();
gl_Position = vec4 (cenPos.x + gRad/winSize.x, cenPos.y - gRad/winSize.y, cenPos.z , 1);
EmitVertex();
gl_Position = vec4 (cenPos.x - gRad/winSize.x, cenPos.y - gRad/winSize.y, cenPos.z , 1);
EmitVertex();
EndPrimitive();
}
+13
View File
@@ -0,0 +1,13 @@
#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;
void main()
{
gl_Position = vec4(position,1);
//gl_Position = vec4(0,0,0,1);
vColor = color;
vRad = rad;
}