add various shaders for various GPU tasks

This commit is contained in:
Jupeyy 2017-09-12 20:05:05 +02:00
parent 2bc27e5f9d
commit 8d982df9f2
14 changed files with 218 additions and 0 deletions

8
shader/bordertile.frag Normal file
View file

@ -0,0 +1,8 @@
#version 330
uniform vec4 vertColor;
void main()
{
gl_FragColor = vertColor;
}

20
shader/bordertile.vert Normal file
View file

@ -0,0 +1,20 @@
#version 330
layout (location = 0) in vec2 inVertex;
uniform mat4 Pos;
uniform vec2 Offset;
uniform vec2 Dir;
uniform int JumpIndex;
void main()
{
vec4 VertPos = vec4(inVertex, -5.0, 1.0);
int XCount = gl_InstanceID - (int(gl_InstanceID/JumpIndex) * JumpIndex);
int YCount = (int(gl_InstanceID/JumpIndex));
VertPos.x += Offset.x + Dir.x * XCount;
VertPos.y += Offset.y + Dir.y * YCount;
gl_Position = Pos * VertPos;
}

View file

@ -0,0 +1,8 @@
#version 330
uniform vec4 vertColor;
void main()
{
gl_FragColor = vertColor;
}

View file

@ -0,0 +1,16 @@
#version 330
layout (location = 0) in vec2 inVertex;
uniform mat4 Pos;
uniform vec2 Dir;
void main()
{
vec4 VertPos = vec4(inVertex, -5.0, 1.0);
VertPos.x += Dir.x * (gl_InstanceID+1);
VertPos.y += Dir.y * (gl_InstanceID+1);
gl_Position = Pos * VertPos;
}

View file

@ -0,0 +1,13 @@
#version 330
uniform sampler2D textureSampler;
uniform vec4 vertColor;
noperspective in vec2 texCoord;
void main()
{
vec4 tex = texture2D(textureSampler, texCoord);
gl_FragColor = tex * vertColor;
}

View file

@ -0,0 +1,26 @@
#version 330
layout (location = 0) in vec2 inVertex;
layout (location = 1) in vec2 inVertexTexCoord;
layout (location = 2) in ivec2 inVertexTexRightOrBottom;
uniform mat4 Pos;
uniform float ZoomFactor;
uniform vec2 Dir;
noperspective out vec2 texCoord;
void main()
{
vec4 VertPos = vec4(inVertex, -5.0, 1.0);
VertPos.x += Dir.x * (gl_InstanceID+1);
VertPos.y += Dir.y * (gl_InstanceID+1);
gl_Position = Pos * VertPos;
float F1 = -(0.75/1024.0) * ZoomFactor;
float F2 = (1.75/1024.0) * ZoomFactor;
float tx = (inVertexTexCoord.x/(16.0)) - (inVertexTexRightOrBottom.x == 0 ? 0.0 : (1.0/1024.0));
float ty = (inVertexTexCoord.y/(16.0)) - (inVertexTexRightOrBottom.y == 0 ? 0.0 : (1.0/1024.0));
texCoord = vec2(tx + (inVertexTexRightOrBottom.x == 0 ? F2 : F1), ty + (inVertexTexRightOrBottom.y == 0 ? F2 : F1));
}

13
shader/bordertiletex.frag Normal file
View file

@ -0,0 +1,13 @@
#version 330
uniform sampler2D textureSampler;
uniform vec4 vertColor;
noperspective in vec2 texCoord;
void main()
{
vec4 tex = texture2D(textureSampler, texCoord);
gl_FragColor = tex * vertColor;
}

30
shader/bordertiletex.vert Normal file
View file

