mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 06:58:20 +00:00
add various shaders for various GPU tasks
This commit is contained in:
parent
2bc27e5f9d
commit
8d982df9f2
8
shader/bordertile.frag
Normal file
8
shader/bordertile.frag
Normal file
|
@ -0,0 +1,8 @@
|
|||
#version 330
|
||||
|
||||
uniform vec4 vertColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vertColor;
|
||||
}
|
20
shader/bordertile.vert
Normal file
20
shader/bordertile.vert
Normal 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;
|
||||
}
|
8
shader/bordertileline.frag
Normal file
8
shader/bordertileline.frag
Normal file
|
@ -0,0 +1,8 @@
|
|||
#version 330
|
||||
|
||||
uniform vec4 vertColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vertColor;
|
||||
}
|
16
shader/bordertileline.vert
Normal file
16
shader/bordertileline.vert
Normal 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;
|
||||
}
|
13
shader/bordertilelinetex.frag
Normal file
13
shader/bordertilelinetex.frag
Normal 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;
|
||||
}
|
26
shader/bordertilelinetex.vert
Normal file
26
shader/bordertilelinetex.vert
Normal 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
13
shader/bordertiletex.frag
Normal 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
30
shader/bordertiletex.vert
Normal 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
16
shader/prim.frag
Normal 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
17
shader/prim.vert
Normal 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
8
shader/tile.frag
Normal file
|
@ -0,0 +1,8 @@
|
|||
#version 330
|
||||
|
||||
uniform vec4 vertColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vertColor;
|
||||
}
|
10
shader/tile.vert
Normal file
10
shader/tile.vert
Normal 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
13
shader/tiletex.frag
Normal 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
20
shader/tiletex.vert
Normal 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));
|
||||
}
|
Loading…
Reference in a new issue