diff --git a/shader/basic.frag b/shader/basic.frag new file mode 100644 index 000000000..aedc197fd --- /dev/null +++ b/shader/basic.frag @@ -0,0 +1,7 @@ +#version 430 core +in vec4 vColor; +out vec4 fColor; +void main() +{ + fColor = vColor; +} diff --git a/shader/basic.vert b/shader/basic.vert new file mode 100644 index 000000000..a9cb79602 --- /dev/null +++ b/shader/basic.vert @@ -0,0 +1,9 @@ +#version 430 core +layout (location = 0) in vec3 position; +layout (location = 1) in vec4 color; +out vec4 vColor; +void main() +{ + gl_Position = vec4(position,1); + vColor = color; +} diff --git a/shader/basicTexture.frag b/shader/basicTexture.frag new file mode 100644 index 000000000..a1cefb0e9 --- /dev/null +++ b/shader/basicTexture.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/basicTexture.geom b/shader/basicTexture.geom new file mode 100644 index 000000000..a3e1851e4 --- /dev/null +++ b/shader/basicTexture.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/basicTexture.vert b/shader/basicTexture.vert new file mode 100644 index 000000000..11474be8c --- /dev/null +++ b/shader/basicTexture.vert @@ -0,0 +1,15 @@ +#version 430 core +layout (location = 0) in vec3 aPos; +layout (location = 1) in vec4 aColor; +layout (location = 2) in vec2 aTexCoord; + +out vec4 vColor; +out vec2 vTexCoord; + +void main() +{ + gl_Position = vec4(aPos, 1.0); + vColor = aColor; + vTexCoord = aTexCoord; +} + diff --git a/shader/fadeCircle.frag b/shader/fadeCircle.frag new file mode 100644 index 000000000..45ca0c969 --- /dev/null +++ b/shader/fadeCircle.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/fadeCircle.geom b/shader/fadeCircle.geom new file mode 100644 index 000000000..4d696433c --- /dev/null +++ b/shader/fadeCircle.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/fadeCircle.vert b/shader/fadeCircle.vert new file mode 100644 index 000000000..2046f8894 --- /dev/null +++ b/shader/fadeCircle.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; +}