summaryrefslogtreecommitdiff
path: root/source/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'source/shaders')
-rwxr-xr-xsource/shaders/colored_quad.fs.glsl8
-rwxr-xr-xsource/shaders/colored_quad.vs.glsl10
-rwxr-xr-xsource/shaders/ui_text.fs.glsl15
-rwxr-xr-xsource/shaders/ui_text.vs.glsl16
4 files changed, 49 insertions, 0 deletions
diff --git a/source/shaders/colored_quad.fs.glsl b/source/shaders/colored_quad.fs.glsl
new file mode 100755
index 0000000..095a90e
--- /dev/null
+++ b/source/shaders/colored_quad.fs.glsl
@@ -0,0 +1,8 @@
+#version 330 core
+
+uniform vec3 Color;
+out vec4 FragColor;
+
+void main() {
+ FragColor = vec4(Color, 1.0);
+};
diff --git a/source/shaders/colored_quad.vs.glsl b/source/shaders/colored_quad.vs.glsl
new file mode 100755
index 0000000..ac64c49
--- /dev/null
+++ b/source/shaders/colored_quad.vs.glsl
@@ -0,0 +1,10 @@
+#version 330 core
+layout(location=0) in vec3 aPos;
+
+uniform mat4 Model;
+uniform mat4 View;
+uniform mat4 Projection;
+
+void main() {
+ gl_Position = Projection * View * Model * vec4(aPos, 1.0);
+}
diff --git a/source/shaders/ui_text.fs.glsl b/source/shaders/ui_text.fs.glsl
new file mode 100755
index 0000000..ca2c249
--- /dev/null
+++ b/source/shaders/ui_text.fs.glsl
@@ -0,0 +1,15 @@
+#version 330 core
+
+in vec2 TexCoords;
+flat in int Index;
+uniform sampler2DArray TextureAtlas;
+uniform int TextureMap[32];
+uniform vec3 TextColor;
+out vec4 FragColor;
+
+void main() {
+ int TextureId = TextureMap[Index];
+ vec3 TextureIndexCoords = vec3(TexCoords.xy, TextureId);
+ vec4 sampled = vec4(1.0, 1.0, 1.0, texture(TextureAtlas, TextureIndexCoords).r);
+ FragColor = sampled * vec4(TextColor, 1);
+};
diff --git a/source/shaders/ui_text.vs.glsl b/source/shaders/ui_text.vs.glsl
new file mode 100755
index 0000000..9bba904
--- /dev/null
+++ b/source/shaders/ui_text.vs.glsl
@@ -0,0 +1,16 @@
+#version 330 core
+layout(location=0) in vec2 aPos;
+
+uniform mat4 Projection;
+uniform mat4 View;
+uniform mat4 LetterTransforms[32];
+out vec2 TexCoords;
+flat out int Index;
+
+void main() {
+ gl_Position = Projection * View * LetterTransforms[gl_InstanceID] * vec4(aPos, 0.0, 1.0);
+ vec2 tex = aPos;
+ TexCoords = tex;
+ TexCoords.y = 1.0 - TexCoords.y;
+ Index = gl_InstanceID;
+}