Move shaders and textures into subdirectories.
authorBernie Innocenti <bernie@codewiz.org>
Sat, 8 Jul 2017 01:21:29 +0000 (21:21 -0400)
committerBernie Innocenti <bernie@codewiz.org>
Sat, 8 Jul 2017 01:21:29 +0000 (21:21 -0400)
shaders/mandelwow.frag [new file with mode: 0644]
shaders/mandelwow.vert [new file with mode: 0644]
shaders/shaded.frag [new file with mode: 0644]
shaders/shaded.vert [new file with mode: 0644]
shaders/solid.frag [new file with mode: 0644]
shaders/solid.vert [new file with mode: 0644]
textures/c64-font-color.png [new file with mode: 0644]
textures/c64-font.gray [new file with mode: 0644]
textures/c64-font.png [new file with mode: 0644]

diff --git a/shaders/mandelwow.frag b/shaders/mandelwow.frag
new file mode 100644 (file)
index 0000000..0551a34
--- /dev/null
@@ -0,0 +1,25 @@
+#version 100
+precision highp float;
+varying vec2 c;
+varying vec2 z;
+
+void main() {
+    float zx = z.x;
+    float zy = z.y;
+    const int maxiter = 64;
+    for (int iter = maxiter; iter > 0; iter--) {
+        float zx2 = zx * zx;
+        float zy2 = zy * zy;
+        if (zx2 * zy2 > 4.0) {
+          float index = float(iter) / float(maxiter);
+          gl_FragColor = vec4(index, 0.1, 1.0 - index / 2.0, 0.8 - index * index);
+          return;
+        }
+        zy = zx * zy * 2.0 + c.y;
+        zx = zx2 - zy2 + c.x;
+    }
+    gl_FragColor = vec4((sin(z.y) + 1.0) / 4.0,
+                        (sin(z.x) + 1.0) / 4.0,
+                        (sin(c.x) + 1.0) / 4.0,
+                        1.0);
+}
diff --git a/shaders/mandelwow.vert b/shaders/mandelwow.vert
new file mode 100644 (file)
index 0000000..0e67eda
--- /dev/null
@@ -0,0 +1,15 @@
+#version 100
+uniform mat4 perspective;
+uniform mat4 view;
+uniform mat4 model;
+uniform vec2 z0;
+attribute mediump vec3 position;
+varying mediump vec2 c;
+varying mediump vec2 z;
+
+void main() {
+    mat4 modelview = view * model;
+    gl_Position = perspective * modelview * vec4(position, 1.0);
+    c = vec2(position.x, position.y);
+    z = vec2(z0.x, z0.y);
+}
diff --git a/shaders/shaded.frag b/shaders/shaded.frag
new file mode 100644 (file)
index 0000000..492644f
--- /dev/null
@@ -0,0 +1,9 @@
+#version 300 es
+precision lowp float;
+
+flat in vec4 color;
+out vec4 color_out;
+
+void main() {
+    color_out = color;
+}
diff --git a/shaders/shaded.vert b/shaders/shaded.vert
new file mode 100644 (file)
index 0000000..c7c7fa1
--- /dev/null
@@ -0,0 +1,24 @@
+#version 300 es
+precision lowp float;
+
+in vec3 position;
+in vec3 normal;
+flat out vec4 color;  // Shaded color
+
+uniform mat4 model;
+uniform mat4 perspview;
+uniform vec3 col;
+
+void main() {
+    mat4 m = perspview * model;
+    vec3 dark = col * 0.1;
+    vec3 u_light = vec3( 0.5, -0.7, -0.6);
+    vec3 v_normal = transpose(inverse(mat3(model))) * normal;
+
+    float distance = model[3][2];
+    float attenuation = 1. / (1. + distance * distance * 0.05);
+    float brightness = max(dot(normalize(v_normal), normalize(u_light)) * attenuation, 0.0);
+    color = vec4(mix(dark, col, brightness), 1.0);
+
+    gl_Position = m * vec4(position, 1.0);
+}
diff --git a/shaders/solid.frag b/shaders/solid.frag
new file mode 100644 (file)
index 0000000..2fed3bf
--- /dev/null
@@ -0,0 +1,8 @@
+#version 300 es
+precision lowp float;
+
+out vec4 color;
+
+void main() {
+    color = vec4(1.0, 1.0, 1.0, 1.0);
+}
diff --git a/shaders/solid.vert b/shaders/solid.vert
new file mode 100644 (file)
index 0000000..6dd30a4
--- /dev/null
@@ -0,0 +1,12 @@
+#version 300 es
+precision lowp float;
+
+in vec3 position;
+uniform mat4 perspective;
+uniform mat4 view;
+uniform mat4 model;
+
+void main() {
+    mat4 modelview = view * model;
+    gl_Position = perspective * modelview * vec4(position, 1.0);
+}
diff --git a/textures/c64-font-color.png b/textures/c64-font-color.png
new file mode 100644 (file)
index 0000000..61d5e56
Binary files /dev/null and b/textures/c64-font-color.png differ
diff --git a/textures/c64-font.gray b/textures/c64-font.gray
new file mode 100644 (file)
index 0000000..ab49a6b
Binary files /dev/null and b/textures/c64-font.gray differ
diff --git a/textures/c64-font.png b/textures/c64-font.png
new file mode 100644 (file)
index 0000000..4342a5d
Binary files /dev/null and b/textures/c64-font.png differ