Reorganise shaders

This commit is contained in:
jgk
2021-03-21 12:50:27 +01:00
parent a8ebf2f7f1
commit cf5a8b3e1b
32 changed files with 22 additions and 60 deletions
+34
View File
@@ -0,0 +1,34 @@
#version 430 core
in vec4 gColor;
in vec2 cenPosT;
in float gRadIn;
in float gRadOut;
in vec2 angles;
out vec4 fColor;
out float gl_FragDepth;
uniform float rotation;
void main()
{
vec2 pos = gl_FragCoord.xy;
float d = distance(pos,cenPosT);
float dTest = max ( step(gRadOut/2,d)
, 1 - step(gRadIn/2,d)
);
vec2 posDiff = pos - cenPosT;
float sa = angles.x - rotation;
vec2 sv = vec2 (-sin(sa), cos(sa));
float saTest = dot(sv,posDiff) >= 0 ? 0 : 1;
float ea = angles.y - rotation;
vec2 ev = vec2 (-sin(ea), cos(ea));
float eaTest = dot(ev,posDiff) <= 0 ? 0 : 1;
float aTest = ea - sa < radians(180) ? max (saTest,eaTest)
: min (saTest,eaTest);
float onArcTest = max(dTest,aTest);
gl_FragDepth = max(gl_FragCoord.z , onArcTest);
fColor = gColor;
}
+37
View File
@@ -0,0 +1,37 @@
#version 430 core
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
in vec4 vColor [];
in vec4 vparams [];
out vec4 gColor;
out float gRadIn;
out float gRadOut;
out vec2 cenPosT;
out vec2 angles;
uniform vec2 winSize;
uniform float zoom;
void main()
{
angles = vparams[0].xy;
vec3 cenPos = gl_in[0].gl_Position.xyz;
gColor = vColor[0];
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);
gl_Position = vec4 (cenPos.x + gRadOut/winSize.x, cenPos.y + gRadOut/winSize.y, cenPos.z , 1);
EmitVertex();
gl_Position = vec4 (cenPos.x - gRadOut/winSize.x, cenPos.y + gRadOut/winSize.y, cenPos.z , 1);
EmitVertex();
gl_Position = vec4 (cenPos.x + gRadOut/winSize.x, cenPos.y - gRadOut/winSize.y, cenPos.z , 1);
EmitVertex();
gl_Position = vec4 (cenPos.x - gRadOut/winSize.x, cenPos.y - gRadOut/winSize.y, cenPos.z , 1);
EmitVertex();
EndPrimitive();
}
+19
View File
@@ -0,0 +1,19 @@
#version 430 core
layout (location = 0) in vec3 position;
layout (location = 1) in vec4 color;
layout (location = 2) in vec4 saEaRadWdth;
out vec4 vColor;
out vec4 vparams;
uniform vec2 winSize;
uniform float zoom;
uniform vec2 translation;
uniform float rotation;
uniform mat4 worldMat;
void main()
{
gl_Position = worldMat * vec4(position.xyz,1);
vColor = color;
vparams = saEaRadWdth;
}
+7
View File
@@ -0,0 +1,7 @@
#version 430 core
in vec4 vColor;
out vec4 fColor;
void main()
{
fColor = vColor;
}
+16
View File
@@ -0,0 +1,16 @@
#version 430 core
layout (location = 0) in vec3 position;
layout (location = 1) in vec4 color;
out vec4 vColor;
uniform vec2 winSize;
uniform float zoom;
uniform float rotation;
uniform vec2 translation;
uniform mat4 worldMat;
void main()
{
gl_Position = worldMat * vec4(position.xyz,1);
vColor = color;
}
+18
View File
@@ -0,0 +1,18 @@
#version 430 core
in vec4 vColor;
in vec2 boxOut;
in vec2 boxIn;
out vec4 fColor;
void main()
{
//float d = x - y - 1 + 2* sqrt(y);
float d = sqrt(boxOut.x) + sqrt(boxOut.y) - 1;
// float e = sqrt(f(x,wStart)) + sqrt(f(y,wEnd)) - 1.0;
float e = sqrt(boxIn.x) + sqrt(boxIn.y) - 1.0;
if ( d < 0 || e > 0) { discard; }
fColor = vColor;
// if ( d < 0 || e > 0) { fColor = vec4(0,0,1,1); }
// if ( d < 0 || e > 0) { fColor = vec4(0,0,1,1); }
}
+76
View File
@@ -0,0 +1,76 @@
#version 430 core
layout (triangles) in;
layout (triangle_strip, max_vertices = 5) out;
in vec4 vColor[];
in vec2 vPosOff[];
in float vRadMag[];
out vec4 gColor;
out float wStart;
out float wEnd;
out vec3 gBoundingBox;
out vec2 box2 ;
vec2 normV2 (vec2 v)
{ return vec2(-v.y,v.x) ;
}
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;
vec3 pb = gl_in[1].gl_Position.xyz;
vec3 pc = gl_in[2].gl_Position.xyz;
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);
EmitVertex();
EndPrimitive();
}
+21
View File
@@ -0,0 +1,21 @@
#version 430 core
layout (location = 0) in vec3 position;
layout (location = 1) in vec4 color;
layout (location = 2) in vec4 boxes;
out vec4 vColor;
out vec2 boxOut;
out vec2 boxIn;
uniform vec2 winSize;
uniform float zoom;
uniform float rotation;
uniform vec2 translation;
uniform mat4 worldMat;
void main()
{
gl_Position = worldMat * vec4(position.xyz,1);
vColor = color;
boxOut = boxes.xy ;
boxIn = boxes.zw ;
}
+15
View File
@@ -0,0 +1,15 @@
#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);
}
+37
View File
@@ -0,0 +1,37 @@
#version 430 core
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
in vec4 vColor [];
in vec3 vTexCoord [];
out vec4 gColor;
out vec2 gTex;
void main()
{
vec3 cenPos = gl_in[0].gl_Position.xyz;
float sizex = vTexCoord[0].y;
float sizey = vTexCoord[0].z;
//float size = 0.05;
gColor = vColor[0];
float texPos = vTexCoord[0].x;
gl_Position = vec4 (cenPos.x - sizex*0.5, cenPos.y - sizey*0.5, cenPos.z , 1);
//gl_Position = vec4 (0, 0 , 5 , 1);
gTex = vec2 (texPos*0.0078125, 1);
EmitVertex();
gl_Position = vec4 (cenPos.x - sizex*0.5, cenPos.y + sizey*0.5, cenPos.z , 1);
//gl_Position = vec4 (0, 0.5 , 5 , 1);
gTex = vec2 (texPos*0.0078125, 0);
EmitVertex();
gl_Position = vec4 (cenPos.x + sizex*0.5, cenPos.y - sizey*0.5, 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 + sizex*0.5, cenPos.y + sizey*0.5, cenPos.z , 1);
gTex = vec2 ((texPos+1)*0.0078125, 0);
//gl_Position = vec4 (0.5, 0 , -5 , 1);
EmitVertex();
EndPrimitive();
}
+21
View File
@@ -0,0 +1,21 @@
#version 430 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec4 aColor;
layout (location = 2) in vec3 aTexCoord;
uniform vec2 winSize;
uniform float zoom;
uniform vec2 translation;
uniform float rotation;
uniform mat4 worldMat;
out vec4 vColor;
out vec3 vTexCoord;
void main()
{
gl_Position = vec4(aPos, 1.0);
vColor = aColor;
vTexCoord = aTexCoord;
}
+13
View File
@@ -0,0 +1,13 @@
#version 430 core
in vec4 gColorC;
in vec4 gColorE;
in vec2 gBoundingBox;
out vec4 fColor;
void main()
{
float d = dot(gBoundingBox,gBoundingBox);
if ( d > 1) { discard; }
fColor = mix (gColorE , gColorC, d);
}
+31
View File
@@ -0,0 +1,31 @@
#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;
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);
EmitVertex();
gBoundingBox = vec2 (1,1);
gl_Position = vec4 (pa, 1);
EmitVertex();
gBoundingBox = vec2 (-1,-1);
gl_Position = vec4 (pc, 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;
}