@ -0,0 +1,30 @@
#version 330
layout (location = 0) in vec2 inVertex;
layout (location = 1) in vec2 inVertexTexCoord;
layout (location = 2) in ivec2 inVertexTexRightOrBottom;
uniform mat4 Pos;
uniform float ZoomFactor;
uniform vec2 Offset;
uniform vec2 Dir;
uniform int JumpIndex;
noperspective out vec2 texCoord;
void main()
{
vec4 VertPos = vec4(inVertex, -5.0, 1.0);
int XCount = gl_InstanceID - (int(gl_InstanceID/JumpIndex) * JumpIndex);
int YCount = (int(gl_InstanceID/JumpIndex));
VertPos.x += Offset.x + Dir.x * XCount;
VertPos.y += Offset.y + Dir.y * YCount;
gl_Position = Pos * VertPos;
float F1 = -(0.75/1024.0) * ZoomFactor;
float F2 = (1.75/1024.0) * ZoomFactor;
float tx = (inVertexTexCoord.x/(16.0)) - (inVertexTexRightOrBottom.x == 0 ? 0.0 : (1.0/1024.0));
float ty = (inVertexTexCoord.y/(16.0)) - (inVertexTexRightOrBottom.y == 0 ? 0.0 : (1.0/1024.0));
texCoord = vec2(tx + (inVertexTexRightOrBottom.x == 0 ? F2 : F1), ty + (inVertexTexRightOrBottom.y == 0 ? F2 : F1));
}

16
shader/prim.frag Normal file
View file

@ -0,0 +1,16 @@
#version 330
uniform int isTextured;
uniform sampler2D textureSampler;
noperspective in vec2 texCoord;
noperspective in vec4 vertColor;
void main()
{
if(isTextured == 1) {
vec4 tex = texture2D(textureSampler, texCoord);
gl_FragColor = tex * vertColor;
}
else gl_FragColor = vertColor;
}

17
shader/prim.vert Normal file
View file

@ -0,0 +1,17 @@
#version 330
layout (location = 0) in vec3 inVertex;
layout (location = 1) in vec2 inVertexTexCoord;
layout (location = 2) in vec4 inVertexColor;
uniform mat4 Pos;
noperspective out vec2 texCoord;
noperspective out vec4 vertColor;
void main()
{
gl_Position = Pos * vec4(inVertex, 1.0);
texCoord = inVertexTexCoord;
vertColor = inVertexColor;
}

8
shader/tile.frag Normal file
View file

@ -0,0 +1,8 @@
#version 330
uniform vec4 vertColor;
void main()
{
gl_FragColor = vertColor;
}

10
shader/tile.vert Normal file
View file

@ -0,0 +1,10 @@
#version 330
layout (location = 0) in vec2 inVertex;
uniform mat4 Pos;
void main()
{
gl_Position = Pos * vec4(inVertex, -5.0, 1.0);
}

13
shader/tiletex.frag Normal file
View file

@ -0,0 +1,13 @@
#version 330
uniform sampler2D textureSampler;
uniform vec4 vertColor;
noperspective in vec2 texCoord;
void main()
{
vec4 tex = texture2D(textureSampler, texCoord);
gl_FragColor = tex * vertColor;
}

20
shader/tiletex.vert Normal file
View file

@ -0,0 +1,20 @@
#version 330
layout (location = 0) in vec2 inVertex;
layout (location = 1) in vec2 inVertexTexCoord;
layout (location = 2) in ivec2 inVertexTexRightOrBottom;
uniform mat4 Pos;
uniform float ZoomFactor;
noperspective out vec2 texCoord;
void main()
{
gl_Position = Pos * vec4(inVertex, -5.0, 1.0);
float F1 = -(0.75/1024.0) * ZoomFactor;
float F2 = (1.75/1024.0) * ZoomFactor;
float tx = (inVertexTexCoord.x/(16.0)) - (inVertexTexRightOrBottom.x == 0 ? 0.0 : (1.0/1024.0));
float ty = (inVertexTexCoord.y/(16.0)) - (inVertexTexRightOrBottom.y == 0 ? 0.0 : (1.0/1024.0));
texCoord = vec2(tx + (inVertexTexRightOrBottom.x == 0 ? F2 : F1), ty + (inVertexTexRightOrBottom.y == 0 ? F2 : F1));
}