Fix arc rendering bug (make vertex attribs correct size)

This commit is contained in:
jgk
2021-03-12 01:22:10 +01:00
parent e8e3dd8f50
commit 9bdc6fddd7
21 changed files with 63 additions and 347 deletions
-1
View File
@@ -29,7 +29,6 @@ void main()
float onArcTest = max(dTest,aTest);
//gl_FragDepth = max(gl_FragCoord.z , step(gRadOut/2,distance(pos,cenPosT)));
gl_FragDepth = max(gl_FragCoord.z , onArcTest);
fColor = gColor;
}
+4 -3
View File
@@ -17,9 +17,10 @@ void main()
angles = vparams[0].xy;
vec3 cenPos = gl_in[0].gl_Position.xyz;
gColor = vColor[0];
float gWdth = vparams[0].w * 0.5;
gRadOut = (vparams[0].z + gWdth) * zoom * 2;
gRadIn = (vparams[0].z - gWdth) * zoom * 2;
float width = vparams[0].w * 0.5;
float rad = vparams[0].z;
gRadOut = (rad + width) * zoom * 2;
gRadIn = (rad - width) * zoom * 2;
cenPosT = vec2 ( (cenPos.x + 1) * 0.5 * winSize.x , (cenPos.y + 1) * 0.5 * winSize.y);
-15
View File
@@ -1,15 +0,0 @@
#version 430 core
out vec4 FragColor;
in vec4 gColor;
in vec2 gTex;
uniform sampler2D aTexture;
void main()
{
FragColor = texture(aTexture, gTex) * gColor;
// FragColor = texture(aTexture, vTexCoord);
// FragColor = gColor;
// FragColor = vec4 (1,1,1,1);
}
-36
View File
@@ -1,36 +0,0 @@
#version 430 core
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
in vec4 vColor [];
in vec2 vTexCoord [];
out vec4 gColor;
out vec2 gTex;
void main()
{
vec3 cenPos = gl_in[0].gl_Position.xyz;
float size = vTexCoord[0].y;
//float size = 0.05;
gColor = vColor[0];
float texPos = vTexCoord[0].x;
gl_Position = vec4 (cenPos.x - size*0.5, cenPos.y - size, cenPos.z , 1);
//gl_Position = vec4 (0, 0 , 5 , 1);
gTex = vec2 (texPos*0.0078125, 1);
EmitVertex();
gl_Position = vec4 (cenPos.x - size*0.5, cenPos.y + size, cenPos.z , 1);
//gl_Position = vec4 (0, 0.5 , 5 , 1);
gTex = vec2 (texPos*0.0078125, 0);
EmitVertex();
gl_Position = vec4 (cenPos.x + size*0.5, cenPos.y - size, cenPos.z , 1);
//gl_Position = vec4 (0.5, 0.5 , -5 , 1);
gTex = vec2 ((texPos+1)*0.0078125, 1);
EmitVertex();
gl_Position = vec4 (cenPos.x + size*0.5, cenPos.y + size, cenPos.z , 1);
gTex = vec2 ((texPos+1)*0.0078125, 0);
//gl_Position = vec4 (0.5, 0 , -5 , 1);
EmitVertex();
EndPrimitive();
}
-20
View File
@@ -1,20 +0,0 @@
#version 430 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec4 aColor;
layout (location = 2) in vec2 aTexCoord;
uniform vec2 winSize;
uniform float zoom;
uniform vec2 translation;
uniform float rotation;
out vec4 vColor;
out vec2 vTexCoord;
void main()
{
gl_Position = vec4(aPos, 1.0);
vColor = aColor;
vTexCoord = aTexCoord;
}
-18
View File
@@ -1,18 +0,0 @@
#version 430 core
in vec4 gColor;
in vec2 cenPosT;
in float gRad;
out vec4 fColor;
out float gl_FragDepth;
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 = gColor;
}
//note it is the fragdepth that stops this from being square
-33
View File
@@ -1,33 +0,0 @@
#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);
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();
}
-19
View File
@@ -1,19 +0,0 @@
#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;
uniform vec2 translation;
uniform float rotation;
uniform mat4 worldMat;
void main()
{
gl_Position = worldMat * vec4(position,1);
vColor = color;
vRad = rad;
}
-2
View File
@@ -4,7 +4,6 @@ in vec4 gColorE;
in vec2 gBoundingBox;
out vec4 fColor;
//out float gl_FragDepth;
void main()
{
@@ -12,4 +11,3 @@ void main()
if ( d > 1) { discard; }
fColor = mix (gColorE , gColorC, d);
}
//note it is the fragdepth that stops this from being square
-5
View File
@@ -6,9 +6,6 @@ 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;
@@ -19,14 +16,12 @@ void main()
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);
-16
View File
@@ -1,16 +0,0 @@
#version 430 core
in vec2 cenPosT;
in vec2 gParams;
out vec4 fColor;
void main()
{
vec2 pos = gl_FragCoord.xy;
float dist = min(1 , 2*distance(pos,cenPosT) / (gParams.x));
//float c = pow(gParams.y*dist,2);
float c = gParams.y * pow(1-dist,2);
//float c = gParams.y;
fColor = vec4( c,c,c ,c );
// fColor = vec4( 1,0,0 , 1);
// fColor = vec4( 1,0,0 , pow(dist,2) );
}
-30
View File
@@ -1,30 +0,0 @@
#version 430 core
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
in vec2 vParams [];
out vec2 gParams;
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);
gParams = vec2( vParams[0].x * zoom * 2, vParams[0].y);
float gRad = gParams.x;
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, 0.9 , 1);
EmitVertex();
gl_Position = vec4 (cenPos.x - gRad/winSize.x, cenPos.y + gRad/winSize.y, 0.9 , 1);
EmitVertex();
gl_Position = vec4 (cenPos.x + gRad/winSize.x, cenPos.y - gRad/winSize.y, 0.9 , 1);
EmitVertex();
gl_Position = vec4 (cenPos.x - gRad/winSize.x, cenPos.y - gRad/winSize.y, 0.9 , 1);
EmitVertex();
EndPrimitive();
}
-15
View File
@@ -1,15 +0,0 @@
#version 430 core
layout (location = 0) in vec4 position;
out vec2 vParams;
uniform vec2 winSize;
uniform float zoom;
uniform vec2 translation;
uniform float rotation;
uniform mat4 worldMat;
void main()
{
gl_Position = vec4(position.xy,0,1);
vParams = position.zw;
}
-12
View File
@@ -1,12 +0,0 @@
#version 430 core
in vec4 gColor;
in vec2 cenPosTrans;
in float gRad;
out vec4 fColor;
void main()
{
vec2 pos = gl_FragCoord.xy;
float dist = max(0 , 1 - 2 * distance(pos,cenPosTrans) / (gRad));
fColor = vec4( gColor.xyz , pow(gColor.z*dist,2) );
}
-30
View File
@@ -1,30 +0,0 @@
#version 430 core
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
in vec4 vColor [];
in float vRad [];
uniform vec2 winSize;
out vec4 gColor;
out float gRad;
out vec2 cenPosTrans;
void main()
{
vec3 cenPos = gl_in[0].gl_Position.xyz;
vec2 cenPosa = cenPos.xy + vec2 (1,1);
cenPosTrans = vec2 (cenPosa * winSize * 0.5);
gColor = vColor[0];
gRad = vRad[0];
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();
}
-12
View File
@@ -1,12 +0,0 @@
#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);
vColor = color;
vRad = rad;
}