aboutsummaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
Diffstat (limited to 'res')
-rw-r--r--res/fonts/NotoSansMono-SemiBold.ttfbin0 -> 517044 bytes
-rw-r--r--res/models/player/player.mtl52
-rw-r--r--res/models/player/player.obj303
-rw-r--r--res/shaders/face.fs15
-rw-r--r--res/shaders/face.vs12
-rw-r--r--res/shaders/framebuffer.fs100
-rw-r--r--res/shaders/framebuffer.vs9
-rw-r--r--res/shaders/line.fs55
-rw-r--r--res/shaders/line.vs8
-rw-r--r--res/shaders/model.fs9
-rw-r--r--res/shaders/model.vs13
-rw-r--r--res/shaders/postprocess.fs105
-rw-r--r--res/shaders/rectangle.fs9
-rw-r--r--res/shaders/rectangle.vs8
-rw-r--r--res/shaders/text.fs13
-rw-r--r--res/shaders/text.vs14
-rw-r--r--res/textures/atlas.pngbin0 -> 14972 bytes
-rw-r--r--res/textures/atlas.xcfbin0 -> 96453 bytes
-rw-r--r--res/textures/debug.pngbin0 -> 26072 bytes
19 files changed, 725 insertions, 0 deletions
diff --git a/res/fonts/NotoSansMono-SemiBold.ttf b/res/fonts/NotoSansMono-SemiBold.ttf
new file mode 100644
index 0000000..869df6a
--- /dev/null
+++ b/res/fonts/NotoSansMono-SemiBold.ttf
Binary files differ
diff --git a/res/models/player/player.mtl b/res/models/player/player.mtl
new file mode 100644
index 0000000..0e66d07
--- /dev/null
+++ b/res/models/player/player.mtl
@@ -0,0 +1,52 @@
+# Blender MTL File: 'untitled.blend'
+# Material Count: 5
+
+newmtl Material
+Ns 323.999994
+Ka 1.000000 1.000000 1.000000
+Kd 0.800000 0.800000 0.800000
+Ks 0.500000 0.500000 0.500000
+Ke 0.000000 0.000000 0.000000
+Ni 1.450000
+d 1.000000
+illum 2
+
+newmtl Material.001
+Ns 323.999994
+Ka 1.000000 1.000000 1.000000
+Kd 0.800000 0.800000 0.800000
+Ks 0.500000 0.500000 0.500000
+Ke 0.000000 0.000000 0.000000
+Ni 1.450000
+d 1.000000
+illum 2
+
+newmtl Material.002
+Ns 323.999994
+Ka 1.000000 1.000000 1.000000
+Kd 0.800000 0.800000 0.800000
+Ks 0.500000 0.500000 0.500000
+Ke 0.000000 0.000000 0.000000
+Ni 1.450000
+d 1.000000
+illum 2
+
+newmtl Material.003
+Ns 323.999994
+Ka 1.000000 1.000000 1.000000
+Kd 0.800000 0.800000 0.800000
+Ks 0.500000 0.500000 0.500000
+Ke 0.000000 0.000000 0.000000
+Ni 1.450000
+d 1.000000
+illum 2
+
+newmtl Material.004
+Ns 323.999994
+Ka 1.000000 1.000000 1.000000
+Kd 0.800000 0.800000 0.800000
+Ks 0.500000 0.500000 0.500000
+Ke 0.000000 0.000000 0.000000
+Ni 1.450000
+d 1.000000
+illum 2
diff --git a/res/models/player/player.obj b/res/models/player/player.obj
new file mode 100644
index 0000000..d832a3b
--- /dev/null
+++ b/res/models/player/player.obj
@@ -0,0 +1,303 @@
+# Blender v2.93.1 OBJ File: 'untitled.blend'
+# www.blender.org
+mtllib player.mtl
+o body_Cube
+v 0.149342 0.672327 -0.316988
+v 0.149342 -0.437780 -0.316988
+v 0.149342 0.672327 0.320204
+v 0.149342 -0.437780 0.320204
+v -0.149342 0.672327 -0.316988
+v -0.149342 -0.437780 -0.316988
+v -0.149342 0.672327 0.320204
+v -0.149342 -0.437780 0.320204
+v 0.149342 0.672327 0.320204
+v -0.149342 0.672327 0.320204
+v 0.149342 0.672327 -0.316988
+v -0.149342 0.672327 -0.316988
+vt 0.625000 1.000000
+vt 0.625000 0.750000
+vt 0.625000 0.750000
+vt 0.625000 1.000000
+vt 0.375000 0.750000
+vt 0.375000 1.000000
+vt 0.375000 0.000000
+vt 0.625000 0.000000
+vt 0.625000 0.250000
+vt 0.375000 0.250000
+vt 0.125000 0.500000
+vt 0.375000 0.500000
+vt 0.125000 0.750000
+vt 0.625000 0.500000
+vt 0.625000 0.500000
+vt 0.875000 0.500000
+vt 0.875000 0.750000
+vt 0.625000 0.000000
+vt 0.625000 0.250000
+vn 0.0000 0.0000 1.0000
+vn -1.0000 0.0000 0.0000
+vn 0.0000 -1.0000 0.0000
+vn 1.0000 0.0000 0.0000
+vn 0.0000 0.0000 -1.0000
+vn 0.0000 1.0000 0.0000
+usemtl Material
+s off
+f 7/1/1 3/2/1 9/3/1 10/4/1
+f 4/5/1 3/2/1 7/1/1 8/6/1
+f 8/7/2 7/8/2 5/9/2 6/10/2
+f 6/11/3 2/12/3 4/5/3 8/13/3
+f 2/12/4 1/14/4 3/2/4 4/5/4
+f 6/10/5 5/9/5 1/14/5 2/12/5
+f 11/15/6 12/16/6 10/17/6 9/3/6
+f 5/9/1 7/8/1 10/18/1 12/19/1
+f 3/2/1 1/14/1 11/15/1 9/3/1
+f 1/14/1 5/9/1 12/19/1 11/15/1
+o leg1_Cube.001
+v 0.149342 -0.434399 0.001608
+v 0.149342 -1.212760 0.001608
+v 0.149342 -0.434399 0.320204
+v 0.149342 -1.212760 0.320204
+v -0.149342 -0.434399 0.001608
+v -0.149342 -1.212760 0.001608
+v -0.149342 -0.434399 0.320204
+v -0.149342 -1.212760 0.320204
+v 0.149342 -0.434399 0.320204
+v -0.149342 -0.434399 0.320204
+v 0.149342 -0.434399 0.001608
+v -0.149342 -0.434399 0.001608
+vt 0.625000 1.000000
+vt 0.625000 0.750000
+vt 0.625000 0.750000
+vt 0.625000 1.000000
+vt 0.375000 0.750000
+vt 0.375000 1.000000
+vt 0.375000 0.000000
+vt 0.625000 0.000000
+vt 0.625000 0.250000
+vt 0.375000 0.250000
+vt 0.125000 0.500000
+vt 0.375000 0.500000
+vt 0.125000 0.750000
+vt 0.625000 0.500000
+vt 0.625000 0.500000
+vt 0.875000 0.500000
+vt 0.875000 0.750000
+vt 0.625000 0.000000
+vt 0.625000 0.250000
+vn 0.0000 0.0000 1.0000
+vn -1.0000 0.0000 0.0000
+vn 0.0000 -1.0000 0.0000
+vn 1.0000 0.0000 0.0000
+vn 0.0000 0.0000 -1.0000
+vn 0.0000 1.0000 0.0000
+usemtl Material.001
+s off
+f 19/20/7 15/21/7 21/22/7 22/23/7
+f 16/24/7 15/21/7 19/20/7 20/25/7
+f 20/26/8 19/27/8 17/28/8 18/29/8
+f 18/30/9 14/31/9 16/24/9 20/32/9
+f 14/31/10 13/33/10 15/21/10 16/24/10
+f 18/29/11 17/28/11 13/33/11 14/31/11
+f 23/34/12 24/35/12 22/36/12 21/22/12
+f 17/28/7 19/27/7 22/37/7 24/38/7
+f 15/21/7 13/33/7 23/34/7 21/22/7
+f 13/33/7 17/28/7 24/38/7 23/34/7
+o leg2_Cube.002
+v 0.149342 -0.434399 -0.316988
+v 0.149342 -1.212760 -0.316988
+v 0.149342 -0.434399 0.001608
+v 0.149342 -1.212760 0.001608
+v -0.149342 -0.434399 -0.316988
+v -0.149342 -1.212760 -0.316988
+v -0.149342 -0.434399 0.001608
+v -0.149342 -1.212760 0.001608
+v 0.149342 -0.434399 0.001608
+v -0.149342 -0.434399 0.001608
+v 0.149342 -0.434399 -0.316988
+v -0.149342 -0.434399 -0.316988
+vt 0.625000 1.000000
+vt 0.625000 0.750000
+vt 0.625000 0.750000
+vt 0.625000 1.000000
+vt 0.375000 0.750000
+vt 0.375000 1.000000
+vt 0.375000 0.000000
+vt 0.625000 0.000000
+vt 0.625000 0.250000
+vt 0.375000 0.250000
+vt 0.125000 0.500000
+vt 0.375000 0.500000
+vt 0.125000 0.750000
+vt 0.625000 0.500000
+vt 0.625000 0.500000
+vt 0.875000 0.500000
+vt 0.875000 0.750000
+vt 0.625000 0.000000
+vt 0.625000 0.250000
+vn 0.0000 0.0000 1.0000
+vn -1.0000 0.0000 0.0000
+vn 0.0000 -1.0000 0.0000
+vn 1.0000 0.0000 0.0000
+vn 0.0000 0.0000 -1.0000
+vn 0.0000 1.0000 0.0000
+usemtl Material.001
+s off
+f 31/39/13 27/40/13 33/41/13 34/42/13
+f 28/43/13 27/40/13 31/39/13 32/44/13
+f 32/45/14 31/46/14 29/47/14 30/48/14
+f 30/49/15 26/50/15 28/43/15 32/51/15
+f 26/50/16 25/52/16 27/40/16 28/43/16
+f 30/48/17 29/47/17 25/52/17 26/50/17
+f 35/53/18 36/54/18 34/55/18 33/41/18
+f 29/47/13 31/46/13 34/56/13 36/57/13
+f 27/40/13 25/52/13 35/53/13 33/41/13
+f 25/52/13 29/47/13 36/57/13 35/53/13
+o arm1_Cube.003
+v 0.149342 0.671449 -0.634468
+v 0.149342 -0.106912 -0.634468
+v 0.149342 0.671449 -0.315872
+v 0.149342 -0.106912 -0.315872
+v -0.149342 0.671449 -0.634468
+v -0.149342 -0.106912 -0.634468
+v -0.149342 0.671449 -0.315872
+v -0.149342 -0.106912 -0.315872
+v 0.149342 0.671449 -0.315872
+v -0.149342 0.671449 -0.315872
+v 0.149342 0.671449 -0.634468
+v -0.149342 0.671449 -0.634468
+vt 0.625000 1.000000
+vt 0.625000 0.750000
+vt 0.625000 0.750000
+vt 0.625000 1.000000
+vt 0.375000 0.750000
+vt 0.375000 1.000000
+vt 0.375000 0.000000
+vt 0.625000 0.000000
+vt 0.625000 0.250000
+vt 0.375000 0.250000
+vt 0.125000 0.500000
+vt 0.375000 0.500000
+vt 0.125000 0.750000
+vt 0.625000 0.500000
+vt 0.625000 0.500000
+vt 0.875000 0.500000
+vt 0.875000 0.750000
+vt 0.625000 0.000000
+vt 0.625000 0.250000
+vn 0.0000 0.0000 1.0000
+vn -1.0000 0.0000 0.0000
+vn 0.0000 -1.0000 0.0000
+vn 1.0000 0.0000 0.0000
+vn 0.0000 0.0000 -1.0000
+vn 0.0000 1.0000 0.0000
+usemtl Material.002
+s off
+f 43/58/19 39/59/19 45/60/19 46/61/19
+f 40/62/19 39/59/19 43/58/19 44/63/19
+f 44/64/20 43/65/20 41/66/20 42/67/20
+f 42/68/21 38/69/21 40/62/21 44/70/21
+f 38/69/22 37/71/22 39/59/22 40/62/22
+f 42/67/23 41/66/23 37/71/23 38/69/23
+f 47/72/24 48/73/24 46/74/24 45/60/24
+f 41/66/19 43/65/19 46/75/19 48/76/19
+f 39/59/19 37/71/19 47/72/19 45/60/19
+f 37/71/19 41/66/19 48/76/19 47/72/19
+o arm2_Cube.004
+v 0.149342 0.671449 0.309439
+v 0.149342 -0.106912 0.309439
+v 0.149342 0.671449 0.628035
+v 0.149342 -0.106912 0.628035
+v -0.149342 0.671449 0.309439
+v -0.149342 -0.106912 0.309439
+v -0.149342 0.671449 0.628035
+v -0.149342 -0.106912 0.628035
+v 0.149342 0.671449 0.628035
+v -0.149342 0.671449 0.628035
+v 0.149342 0.671449 0.309439
+v -0.149342 0.671449 0.309439
+vt 0.625000 1.000000
+vt 0.625000 0.750000
+vt 0.625000 0.750000
+vt 0.625000 1.000000
+vt 0.375000 0.750000
+vt 0.375000 1.000000
+vt 0.375000 0.000000
+vt 0.625000 0.000000
+vt 0.625000 0.250000
+vt 0.375000 0.250000
+vt 0.125000 0.500000
+vt 0.375000 0.500000
+vt 0.125000 0.750000
+vt 0.625000 0.500000
+vt 0.625000 0.500000
+vt 0.875000 0.500000
+vt 0.875000 0.750000
+vt 0.625000 0.000000
+vt 0.625000 0.250000
+vn 0.0000 0.0000 1.0000
+vn -1.0000 0.0000 0.0000
+vn 0.0000 -1.0000 0.0000
+vn 1.0000 0.0000 0.0000
+vn 0.0000 0.0000 -1.0000
+vn 0.0000 1.0000 0.0000
+usemtl Material.003
+s off
+f 55/77/25 51/78/25 57/79/25 58/80/25
+f 52/81/25 51/78/25 55/77/25 56/82/25
+f 56/83/26 55/84/26 53/85/26 54/86/26
+f 54/87/27 50/88/27 52/81/27 56/89/27
+f 50/88/28 49/90/28 51/78/28 52/81/28
+f 54/86/29 53/85/29 49/90/29 50/88/29
+f 59/91/30 60/92/30 58/93/30 57/79/30
+f 53/85/25 55/84/25 58/94/25 60/95/25
+f 51/78/25 49/90/25 59/91/25 57/79/25
+f 49/90/25 53/85/25 60/95/25 59/91/25
+o head_Cube.005
+v 0.181572 1.115948 -0.225332
+v 0.181572 0.664154 -0.225332
+v 0.181572 1.115948 0.228549
+v 0.181572 0.664154 0.228549
+v -0.181572 1.115948 -0.225332
+v -0.181572 0.664154 -0.225332
+v -0.181572 1.115948 0.228549
+v -0.181572 0.664154 0.228549
+v 0.181572 1.115948 0.228549
+v -0.181572 1.115948 0.228549
+v 0.181572 1.115948 -0.225332
+v -0.181572 1.115948 -0.225332
+vt 0.625000 1.000000
+vt 0.625000 0.750000
+vt 0.625000 0.750000
+vt 0.625000 1.000000
+vt 0.375000 0.750000
+vt 0.375000 1.000000
+vt 0.375000 0.000000
+vt 0.625000 0.000000
+vt 0.625000 0.250000
+vt 0.375000 0.250000
+vt 0.125000 0.500000
+vt 0.375000 0.500000
+vt 0.125000 0.750000
+vt 0.625000 0.500000
+vt 0.625000 0.500000
+vt 0.875000 0.500000
+vt 0.875000 0.750000
+vt 0.625000 0.000000
+vt 0.625000 0.250000
+vn 0.0000 0.0000 1.0000
+vn -1.0000 0.0000 0.0000
+vn 0.0000 -1.0000 0.0000
+vn 1.0000 0.0000 0.0000
+vn 0.0000 0.0000 -1.0000
+vn 0.0000 1.0000 0.0000
+usemtl Material.004
+s off
+f 67/96/31 63/97/31 69/98/31 70/99/31
+f 64/100/31 63/97/31 67/96/31 68/101/31
+f 68/102/32 67/103/32 65/104/32 66/105/32
+f 66/106/33 62/107/33 64/100/33 68/108/33
+f 62/107/34 61/109/34 63/97/34 64/100/34
+f 66/105/35 65/104/35 61/109/35 62/107/35
+f 71/110/36 72/111/36 70/112/36 69/98/36
+f 65/104/31 67/103/31 70/113/31 72/114/31
+f 63/97/31 61/109/31 71/110/31 69/98/31
+f 61/109/31 65/104/31 72/114/31 71/110/31
diff --git a/res/shaders/face.fs b/res/shaders/face.fs
new file mode 100644
index 0000000..d82949e
--- /dev/null
+++ b/res/shaders/face.fs
@@ -0,0 +1,15 @@
+#version 420 core
+
+in vec3 _f_texture;
+
+layout (binding = 1) uniform sampler2DArray _u_texture;
+
+out vec4 _o_colour;
+
+void main() {
+ vec4 texture = texture(_u_texture, _f_texture);
+ if (texture.a < 0.60f) {
+ discard;
+ }
+ _o_colour = texture;
+}
diff --git a/res/shaders/face.vs b/res/shaders/face.vs
new file mode 100644
index 0000000..a939dbd
--- /dev/null
+++ b/res/shaders/face.vs
@@ -0,0 +1,12 @@
+#version 420 core
+layout (location = 0) in vec3 _l_position;
+layout (location = 1) in vec3 _l_texture;
+
+out vec3 _f_texture;
+
+uniform mat4 _u_matrix;
+
+void main() {
+ _f_texture = _l_texture;
+ gl_Position = _u_matrix * vec4(_l_position, 1.0);
+}
diff --git a/res/shaders/framebuffer.fs b/res/shaders/framebuffer.fs
new file mode 100644
index 0000000..b644980
--- /dev/null
+++ b/res/shaders/framebuffer.fs
@@ -0,0 +1,100 @@
+#version 420 core
+
+in vec2 _f_texture;
+
+layout(binding = 2) uniform sampler2D main_colour;
+layout(binding = 3) uniform sampler2D main_depth;
+layout(binding = 4) uniform sampler2D water_colour;
+layout(binding = 5) uniform sampler2D water_depth;
+
+layout(std140, binding = 0) uniform _u_globals {
+ mat4 proj;
+ mat4 view;
+ vec4 frustum[6];
+ float znear;
+ float zfar;
+ float xfov;
+ float yfov;
+ int time;
+ float xwindow;
+ float ywindow;
+};
+
+uniform bool _u_is_underwater;
+
+const vec3 fog_colour = vec3(0.5f, 0.7f, 0.9f);
+const vec3 underwater_fog_colour = vec3(0.137f, 0.275f, 0.694f);
+
+out vec4 _o_colour;
+
+vec4 texture_sample(const sampler2D sampler, const vec2 coord) {
+ return texture(sampler, coord);
+}
+
+float depth_sample(const sampler2D sampler, const vec2 coord) {
+ return texture(sampler, coord).r;
+}
+
+float linearise_depth(const float depth) {
+ const float z = depth * 2.0f - 1.0f; // normalised device coordinates
+ const float linear_depth =
+ (2.0 * znear * zfar) / (zfar + znear - (z * (zfar - znear)));
+ // Usually we would just return linear depth, but this is incorrect! We need
+ // to account for the additional distance of the frustum away from the
+ // center of the screen. Just some trigonomety
+
+ const float xsigma = tan(xfov * 0.5) * zfar * _f_texture.x;
+ const float ysigma = tan(yfov * 0.5) * zfar * _f_texture.y;
+ const float dist = sqrt(xsigma * xsigma + ysigma * ysigma) / zfar;
+
+ const float o_dist = linear_depth * dist;
+ return sqrt(o_dist * o_dist + linear_depth * linear_depth);
+}
+
+float get_fog_intensity(const float distance) {
+ return clamp(pow((1.0f / (zfar * 0.6f)) * distance, 3.0f), 0.0f, 1.0f);
+}
+
+float get_water_intensity(const float distance) {
+ return 1.0f - exp(0.5 * distance);
+}
+
+void main() {
+ // We recycle the coordinates of our position into our texture coordinates.
+ const vec2 coords =
+ vec2((_f_texture.x + 1.0f) / 2.0f, (_f_texture.y + 1.0f) / 2.0f);
+
+ const float main_depth = depth_sample(main_depth, coords);
+ const float main_distance = linearise_depth(main_depth);
+ const float water_depth = depth_sample(water_depth, coords);
+ const float water_distance = linearise_depth(water_depth);
+
+ _o_colour = texture_sample(main_colour, coords);
+ if (!_u_is_underwater) {
+ if (water_depth < main_depth) {
+ _o_colour =
+ vec4(mix(vec3(_o_colour.rgb),
+ texture_sample(water_colour, coords).rgb,
+ get_water_intensity(water_distance - main_distance)),
+ 1.0f);
+ }
+ _o_colour =
+ vec4(mix(vec3(_o_colour.rgb), fog_colour,
+ get_fog_intensity(min(main_distance, water_distance))),
+ 1.0f);
+ } else {
+ _o_colour = vec4(mix(vec3(_o_colour.rgb), fog_colour,
+ get_fog_intensity(main_distance)),
+ 1.0f);
+ if (water_depth < main_depth) {
+ _o_colour = vec4(mix(vec3(_o_colour.rgb),
+ texture_sample(water_colour, coords).rgb,
+ get_water_intensity(-water_distance)),
+ 1.0f);
+ } else {
+ _o_colour = vec4(mix(vec3(_o_colour.rgb), underwater_fog_colour,
+ get_water_intensity(-main_distance)),
+ 1.0f);
+ }
+ }
+}
diff --git a/res/shaders/framebuffer.vs b/res/shaders/framebuffer.vs
new file mode 100644
index 0000000..88579b6
--- /dev/null
+++ b/res/shaders/framebuffer.vs
@@ -0,0 +1,9 @@
+#version 420 core
+layout (location = 0) in vec2 _l_position;
+
+out vec2 _f_texture;
+
+void main() {
+ _f_texture = _l_position;
+ gl_Position = vec4(_l_position.xy, 0.0f, 1.0f);
+}
diff --git a/res/shaders/line.fs b/res/shaders/line.fs
new file mode 100644
index 0000000..04cba86
--- /dev/null
+++ b/res/shaders/line.fs
@@ -0,0 +1,55 @@
+#version 420 core
+
+uniform vec4 _u_colour;
+
+layout(std140, binding = 0) uniform _u_globals {
+ mat4 proj;
+ mat4 view;
+ vec4 frustum[6];
+ float znear;
+ float zfar;
+ float xfov;
+ float yfov;
+ int time;
+ float xwindow;
+ float ywindow;
+};
+layout(binding = 2) uniform sampler2D main_colour;
+layout(binding = 3) uniform sampler2D main_depth;
+
+out vec4 _o_colour;
+
+vec4 texture_sample(const sampler2D sampler, const vec2 coord) {
+ return texture(sampler, coord);
+}
+
+float depth_sample(const sampler2D sampler, const vec2 coord) {
+ return texture(sampler, coord).r;
+}
+
+void main() {
+ const vec2 coords = vec2(gl_FragCoord.x / xwindow, gl_FragCoord.y / ywindow);
+
+ const float cur_depth = depth_sample(main_depth, coords);
+ gl_FragDepth = gl_FragCoord.z * 0.9999f;
+ if (gl_FragDepth > cur_depth) {
+ discard;
+ }
+
+ _o_colour = vec4(0.0f, 0.0f, 0.0f, 1.0f);
+
+ // This is for dynamically choosing a higher contrast colour, but it's not
+ // that nice of an effect so it's commented out.
+ /*
+ const vec2 coords = vec2(gl_FragCoord.x / xwindow, gl_FragCoord.y / ywindow);
+ const float cur_depth = depth_sample(main_depth, coords);
+ gl_FragDepth = gl_FragCoord.z * 0.9999f;
+ if (gl_FragDepth > cur_depth) {
+ discard;
+ }
+
+ const vec4 cur_tex = texture_sample(main_colour, coords);
+ const float clr = (1.0f - (cur_tex.r + cur_tex.g + cur_tex.b) / 3.0f) > 0.5f ? 1.0f : 0.0f;
+ _o_colour = vec4(clr, clr, clr, 1.0f);
+ */
+}
diff --git a/res/shaders/line.vs b/res/shaders/line.vs
new file mode 100644
index 0000000..7ad4775
--- /dev/null
+++ b/res/shaders/line.vs
@@ -0,0 +1,8 @@
+#version 420 core
+layout (location = 0) in vec3 _l_position;
+
+uniform mat4 _u_matrix;
+
+void main() {
+ gl_Position = _u_matrix * vec4(_l_position, 1.0f);
+}
diff --git a/res/shaders/model.fs b/res/shaders/model.fs
new file mode 100644
index 0000000..9244ff6
--- /dev/null
+++ b/res/shaders/model.fs
@@ -0,0 +1,9 @@
+#version 420 core
+
+in vec2 _f_texture;
+
+out vec4 _o_colour;
+
+void main() {
+ _o_colour = vec4(0.4, 0.4, 0.4, 1.0);
+}
diff --git a/res/shaders/model.vs b/res/shaders/model.vs
new file mode 100644
index 0000000..47b104d
--- /dev/null
+++ b/res/shaders/model.vs
@@ -0,0 +1,13 @@
+#version 420 core
+layout (location = 0) in vec3 _l_position;
+layout (location = 1) in vec3 _l_normals;
+layout (location = 2) in vec2 _l_texture;
+
+uniform mat4 _u_matrix;
+
+out vec2 _f_texture;
+
+void main() {
+ _f_texture = _l_texture;
+ gl_Position = _u_matrix * vec4(_l_position, 1.0);
+}
diff --git a/res/shaders/postprocess.fs b/res/shaders/postprocess.fs
new file mode 100644
index 0000000..af09c2c
--- /dev/null
+++ b/res/shaders/postprocess.fs
@@ -0,0 +1,105 @@
+#version 420 core
+
+in vec2 _f_texture;
+
+layout(binding = 2) uniform sampler2D main_colour;
+
+layout(std140, binding = 0) uniform _u_globals {
+ mat4 proj;
+ mat4 view;
+ vec4 frustum[6];
+ float znear;
+ float zfar;
+ float xfov;
+ float yfov;
+ uint time;
+};
+
+const float u_lumaThreshold = 0.125f;
+const float u_mulReduce = 1.0f / 8.0f;
+const float u_minReduce = 1.0f / 128.0f;
+const float u_maxSpan = 8.0f;
+
+out vec4 _o_colour;
+
+void main() {
+ const vec2 coords =
+ vec2((_f_texture.x + 1.0f) / 2.0f, (_f_texture.y + 1.0f) / 2.0f);
+
+ vec3 rgbM = texture(main_colour, coords).rgb;
+ vec2 size = textureSize(main_colour, 0);
+ vec2 u_texelStep = vec2(1.0f / size.x, 1.0f / size.y);
+
+ // Sampling neighbour texels. Offsets are adapted to OpenGL texture coordinates.
+ vec3 rgbNW = textureOffset(main_colour, coords, ivec2(-1, 1)).rgb;
+ vec3 rgbNE = textureOffset(main_colour, coords, ivec2(1, 1)).rgb;
+ vec3 rgbSW = textureOffset(main_colour, coords, ivec2(-1, -1)).rgb;
+ vec3 rgbSE = textureOffset(main_colour, coords, ivec2(1, -1)).rgb;
+
+ // see http://en.wikipedia.org/wiki/Grayscale
+ const vec3 toLuma = vec3(0.299, 0.587, 0.114);
+
+ // Convert from RGB to luma.
+ float lumaNW = dot(rgbNW, toLuma);
+ float lumaNE = dot(rgbNE, toLuma);
+ float lumaSW = dot(rgbSW, toLuma);
+ float lumaSE = dot(rgbSE, toLuma);
+ float lumaM = dot(rgbM, toLuma);
+
+ // Gather minimum and maximum luma.
+ float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
+ float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
+
+ // If contrast is lower than a maximum threshold ...
+ if (lumaMax - lumaMin <= lumaMax * u_lumaThreshold)
+ {
+ // ... do no AA and return.
+ _o_colour = vec4(rgbM, 1.0);
+
+ return;
+ }
+
+ // Sampling is done along the gradient.
+ vec2 samplingDirection;
+ samplingDirection.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
+ samplingDirection.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
+
+ // Sampling step distance depends on the luma: The brighter the sampled texels, the smaller the final sampling step direction.
+ // This results, that brighter areas are less blurred/more sharper than dark areas.
+ float samplingDirectionReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * 0.25 * u_mulReduce, u_minReduce);
+
+ // Factor for norming the sampling direction plus adding the brightness influence.
+ float minSamplingDirectionFactor = 1.0 / (min(abs(samplingDirection.x), abs(samplingDirection.y)) + samplingDirectionReduce);
+
+ // Calculate final sampling direction vector by reducing, clamping to a range and finally adapting to the texture size.
+ samplingDirection = clamp(samplingDirection * minSamplingDirectionFactor, vec2(-u_maxSpan), vec2(u_maxSpan)) * u_texelStep;
+
+ // Inner samples on the tab.
+ vec3 rgbSampleNeg = texture(main_colour, coords + samplingDirection * (1.0/3.0 - 0.5)).rgb;
+ vec3 rgbSamplePos = texture(main_colour, coords + samplingDirection * (2.0/3.0 - 0.5)).rgb;
+
+ vec3 rgbTwoTab = (rgbSamplePos + rgbSampleNeg) * 0.5;
+
+ // Outer samples on the tab.
+ vec3 rgbSampleNegOuter = texture(main_colour, coords + samplingDirection * (0.0/3.0 - 0.5)).rgb;
+ vec3 rgbSamplePosOuter = texture(main_colour, coords + samplingDirection * (3.0/3.0 - 0.5)).rgb;
+
+ vec3 rgbFourTab = (rgbSamplePosOuter + rgbSampleNegOuter) * 0.25 + rgbTwoTab * 0.5;
+
+ // Calculate luma for checking against the minimum and maximum value.
+ float lumaFourTab = dot(rgbFourTab, toLuma);
+
+ // Are outer samples of the tab beyond the edge ...
+ if (lumaFourTab < lumaMin || lumaFourTab > lumaMax)
+ {
+ // ... yes, so use only two samples.
+ _o_colour = vec4(rgbTwoTab, 1.0);
+ }
+ else
+ {
+ // ... no, so use four samples.
+ _o_colour = vec4(rgbFourTab, 1.0);
+ }
+
+ //_o_colour.r = 1.0f;
+}
diff --git a/res/shaders/rectangle.fs b/res/shaders/rectangle.fs
new file mode 100644
index 0000000..97ca400
--- /dev/null
+++ b/res/shaders/rectangle.fs
@@ -0,0 +1,9 @@
+#version 330 core
+
+uniform vec4 _u_colour;
+
+out vec4 _o_colour;
+
+void main() {
+ _o_colour = _u_colour;
+}
diff --git a/res/shaders/rectangle.vs b/res/shaders/rectangle.vs
new file mode 100644
index 0000000..6adb73d
--- /dev/null
+++ b/res/shaders/rectangle.vs
@@ -0,0 +1,8 @@
+#version 330 core
+layout (location = 0) in vec2 _l_position;
+
+uniform mat4 _u_matrix;
+
+void main() {
+ gl_Position = _u_matrix * vec4(_l_position, 0.0f, 1.0f);
+}
diff --git a/res/shaders/text.fs b/res/shaders/text.fs
new file mode 100644
index 0000000..0408f2c
--- /dev/null
+++ b/res/shaders/text.fs
@@ -0,0 +1,13 @@
+#version 420 core
+
+in vec2 _f_texture;
+
+layout (binding = 0) uniform sampler2D text;
+uniform vec4 _u_colour;
+
+out vec4 _o_colour;
+
+void main() {
+ float alpha = texture(text, _f_texture).r;
+ _o_colour = vec4(_u_colour.rgb, alpha * _u_colour.a);
+}
diff --git a/res/shaders/text.vs b/res/shaders/text.vs
new file mode 100644
index 0000000..19ae8cb
--- /dev/null
+++ b/res/shaders/text.vs
@@ -0,0 +1,14 @@
+#version 330 core
+
+layout (location = 0) in vec2 vertex;
+layout (location = 1) in vec2 texture;
+
+// <vec2 pos, vec2 tex>
+out vec2 _f_texture;
+
+uniform mat4 _u_matrix;
+
+void main() {
+ _f_texture = texture;
+ gl_Position = _u_matrix * vec4(vertex.xy, 0.0, 1.0);
+}
diff --git a/res/textures/atlas.png b/res/textures/atlas.png
new file mode 100644
index 0000000..207dffc
--- /dev/null
+++ b/res/textures/atlas.png
Binary files differ
diff --git a/res/textures/atlas.xcf b/res/textures/atlas.xcf
new file mode 100644
index 0000000..cabc72c
--- /dev/null
+++ b/res/textures/atlas.xcf
Binary files differ
diff --git a/res/textures/debug.png b/res/textures/debug.png
new file mode 100644
index 0000000..bf1eb54
--- /dev/null
+++ b/res/textures/debug.png
Binary files differ