From 37822c3ad29f0d40115ddbf2bd9118d922218ceb Mon Sep 17 00:00:00 2001 From: jgk Date: Fri, 5 Mar 2021 20:24:49 +0100 Subject: [PATCH] Track new shaders --- shader/character.frag | 15 +++++++++++++++ shader/character.geom | 36 ++++++++++++++++++++++++++++++++++++ shader/character.vert | 21 +++++++++++++++++++++ shader/fullFadeCircle.frag | 12 ++++++++++++ shader/fullFadeCircle.geom | 30 ++++++++++++++++++++++++++++++ shader/fullFadeCircle.vert | 12 ++++++++++++ 6 files changed, 126 insertions(+) create mode 100644 shader/character.frag create mode 100644 shader/character.geom create mode 100644 shader/character.vert create mode 100644 shader/fullFadeCircle.frag create mode 100644 shader/fullFadeCircle.geom create mode 100644 shader/fullFadeCircle.vert diff --git a/shader/character.frag b/shader/character.frag new file mode 100644 index 000000000..a1cefb0e9 --- /dev/null +++ b/shader/character.frag @@ -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); +} diff --git a/shader/character.geom b/shader/character.geom new file mode 100644 index 000000000..a3e1851e4 --- /dev/null +++ b/shader/character.geom @@ -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(); + +} diff --git a/shader/character.vert b/shader/character.vert new file mode 100644 index 000000000..c9d3000e9 --- /dev/null +++ b/shader/character.vert @@ -0,0 +1,21 @@ +#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; +uniform mat4 worldMat; + +out vec4 vColor; +out vec2 vTexCoord; + +void main() +{ + gl_Position = vec4(aPos, 1.0); + vColor = aColor; + vTexCoord = aTexCoord; +} + diff --git a/shader/fullFadeCircle.frag b/shader/fullFadeCircle.frag new file mode 100644 index 000000000..45ca0c969 --- /dev/null +++ b/shader/fullFadeCircle.frag @@ -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) ); +} diff --git a/shader/fullFadeCircle.geom b/shader/fullFadeCircle.geom new file mode 100644 index 000000000..4d696433c --- /dev/null +++ b/shader/fullFadeCircle.geom @@ -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(); + +} diff --git a/shader/fullFadeCircle.vert b/shader/fullFadeCircle.vert new file mode 100644 index 000000000..2046f8894 --- /dev/null +++ b/shader/fullFadeCircle.vert @@ -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; +}