First implementation of quadratic bezier curve shader
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#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();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#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
|
||||
@@ -0,0 +1,33 @@
|
||||
#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();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#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;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#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) );
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#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();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#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;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#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) );
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#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();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#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;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#version 430 core
|
||||
in vec4 gColor;
|
||||
in vec3 gBoundingBox;
|
||||
|
||||
out vec4 fColor;
|
||||
|
||||
float x = gBoundingBox.x;
|
||||
float y = gBoundingBox.y;
|
||||
float z = gBoundingBox.z;
|
||||
|
||||
void main()
|
||||
{
|
||||
//float d = x - y - 1 + 2* sqrt(y);
|
||||
float d = sqrt(x) + sqrt(y) - 1;
|
||||
// if ( d < -0.1 || d > 0.1) { discard; }
|
||||
fColor = gColor;
|
||||
if ( d < -z*0.1 || d > z*0.1) { fColor = vec4 (0,1,0,1); }
|
||||
if ( d < -0.1 || d > 0.1) { fColor = vec4 (0,0,1,1); }
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#version 430 core
|
||||
layout (triangles) in;
|
||||
layout (triangle_strip, max_vertices = 3) out;
|
||||
in vec4 vColor[];
|
||||
out vec4 gColor;
|
||||
out vec3 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;
|
||||
|
||||
gBoundingBox = vec3 (1,0,1);
|
||||
gColor = vColor[0];
|
||||
gl_Position = vec4 (pa, 1);
|
||||
EmitVertex();
|
||||
gBoundingBox = vec3 (0,0,-0.9);
|
||||
gColor = vColor[1];
|
||||
gl_Position = vec4 (pb, 1);
|
||||
EmitVertex();
|
||||
gBoundingBox = vec3 (0,1,1);
|
||||
gColor = vColor[2];
|
||||
gl_Position = vec4 (pc, 1);
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user